@opencode/server 2.1.3 → 2.2.0
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 +854 -969
- package/dist/api.js +5 -5
- package/dist/auth.js +1 -1
- package/dist/chunks/server-info-1gwc8nvb.js +69 -0
- package/dist/chunks/{service-status-z554rpg5.js → server-info-1v577ncx.js} +4 -2
- package/dist/chunks/{service-status-79n3507d.js → server-info-1wd9c1m3.js} +3 -3
- package/dist/chunks/{service-status-jwf0kwqx.js → server-info-2eaky32g.js} +12 -3
- package/dist/chunks/{service-status-a30hykaf.js → server-info-2h6qktqa.js} +24 -6
- package/dist/chunks/{service-status-6tj91hdj.js → server-info-4fy84009.js} +3 -3
- package/dist/chunks/{service-status-yzwm8eeq.js → server-info-4q6e7fh8.js} +2 -2
- package/dist/chunks/{service-status-gymtz25n.js → server-info-50bbk3b2.js} +3 -3
- package/dist/chunks/{service-status-rj8tbp10.js → server-info-5b42hxrf.js} +1 -1
- package/dist/chunks/{service-status-x2cwbfak.js → server-info-5pdfedjd.js} +7 -7
- package/dist/chunks/{service-status-1qc831kp.js → server-info-5s6gh8sx.js} +7 -3
- package/dist/chunks/{service-status-vg0x3zn0.js → server-info-6z9pvq7p.js} +1 -1
- package/dist/chunks/{service-status-6v4wsps6.js → server-info-7b9xm1qg.js} +3 -2
- package/dist/chunks/{service-status-7qrtcnv4.js → server-info-a8jcac9a.js} +1 -1
- package/dist/chunks/{service-status-5ewqf72w.js → server-info-az0609r6.js} +4 -2
- package/dist/chunks/server-info-b0f38s3n.js +105 -0
- package/dist/chunks/server-info-b105zy65.js +22 -0
- package/dist/chunks/{service-status-x74w7e1f.js → server-info-b3bmdkga.js} +1 -1
- package/dist/chunks/{service-status-erzfdgke.js → server-info-bd8755ek.js} +16 -1
- package/dist/chunks/server-info-bhbc7551.js +107 -0
- package/dist/chunks/{service-status-11d378s5.js → server-info-btahnm2b.js} +3 -3
- package/dist/chunks/{service-status-c2hv5jmf.js → server-info-cezwbsk5.js} +1 -1
- package/dist/chunks/{service-status-crt28xe4.js → server-info-d0edqfxx.js} +4 -11
- package/dist/chunks/{service-status-e6e4kz0w.js → server-info-e6e4kz0w.js} +1 -1
- package/dist/chunks/{service-status-5adf1am9.js → server-info-f559fakr.js} +2 -2
- package/dist/chunks/{service-status-pf9k0dqe.js → server-info-h29xjj1e.js} +2 -2
- package/dist/chunks/{service-status-3154e7fk.js → server-info-htyf2qs7.js} +5 -3
- package/dist/chunks/{service-status-5680j7c4.js → server-info-j2d131x1.js} +23 -20
- package/dist/chunks/{service-status-j4at0y5c.js → server-info-j4at0y5c.js} +1 -1
- package/dist/chunks/{service-status-r82dtfrk.js → server-info-j87xz9bt.js} +3 -3
- package/dist/chunks/{service-status-y89d99mz.js → server-info-kkdkqt8j.js} +2 -2
- package/dist/chunks/{service-status-vb61dkrm.js → server-info-kqr36gas.js} +8 -8
- package/dist/chunks/server-info-n321d8vm.js +46 -0
- package/dist/chunks/{service-status-rkmbbexc.js → server-info-nx6f5k7a.js} +4 -4
- package/dist/chunks/{service-status-0znmasm1.js → server-info-ny1j968n.js} +2 -2
- package/dist/chunks/server-info-qcg3sqtb.js +38 -0
- package/dist/chunks/{service-status-6e6jjne7.js → server-info-qd0r787n.js} +2 -2
- package/dist/chunks/{service-status-xcxwzp6z.js → server-info-rha2aq18.js} +4 -4
- package/dist/chunks/{service-status-6tjqh8g4.js → server-info-rw1dfckh.js} +8 -4
- package/dist/chunks/{service-status-2e16a9cc.js → server-info-s282vggx.js} +1 -1
- package/dist/chunks/{service-status-k6dz4enc.js → server-info-s802fzg1.js} +21 -20
- package/dist/chunks/{service-status-10kexchg.js → server-info-te8jwba1.js} +2 -2
- package/dist/chunks/{service-status-53jj3zgg.js → server-info-tjtyxt9h.js} +32 -12
- package/dist/chunks/server-info-xthc02cw.js +6 -0
- package/dist/chunks/server-info-yqhefp4s.js +83 -0
- package/dist/chunks/{service-status-7scj3y0h.js → server-info-yxw63vq5.js} +10 -8
- package/dist/chunks/{service-status-krqg3gd2.js → server-info-zcvan105.js} +1 -1
- package/dist/chunks/{service-status-q6jxy1hn.js → server-info-zpr61asr.js} +15 -38
- package/dist/cors.js +1 -1
- package/dist/event-feed.d.ts +1 -1
- package/dist/event-feed.js +3 -3
- package/dist/fetch.js +50 -48
- package/dist/handlers/agent.js +6 -6
- package/dist/handlers/command.js +6 -6
- package/dist/handlers/config.js +6 -6
- package/dist/handlers/credential.js +6 -6
- package/dist/handlers/debug.d.ts +2 -1
- 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.d.ts +2 -1
- package/dist/handlers/fs.js +6 -6
- package/dist/handlers/generate.d.ts +1 -1
- package/dist/handlers/generate.js +6 -6
- package/dist/handlers/integration.js +6 -6
- package/dist/handlers/location.js +6 -6
- package/dist/handlers/mcp.d.ts +3 -1
- package/dist/handlers/mcp.js +8 -6
- package/dist/handlers/media.d.ts +6 -0
- package/dist/handlers/media.js +6 -0
- package/dist/handlers/message.js +7 -6
- package/dist/handlers/migration.js +6 -6
- package/dist/handlers/model.js +6 -6
- package/dist/handlers/permission.js +6 -6
- package/dist/handlers/persistent-pty.d.ts +1 -1
- package/dist/handlers/persistent-pty.js +9 -8
- package/dist/handlers/plugin.js +6 -6
- package/dist/handlers/project.d.ts +1 -1
- 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.d.ts +1 -2
- package/dist/handlers/pty.js +8 -9
- 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.d.ts +3 -1
- package/dist/handlers/session.js +7 -6
- package/dist/handlers/shell.js +6 -6
- package/dist/handlers/skill.js +6 -6
- package/dist/handlers/usage.d.ts +1 -0
- package/dist/handlers/usage.js +11 -0
- package/dist/handlers/vcs.js +6 -6
- package/dist/handlers/voice.d.ts +1 -1
- 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 +46 -44
- package/dist/location.js +4 -4
- package/dist/media-uri.d.ts +6 -0
- package/dist/media-uri.js +6 -0
- package/dist/middleware/authorization.js +2 -2
- package/dist/middleware/form-location.js +3 -3
- package/dist/middleware/schema-error.js +1 -1
- package/dist/middleware/session-location.js +3 -3
- package/dist/pairing.js +5 -5
- package/dist/process.js +54 -51
- package/dist/request-tracing.js +1 -1
- package/dist/routes.d.ts +5 -3
- package/dist/routes.js +49 -47
- package/dist/server-info.js +5 -5
- package/dist/service-status.js +1 -1
- package/dist/workerd.js +51 -49
- package/package.json +12 -10
- package/dist/chunks/service-status-0f489yfb.js +0 -102
- package/dist/chunks/service-status-2f9g7rg2.js +0 -20
- package/dist/chunks/service-status-hwdnjend.js +0 -40
- package/dist/chunks/service-status-j3461ttv.js +0 -59
- package/dist/chunks/service-status-z9g9xjb3.js +0 -30
- package/dist/chunks/service-status-zy1wt1f8.js +0 -23
- package/dist/pty-environment.d.ts +0 -13
- package/dist/pty-environment.js +0 -12
- /package/dist/chunks/{service-status-9rqn6x4v.js → server-info-9rqn6x4v.js} +0 -0
- /package/dist/chunks/{service-status-h6rt5k9s.js → server-info-h6rt5k9s.js} +0 -0
- /package/dist/chunks/{service-status-q4bn6dy8.js → server-info-q4bn6dy8.js} +0 -0
- /package/dist/chunks/{service-status-smaf4a18.js → server-info-smaf4a18.js} +0 -0
- /package/dist/chunks/{service-status-yc7nft6q.js → server-info-yc7nft6q.js} +0 -0
package/dist/api.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Api2
|
|
3
|
-
} from "./chunks/
|
|
4
|
-
import"./chunks/
|
|
5
|
-
import"./chunks/
|
|
6
|
-
import"./chunks/
|
|
7
|
-
import"./chunks/
|
|
3
|
+
} from "./chunks/server-info-j87xz9bt.js";
|
|
4
|
+
import"./chunks/server-info-htyf2qs7.js";
|
|
5
|
+
import"./chunks/server-info-b3bmdkga.js";
|
|
6
|
+
import"./chunks/server-info-50bbk3b2.js";
|
|
7
|
+
import"./chunks/server-info-smaf4a18.js";
|
|
8
8
|
export {
|
|
9
9
|
Api2 as Api
|
|
10
10
|
};
|
package/dist/auth.js
CHANGED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import {
|
|
2
|
+
missingSession2,
|
|
3
|
+
failedMessageDecode2
|
|
4
|
+
} from "./server-info-smaf4a18.js";
|
|
5
|
+
import {
|
|
6
|
+
Api2
|
|
7
|
+
} from "./server-info-j87xz9bt.js";
|
|
8
|
+
import {
|
|
9
|
+
wantsMediaRefs2
|
|
10
|
+
} from "./server-info-xthc02cw.js";
|
|
11
|
+
|
|
12
|
+
// src/handlers/message.ts
|
|
13
|
+
import { SessionMessage } from "@opencode/core/session/message";
|
|
14
|
+
import { Session } from "@opencode/core/session";
|
|
15
|
+
import { Effect, Option, Schema } from "effect";
|
|
16
|
+
import { HttpServerResponse } from "effect/http";
|
|
17
|
+
import { HttpApiBuilder } from "effect/http-api";
|
|
18
|
+
import { InvalidCursorError } from "@opencode/protocol/errors";
|
|
19
|
+
import { SessionMediaMessagesResponse } from "@opencode/protocol/groups/message";
|
|
20
|
+
var DefaultMessagesLimit = 50;
|
|
21
|
+
var Cursor = Schema.Struct({
|
|
22
|
+
id: SessionMessage.ID,
|
|
23
|
+
order: Schema.Union([Schema.Literal("asc"), Schema.Literal("desc")]),
|
|
24
|
+
direction: Schema.Union([Schema.Literal("previous"), Schema.Literal("next")])
|
|
25
|
+
});
|
|
26
|
+
var decodeCursor = Schema.decodeUnknownOption(Schema.fromJsonString(Cursor));
|
|
27
|
+
var cursor = {
|
|
28
|
+
encode(message, order, direction) {
|
|
29
|
+
return Buffer.from(JSON.stringify({ id: message.id, order, direction })).toString("base64url");
|
|
30
|
+
},
|
|
31
|
+
decode(input) {
|
|
32
|
+
return decodeCursor(Buffer.from(input, "base64url").toString("utf8"));
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
var MessageHandler2 = HttpApiBuilder.group(Api2, "server.message", (handlers) => Effect.gen(function* () {
|
|
36
|
+
const session = yield* Session.Service;
|
|
37
|
+
return handlers.handle("session.messages", Effect.fn(function* (ctx) {
|
|
38
|
+
if (ctx.query.cursor && ctx.query.order !== undefined)
|
|
39
|
+
return yield* new InvalidCursorError({ message: "Cursor cannot be combined with order" });
|
|
40
|
+
const decoded = ctx.query.cursor ? Option.getOrUndefined(cursor.decode(ctx.query.cursor)) ?? (yield* new InvalidCursorError({ message: "Invalid cursor" })) : undefined;
|
|
41
|
+
const order = decoded?.order ?? ctx.query.order ?? "desc";
|
|
42
|
+
const input = {
|
|
43
|
+
sessionID: ctx.params.sessionID,
|
|
44
|
+
limit: ctx.query.limit ?? DefaultMessagesLimit,
|
|
45
|
+
order,
|
|
46
|
+
type: ctx.query.type,
|
|
47
|
+
cursor: decoded ? { id: decoded.id, direction: decoded.direction } : undefined
|
|
48
|
+
};
|
|
49
|
+
const page = (messages) => {
|
|
50
|
+
const first = messages[0];
|
|
51
|
+
const last = messages.at(-1);
|
|
52
|
+
return {
|
|
53
|
+
data: messages,
|
|
54
|
+
cursor: {
|
|
55
|
+
previous: first ? cursor.encode(first, order, "previous") : undefined,
|
|
56
|
+
next: last ? cursor.encode(last, order, "next") : undefined
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
if (wantsMediaRefs2(ctx.request)) {
|
|
61
|
+
const messages = yield* session.messagesWithRefs(input).pipe(Effect.catchTag("Session.NotFoundError", missingSession2), Effect.catchTag("Session.MessageDecodeError", failedMessageDecode2));
|
|
62
|
+
return yield* HttpServerResponse.schemaJson(SessionMediaMessagesResponse)(page(messages)).pipe(Effect.orDie);
|
|
63
|
+
}
|
|
64
|
+
const messages = yield* session.messages(input).pipe(Effect.catchTag("Session.NotFoundError", missingSession2), Effect.catchTag("Session.MessageDecodeError", failedMessageDecode2));
|
|
65
|
+
return page(messages);
|
|
66
|
+
}));
|
|
67
|
+
}));
|
|
68
|
+
|
|
69
|
+
export { MessageHandler2 };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
+
awaitPlugins2,
|
|
2
3
|
response2
|
|
3
|
-
} from "./
|
|
4
|
+
} from "./server-info-50bbk3b2.js";
|
|
4
5
|
import {
|
|
5
6
|
Api2
|
|
6
|
-
} from "./
|
|
7
|
+
} from "./server-info-j87xz9bt.js";
|
|
7
8
|
|
|
8
9
|
// src/handlers/agent.ts
|
|
9
10
|
import { Agent } from "@opencode/core/agent";
|
|
@@ -11,6 +12,7 @@ import { Effect } from "effect";
|
|
|
11
12
|
import { HttpApiBuilder } from "effect/http-api";
|
|
12
13
|
import { AgentNotFoundError } from "@opencode/protocol/errors";
|
|
13
14
|
var AgentHandler2 = HttpApiBuilder.group(Api2, "server.agent", (handlers) => handlers.handle("agent.list", () => Effect.gen(function* () {
|
|
15
|
+
yield* awaitPlugins2;
|
|
14
16
|
return yield* response2(Agent.Service.use((agent) => agent.list()));
|
|
15
17
|
})).handle("agent.get", Effect.fn(function* (ctx) {
|
|
16
18
|
const agent = yield* Agent.Service.use((service) => service.get(ctx.params.agentID));
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isAllowedCorsOrigin2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./server-info-q4bn6dy8.js";
|
|
4
4
|
import {
|
|
5
5
|
createRoutes2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./server-info-j2d131x1.js";
|
|
7
7
|
import {
|
|
8
8
|
__export
|
|
9
|
-
} from "./
|
|
9
|
+
} from "./server-info-9rqn6x4v.js";
|
|
10
10
|
|
|
11
11
|
// src/fetch.ts
|
|
12
12
|
var exports_fetch = {};
|
|
@@ -1,18 +1,27 @@
|
|
|
1
1
|
import {
|
|
2
2
|
response2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./server-info-50bbk3b2.js";
|
|
4
4
|
import {
|
|
5
5
|
Api2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./server-info-j87xz9bt.js";
|
|
7
7
|
|
|
8
8
|
// src/handlers/plugin.ts
|
|
9
9
|
import { Plugin } from "@opencode/core/plugin";
|
|
10
10
|
import { PluginUpdate } from "@opencode/core/plugin/update";
|
|
11
|
-
import { InvalidRequestError, ServiceUnavailableError } from "@opencode/protocol/errors";
|
|
11
|
+
import { InvalidRequestError, PluginNotFoundError, ServiceUnavailableError } from "@opencode/protocol/errors";
|
|
12
12
|
import { Cause, Effect, Exit } from "effect";
|
|
13
13
|
import { HttpApiBuilder } from "effect/http-api";
|
|
14
14
|
var PluginHandler2 = HttpApiBuilder.group(Api2, "server.plugin", (handlers) => handlers.handle("plugin.list", () => Effect.gen(function* () {
|
|
15
15
|
return yield* response2(Plugin.Service.use((plugin) => plugin.list()));
|
|
16
|
+
})).handle("plugin.gui", (ctx) => Effect.gen(function* () {
|
|
17
|
+
const plugins = yield* Plugin.Service;
|
|
18
|
+
const bundle = yield* plugins.gui(ctx.query.id);
|
|
19
|
+
if (!bundle)
|
|
20
|
+
return yield* new PluginNotFoundError({
|
|
21
|
+
pluginID: ctx.query.id,
|
|
22
|
+
message: `No active plugin with a ./gui-experimental bundle: ${ctx.query.id}`
|
|
23
|
+
});
|
|
24
|
+
return yield* response2(Effect.succeed(bundle));
|
|
16
25
|
})).handle("plugin.check", (ctx) => Effect.gen(function* () {
|
|
17
26
|
const plugins = yield* Plugin.Service;
|
|
18
27
|
const inventory = yield* plugins.list();
|
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
2
|
response2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./server-info-50bbk3b2.js";
|
|
4
4
|
import {
|
|
5
5
|
Api2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./server-info-j87xz9bt.js";
|
|
7
7
|
|
|
8
8
|
// src/handlers/fs.ts
|
|
9
9
|
import { FileSystem } from "@opencode/core/filesystem";
|
|
10
|
+
import { FileWatch } from "@opencode/core/filesystem/file-watch";
|
|
11
|
+
import { Location } from "@opencode/core/location";
|
|
10
12
|
import { RelativePath } from "@opencode/core/schema";
|
|
11
|
-
import { FileNotFoundError } from "@opencode/protocol/errors";
|
|
13
|
+
import { FileNotFoundError, ServiceUnavailableError } from "@opencode/protocol/errors";
|
|
12
14
|
import { Effect, Option, Stream } from "effect";
|
|
13
15
|
import { HttpServerResponse } from "effect/http";
|
|
14
16
|
import { HttpApiBuilder } from "effect/http-api";
|
|
17
|
+
import path from "path";
|
|
15
18
|
var FileSystemHandler2 = HttpApiBuilder.group(Api2, "server.fs", (handlers) => Effect.gen(function* () {
|
|
19
|
+
const fileWatch = yield* FileWatch.Service;
|
|
16
20
|
return handlers.handleRaw("fs.read", (ctx) => Effect.gen(function* () {
|
|
17
|
-
const
|
|
21
|
+
const path2 = yield* decodeRequestPath(ctx.request.url);
|
|
18
22
|
const fs = yield* FileSystem.Service;
|
|
19
|
-
const file = yield* fs.read({ path }).pipe(Effect.mapError((error) => new FileNotFoundError({ path: error.path, message: `File not found: ${error.path}` })));
|
|
23
|
+
const file = yield* fs.read({ path: path2 }).pipe(Effect.mapError((error) => new FileNotFoundError({ path: error.path, message: `File not found: ${error.path}` })));
|
|
20
24
|
return serveFile(ctx.request, file);
|
|
21
25
|
})).handle("fs.list", (ctx) => response2(Effect.gen(function* () {
|
|
22
26
|
const fs = yield* FileSystem.Service;
|
|
@@ -27,7 +31,21 @@ var FileSystemHandler2 = HttpApiBuilder.group(Api2, "server.fs", (handlers) => E
|
|
|
27
31
|
}))).handle("fs.write", (ctx) => response2(Effect.gen(function* () {
|
|
28
32
|
const fs = yield* FileSystem.Service;
|
|
29
33
|
return yield* fs.write({ path: ctx.query.path, data: ctx.payload });
|
|
30
|
-
})))
|
|
34
|
+
}))).handle("fs.watch", (ctx) => Effect.gen(function* () {
|
|
35
|
+
const fs = yield* FileSystem.Service;
|
|
36
|
+
const location = yield* Location.Service;
|
|
37
|
+
yield* fs.read({ path: RelativePath.make(ctx.payload.path) }).pipe(Effect.mapError((error) => new FileNotFoundError({ path: error.path, message: `File not found: ${error.path}` })));
|
|
38
|
+
yield* fileWatch.watch({
|
|
39
|
+
location: { directory: location.directory, workspaceID: location.workspaceID },
|
|
40
|
+
file: path.resolve(location.directory, ctx.payload.path)
|
|
41
|
+
}).pipe(Effect.mapError((error) => new ServiceUnavailableError({ message: error.message, service: "filewatcher" })));
|
|
42
|
+
})).handle("fs.unwatch", (ctx) => Effect.gen(function* () {
|
|
43
|
+
const location = yield* Location.Service;
|
|
44
|
+
yield* fileWatch.unwatch({
|
|
45
|
+
location: { directory: location.directory, workspaceID: location.workspaceID },
|
|
46
|
+
file: path.resolve(location.directory, ctx.payload.path)
|
|
47
|
+
});
|
|
48
|
+
}));
|
|
31
49
|
}));
|
|
32
50
|
function decodeRequestPath(url) {
|
|
33
51
|
const raw = new URL(url, "http://localhost").pathname.slice(13);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Api2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./server-info-j87xz9bt.js";
|
|
4
4
|
|
|
5
5
|
// src/handlers/worktree.ts
|
|
6
6
|
import { Git } from "@opencode/core/git";
|
|
@@ -14,7 +14,7 @@ var WorktreeHandler2 = HttpApiBuilder.group(Api2, "server.worktree", (handlers)
|
|
|
14
14
|
return handlers.handle("worktree.list", (ctx) => worktrees.list(ctx.query).pipe(Effect.catchTag("Project.NotFoundError", missingProject))).handle("worktree.create", (ctx) => worktrees.create(ctx.payload).pipe(badRequest)).handle("worktree.remove", (ctx) => worktrees.remove(ctx.payload).pipe(badRequest, Effect.as(HttpApiSchema.NoContent.make()))).handle("worktree.refresh", (ctx) => worktrees.refresh(ctx.payload).pipe(badRequest, Effect.as(HttpApiSchema.NoContent.make())));
|
|
15
15
|
}));
|
|
16
16
|
function badRequest(effect) {
|
|
17
|
-
return effect.pipe(Effect.
|
|
17
|
+
return effect.pipe(Effect.mapError((error) => error._tag === "Project.NotFoundError" ? missingProject(error) : new WorktreeError({
|
|
18
18
|
name: "WorktreeError",
|
|
19
19
|
data: {
|
|
20
20
|
message: message(error),
|
|
@@ -23,7 +23,7 @@ function badRequest(effect) {
|
|
|
23
23
|
})));
|
|
24
24
|
}
|
|
25
25
|
function missingProject(error) {
|
|
26
|
-
return
|
|
26
|
+
return new ProjectNotFoundError({ projectID: error.projectID, message: `Project not found: ${error.projectID}` });
|
|
27
27
|
}
|
|
28
28
|
function message(error) {
|
|
29
29
|
if (error instanceof Worktree.SourceDirectoryNotFoundError)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
response2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./server-info-50bbk3b2.js";
|
|
4
4
|
import {
|
|
5
5
|
Api2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./server-info-j87xz9bt.js";
|
|
7
7
|
|
|
8
8
|
// src/handlers/command.ts
|
|
9
9
|
import { Command } from "@opencode/core/command";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
missingSession2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./server-info-smaf4a18.js";
|
|
4
4
|
|
|
5
5
|
// src/location.ts
|
|
6
6
|
import { FileSystem } from "@opencode/core/filesystem";
|
|
@@ -59,7 +59,7 @@ function decode(input) {
|
|
|
59
59
|
return input;
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
var
|
|
62
|
+
var layer4 = Layer.effect(LocationMiddleware2, Effect.gen(function* () {
|
|
63
63
|
const locations = yield* LocationServiceMap.Service;
|
|
64
64
|
return LocationMiddleware2.of((effect) => Effect.gen(function* () {
|
|
65
65
|
const request = yield* HttpServerRequest.HttpServerRequest;
|
|
@@ -67,4 +67,4 @@ var layer2 = 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 };
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__export
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./server-info-9rqn6x4v.js";
|
|
4
4
|
|
|
5
5
|
// src/server-info.ts
|
|
6
6
|
var exports_server_info = {};
|
|
7
7
|
__export(exports_server_info, {
|
|
8
8
|
ServerInfo: () => exports_server_info,
|
|
9
|
-
Service: () =>
|
|
9
|
+
Service: () => Service3,
|
|
10
10
|
connectionURLs: () => connectionURLs2,
|
|
11
|
-
layer: () =>
|
|
11
|
+
layer: () => layer2
|
|
12
12
|
});
|
|
13
13
|
import { Context, Layer } from "effect";
|
|
14
14
|
import { networkInterfaces } from "node:os";
|
|
15
15
|
|
|
16
|
-
class
|
|
16
|
+
class Service3 extends Context.Service()("@opencode/server/ServerInfo") {
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
return Layer.succeed(
|
|
18
|
+
function layer2(urls, tmp, app = {}) {
|
|
19
|
+
return Layer.succeed(Service3, Service3.of({ urls, app, paths: { tmp } }));
|
|
20
20
|
}
|
|
21
21
|
function connectionURLs2(value, requestedHostname) {
|
|
22
22
|
const url = new URL(value);
|
|
@@ -38,4 +38,4 @@ function connectionURLs2(value, requestedHostname) {
|
|
|
38
38
|
];
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
export {
|
|
41
|
+
export { Service3, layer2, connectionURLs2, exports_server_info };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
response2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./server-info-50bbk3b2.js";
|
|
4
4
|
import {
|
|
5
5
|
Api2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./server-info-j87xz9bt.js";
|
|
7
7
|
|
|
8
8
|
// src/handlers/vcs.ts
|
|
9
9
|
import { Vcs } from "@opencode/core/vcs";
|
|
@@ -64,7 +64,11 @@ var VcsHandler2 = HttpApiBuilder.group(Api2, "server.vcs", (handlers) => Effect.
|
|
|
64
64
|
return yield* vcs.branches({ search: ctx.query.search, limit: Math.min(ctx.query.limit ?? 50, 100) });
|
|
65
65
|
}))).handle("vcs.diff", (ctx) => response2(Effect.gen(function* () {
|
|
66
66
|
const vcs = yield* Vcs.Service;
|
|
67
|
-
return yield* vcs.diff(ctx.query.mode, {
|
|
67
|
+
return yield* vcs.diff(ctx.query.mode, {
|
|
68
|
+
context: ctx.query.context,
|
|
69
|
+
base: ctx.query.base,
|
|
70
|
+
untracked: ctx.query.untracked
|
|
71
|
+
}).pipe(Effect.mapError((error) => new ServiceUnavailableError({ service: "vcs", message: error.message })));
|
|
68
72
|
})));
|
|
69
73
|
}));
|
|
70
74
|
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
authorized2,
|
|
5
5
|
verifySession2,
|
|
6
6
|
sessionCookieName2
|
|
7
|
-
} from "./
|
|
7
|
+
} from "./server-info-j4at0y5c.js";
|
|
8
8
|
|
|
9
9
|
// src/middleware/authorization.ts
|
|
10
10
|
import { UnauthorizedError } from "@opencode/protocol/errors";
|
|
@@ -12,6 +12,7 @@ import { Authorization } from "@opencode/protocol/middleware/authorization";
|
|
|
12
12
|
import { Authorization as Authorization2 } from "@opencode/protocol/middleware/authorization";
|
|
13
13
|
import { PTY_CONNECT_PATH, PTY_CONNECT_TICKET_QUERY } from "@opencode/protocol/groups/pty";
|
|
14
14
|
import { PERSISTENT_PTY_CONNECT_PATH } from "@opencode/protocol/groups/persistent-pty";
|
|
15
|
+
import { MCP_CLIENT_PATH } from "@opencode/protocol/groups/mcp";
|
|
15
16
|
import { PAIRING_CONNECT_PATH } from "@opencode/protocol/groups/server";
|
|
16
17
|
import { Effect, Layer, Redacted } from "effect";
|
|
17
18
|
import { Base64 } from "effect/encoding";
|
|
@@ -70,7 +71,7 @@ var authorizationLayer2 = Layer.effect(Authorization, Effect.gen(function* () {
|
|
|
70
71
|
const request = yield* HttpServerRequest.HttpServerRequest;
|
|
71
72
|
const route = yield* HttpRouter.RouteContext;
|
|
72
73
|
const url = new URL(request.url, "http://localhost");
|
|
73
|
-
if ((route.route.path === PTY_CONNECT_PATH || route.route.path === PERSISTENT_PTY_CONNECT_PATH) && !!url.searchParams.get(PTY_CONNECT_TICKET_QUERY) || route.route.path === PAIRING_CONNECT_PATH)
|
|
74
|
+
if ((route.route.path === PTY_CONNECT_PATH || route.route.path === PERSISTENT_PTY_CONNECT_PATH || route.route.path === MCP_CLIENT_PATH) && !!url.searchParams.get(PTY_CONNECT_TICKET_QUERY) || route.route.path === PAIRING_CONNECT_PATH)
|
|
74
75
|
return yield* effect;
|
|
75
76
|
if (yield* authorizedRequest2(request, config))
|
|
76
77
|
return yield* effect;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
+
awaitPlugins2,
|
|
2
3
|
response2
|
|
3
|
-
} from "./
|
|
4
|
+
} from "./server-info-50bbk3b2.js";
|
|
4
5
|
import {
|
|
5
6
|
Api2
|
|
6
|
-
} from "./
|
|
7
|
+
} from "./server-info-j87xz9bt.js";
|
|
7
8
|
|
|
8
9
|
// src/handlers/provider.ts
|
|
9
10
|
import { Provider } from "@opencode/core/provider";
|
|
@@ -12,6 +13,7 @@ import { Effect } from "effect";
|
|
|
12
13
|
import { HttpApiBuilder } from "effect/http-api";
|
|
13
14
|
var ProviderHandler2 = HttpApiBuilder.group(Api2, "server.provider", (handlers) => Effect.gen(function* () {
|
|
14
15
|
return handlers.handle("provider.list", Effect.fn(function* () {
|
|
16
|
+
yield* awaitPlugins2;
|
|
15
17
|
const providers = yield* Provider.Service;
|
|
16
18
|
return yield* response2(providers.available());
|
|
17
19
|
})).handle("provider.get", Effect.fn(function* (ctx) {
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GenerateHandler2
|
|
3
|
+
} from "./server-info-yqhefp4s.js";
|
|
4
|
+
import {
|
|
5
|
+
VoiceHandler2
|
|
6
|
+
} from "./server-info-d0edqfxx.js";
|
|
7
|
+
import {
|
|
8
|
+
MessageHandler2
|
|
9
|
+
} from "./server-info-1gwc8nvb.js";
|
|
10
|
+
import {
|
|
11
|
+
ModelHandler2
|
|
12
|
+
} from "./server-info-rha2aq18.js";
|
|
13
|
+
import {
|
|
14
|
+
ProviderHandler2
|
|
15
|
+
} from "./server-info-az0609r6.js";
|
|
16
|
+
import {
|
|
17
|
+
SessionHandler2
|
|
18
|
+
} from "./server-info-tjtyxt9h.js";
|
|
19
|
+
import {
|
|
20
|
+
PermissionHandler2
|
|
21
|
+
} from "./server-info-btahnm2b.js";
|
|
22
|
+
import {
|
|
23
|
+
FileSystemHandler2
|
|
24
|
+
} from "./server-info-2h6qktqa.js";
|
|
25
|
+
import {
|
|
26
|
+
FormHandler2
|
|
27
|
+
} from "./server-info-f559fakr.js";
|
|
28
|
+
import {
|
|
29
|
+
CommandHandler2
|
|
30
|
+
} from "./server-info-4q6e7fh8.js";
|
|
31
|
+
import {
|
|
32
|
+
SkillHandler2
|
|
33
|
+
} from "./server-info-ny1j968n.js";
|
|
34
|
+
import {
|
|
35
|
+
RpcHandler2
|
|
36
|
+
} from "./server-info-s282vggx.js";
|
|
37
|
+
import {
|
|
38
|
+
layer3
|
|
39
|
+
} from "./server-info-s802fzg1.js";
|
|
40
|
+
import {
|
|
41
|
+
EventHandler2
|
|
42
|
+
} from "./server-info-nx6f5k7a.js";
|
|
43
|
+
import {
|
|
44
|
+
AgentHandler2
|
|
45
|
+
} from "./server-info-1v577ncx.js";
|
|
46
|
+
import {
|
|
47
|
+
PluginHandler2
|
|
48
|
+
} from "./server-info-2eaky32g.js";
|
|
49
|
+
import {
|
|
50
|
+
ServerHandler2
|
|
51
|
+
} from "./server-info-yxw63vq5.js";
|
|
52
|
+
import {
|
|
53
|
+
DebugHandler2
|
|
54
|
+
} from "./server-info-qcg3sqtb.js";
|
|
55
|
+
import {
|
|
56
|
+
PtyHandler2
|
|
57
|
+
} from "./server-info-zpr61asr.js";
|
|
58
|
+
import {
|
|
59
|
+
PersistentPtyHandler2
|
|
60
|
+
} from "./server-info-rw1dfckh.js";
|
|
61
|
+
import {
|
|
62
|
+
ShellHandler2
|
|
63
|
+
} from "./server-info-qd0r787n.js";
|
|
64
|
+
import {
|
|
65
|
+
ReferenceHandler2
|
|
66
|
+
} from "./server-info-te8jwba1.js";
|
|
67
|
+
import {
|
|
68
|
+
LocationHandler2
|
|
69
|
+
} from "./server-info-zcvan105.js";
|
|
70
|
+
import {
|
|
71
|
+
IntegrationHandler2
|
|
72
|
+
} from "./server-info-h29xjj1e.js";
|
|
73
|
+
import {
|
|
74
|
+
WebSearchHandler2
|
|
75
|
+
} from "./server-info-kkdkqt8j.js";
|
|
76
|
+
import {
|
|
77
|
+
UsageHandler2
|
|
78
|
+
} from "./server-info-b105zy65.js";
|
|
79
|
+
import {
|
|
80
|
+
McpHandler2
|
|
81
|
+
} from "./server-info-bhbc7551.js";
|
|
82
|
+
import {
|
|
83
|
+
CredentialHandler2
|
|
84
|
+
} from "./server-info-5b42hxrf.js";
|
|
85
|
+
import {
|
|
86
|
+
ProjectHandler2
|
|
87
|
+
} from "./server-info-a8jcac9a.js";
|
|
88
|
+
import {
|
|
89
|
+
WorktreeHandler2
|
|
90
|
+
} from "./server-info-4fy84009.js";
|
|
91
|
+
import {
|
|
92
|
+
VcsHandler2
|
|
93
|
+
} from "./server-info-5s6gh8sx.js";
|
|
94
|
+
import {
|
|
95
|
+
MigrationHandler2
|
|
96
|
+
} from "./server-info-6z9pvq7p.js";
|
|
97
|
+
import {
|
|
98
|
+
ConfigHandler2
|
|
99
|
+
} from "./server-info-cezwbsk5.js";
|
|
100
|
+
|
|
101
|
+
// src/handlers.ts
|
|
102
|
+
import { Layer } from "effect";
|
|
103
|
+
var handlers2 = Layer.mergeAll(ServerHandler2, DebugHandler2, MigrationHandler2, LocationHandler2, AgentHandler2, PluginHandler2, SessionHandler2, MessageHandler2, ModelHandler2, GenerateHandler2, VoiceHandler2, ProviderHandler2, IntegrationHandler2, WebSearchHandler2, UsageHandler2, McpHandler2, CredentialHandler2, ProjectHandler2, FormHandler2, PermissionHandler2, FileSystemHandler2, CommandHandler2, SkillHandler2, RpcHandler2, EventHandler2.pipe(Layer.provide(layer3)), PtyHandler2, PersistentPtyHandler2, ShellHandler2, ReferenceHandler2, WorktreeHandler2, VcsHandler2, ConfigHandler2);
|
|
104
|
+
|
|
105
|
+
export { handlers2 };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
awaitPlugins2,
|
|
3
|
+
response2
|
|
4
|
+
} from "./server-info-50bbk3b2.js";
|
|
5
|
+
import {
|
|
6
|
+
Api2
|
|
7
|
+
} from "./server-info-j87xz9bt.js";
|
|
8
|
+
|
|
9
|
+
// src/handlers/usage.ts
|
|
10
|
+
import { UsageLimits } from "@opencode/core/usage-limits";
|
|
11
|
+
import { ServiceUnavailableError } from "@opencode/protocol/errors";
|
|
12
|
+
import { Effect } from "effect";
|
|
13
|
+
import { HttpApiBuilder } from "effect/http-api";
|
|
14
|
+
var UsageHandler2 = HttpApiBuilder.group(Api2, "server.usage", (handlers) => Effect.gen(function* () {
|
|
15
|
+
return handlers.handle("usage.limits", Effect.fn("server.usage.limits")(function* () {
|
|
16
|
+
yield* awaitPlugins2;
|
|
17
|
+
const limits = yield* UsageLimits.Service;
|
|
18
|
+
return yield* response2(limits.get().pipe(Effect.map((info) => info ?? null), Effect.mapError((error) => new ServiceUnavailableError({ message: error.message, service: "opencode" }))));
|
|
19
|
+
}));
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
export { UsageHandler2 };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/middleware/schema-error.ts
|
|
2
2
|
import { Effect } from "effect";
|
|
3
|
+
import { HttpServerResponse } from "effect/http";
|
|
3
4
|
import { HttpApiMiddleware } from "effect/http-api";
|
|
4
5
|
import { InvalidRequestError } from "@opencode/protocol/errors";
|
|
5
6
|
import { SchemaErrorMiddleware } from "@opencode/protocol/middleware/schema-error";
|
|
@@ -10,8 +11,22 @@ function truncateReason(reason) {
|
|
|
10
11
|
return reason;
|
|
11
12
|
return reason.slice(0, REASON_LIMIT) + `... (${reason.length - REASON_LIMIT} more chars)`;
|
|
12
13
|
}
|
|
13
|
-
var schemaErrorLayer2 = HttpApiMiddleware.layerSchemaErrorTransform(SchemaErrorMiddleware, (error) => {
|
|
14
|
+
var schemaErrorLayer2 = HttpApiMiddleware.layerSchemaErrorTransform(SchemaErrorMiddleware, (error, context) => {
|
|
14
15
|
const reason = truncateReason(error.cause.message);
|
|
16
|
+
if (error.kind === "Body" || error.kind === "ResponseHeaders") {
|
|
17
|
+
const ref = `err_${crypto.randomUUID().slice(0, 8)}`;
|
|
18
|
+
return Effect.logError("failed to encode response").pipe(Effect.annotateLogs({
|
|
19
|
+
ref,
|
|
20
|
+
kind: error.kind,
|
|
21
|
+
endpoint: `${context.group.identifier}.${context.endpoint.name}`,
|
|
22
|
+
route: `${context.endpoint.method} ${context.endpoint.path}`,
|
|
23
|
+
reason
|
|
24
|
+
}), Effect.as(HttpServerResponse.jsonUnsafe({
|
|
25
|
+
_tag: "UnknownError",
|
|
26
|
+
message: "Server failed to encode its response. Check server logs for details.",
|
|
27
|
+
ref
|
|
28
|
+
}, { status: 500 })));
|
|
29
|
+
}
|
|
15
30
|
return Effect.logWarning("schema rejection").pipe(Effect.annotateLogs({ kind: error.kind, reason }), Effect.andThen(Effect.fail(new InvalidRequestError({ message: reason, kind: error.kind }))));
|
|
16
31
|
});
|
|
17
32
|
|