@opencode/server 2.1.4 → 2.2.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 +8 -1
- package/dist/api.js +5 -5
- package/dist/auth.js +1 -1
- package/dist/chunks/{pairing-e4x9285j.js → media-uri-0a5jm2na.js} +4 -4
- package/dist/chunks/{pairing-0dncng21.js → media-uri-0n1e9dnh.js} +25 -12
- package/dist/chunks/{pairing-x0608mvx.js → media-uri-1je14sn4.js} +1 -1
- package/dist/chunks/{pairing-2yr2dq97.js → media-uri-22wspztn.js} +2 -2
- package/dist/chunks/{pairing-5w10ccet.js → media-uri-2xcc0x05.js} +1 -1
- package/dist/chunks/{pairing-39nnfjx1.js → media-uri-39nnfjx1.js} +1 -1
- package/dist/chunks/{pairing-x2dckmx1.js → media-uri-3t6z87e1.js} +23 -16
- package/dist/chunks/{pairing-4b0899hb.js → media-uri-6vs5sqy6.js} +2 -2
- package/dist/chunks/{pairing-7b9xm1qg.js → media-uri-7b9xm1qg.js} +1 -1
- package/dist/chunks/{pairing-aj1jc7g7.js → media-uri-8113w26k.js} +8 -6
- package/dist/chunks/{pairing-t3j5ftv1.js → media-uri-9c4eyh8m.js} +3 -3
- package/dist/chunks/{pairing-3te71694.js → media-uri-b1prsepx.js} +4 -4
- package/dist/chunks/{pairing-e7pctymn.js → media-uri-b2k9041j.js} +1 -1
- package/dist/chunks/{pairing-erzfdgke.js → media-uri-bd8755ek.js} +16 -1
- package/dist/chunks/{pairing-f4b2q3tn.js → media-uri-be53s2qz.js} +1 -1
- package/dist/chunks/media-uri-c6sjpm0r.js +83 -0
- package/dist/chunks/{pairing-4qjw9nya.js → media-uri-ckkpcd9y.js} +4 -4
- package/dist/chunks/{pairing-j5aeaa16.js → media-uri-dk68ymtv.js} +1 -1
- package/dist/chunks/{pairing-kcjd09wg.js → media-uri-e46y0tfd.js} +2 -2
- package/dist/chunks/{pairing-k6dz4enc.js → media-uri-fvpjvjpp.js} +24 -23
- package/dist/chunks/{pairing-3154e7fk.js → media-uri-gk0yxcp6.js} +5 -3
- package/dist/chunks/{pairing-gymtz25n.js → media-uri-gqq6kfhc.js} +3 -3
- package/dist/chunks/{pairing-cfhthk6z.js → media-uri-h072q2hm.js} +1 -1
- package/dist/chunks/{pairing-a6kxe6a7.js → media-uri-h3g82chs.js} +12 -4
- package/dist/chunks/{pairing-2b2wekgg.js → media-uri-h9rcwvg0.js} +1 -1
- package/dist/chunks/{pairing-swdgbzpj.js → media-uri-hax1v4bv.js} +4 -2
- package/dist/chunks/{pairing-ga3m49sz.js → media-uri-hnheq3hv.js} +4 -2
- package/dist/chunks/{pairing-j4at0y5c.js → media-uri-j4at0y5c.js} +1 -1
- package/dist/chunks/media-uri-j9gxd9me.js +22 -0
- package/dist/chunks/{pairing-91mt6ewz.js → media-uri-m5rae7m4.js} +2 -2
- package/dist/chunks/{pairing-kqr36gas.js → media-uri-mzs0n5xz.js} +7 -7
- package/dist/chunks/media-uri-n321d8vm.js +46 -0
- package/dist/chunks/media-uri-ndydfxzp.js +105 -0
- package/dist/chunks/{pairing-6xea6nhh.js → media-uri-ppma8fcc.js} +3 -3
- package/dist/chunks/{pairing-qvy2s3nb.js → media-uri-prdak4hd.js} +6 -6
- package/dist/chunks/{pairing-mte34432.js → media-uri-qbhbayp5.js} +3 -3
- package/dist/chunks/{pairing-49c878v9.js → media-uri-qn8kkfq6.js} +12 -3
- package/dist/chunks/{pairing-x9vr2ttf.js → media-uri-r6vmgwff.js} +24 -6
- package/dist/chunks/{pairing-9me4q8wt.js → media-uri-rztv1fyf.js} +4 -4
- package/dist/chunks/{pairing-nv8hzzrz.js → media-uri-wd7b20jw.js} +32 -12
- package/dist/chunks/{pairing-kaqtndqt.js → media-uri-wxj3d9av.js} +4 -11
- package/dist/chunks/{pairing-q69f22pd.js → media-uri-x8dgc261.js} +2 -2
- package/dist/chunks/{pairing-31acg4hb.js → media-uri-xe9t9xr4.js} +7 -3
- package/dist/chunks/media-uri-xthc02cw.js +6 -0
- package/dist/chunks/media-uri-xzvdbbpy.js +40 -0
- package/dist/chunks/{pairing-x74w7e1f.js → media-uri-yet0vexm.js} +1 -1
- package/dist/chunks/{pairing-kd6vzpgq.js → media-uri-yr4wsvrw.js} +2 -2
- package/dist/chunks/{pairing-xmwystkq.js → media-uri-z59gyc0x.js} +2 -2
- package/dist/chunks/{pairing-72ygafj3.js → media-uri-zjy4sw3d.js} +2 -2
- package/dist/cors.js +1 -1
- package/dist/event-feed.d.ts +1 -1
- package/dist/event-feed.js +5 -5
- package/dist/fetch.js +51 -47
- package/dist/handlers/agent.js +6 -6
- package/dist/handlers/command.js +6 -6
- package/dist/handlers/config.js +6 -6
- package/dist/handlers/credential.js +6 -6
- package/dist/handlers/debug.js +6 -6
- package/dist/handlers/event.js +7 -7
- package/dist/handlers/form.js +6 -6
- package/dist/handlers/fs.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.js +8 -8
- 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 +10 -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.js +8 -8
- package/dist/handlers/reference.js +6 -6
- package/dist/handlers/rpc.js +6 -6
- package/dist/handlers/schedule.d.ts +209 -0
- package/dist/handlers/schedule.js +7 -0
- 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 +47 -43
- 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 +3 -3
- package/dist/process.js +55 -49
- package/dist/request-tracing.js +1 -1
- package/dist/routes.d.ts +5 -2
- package/dist/routes.js +50 -46
- package/dist/server-info.js +3 -3
- package/dist/service-status.js +1 -1
- package/dist/workerd.js +52 -48
- package/package.json +9 -8
- package/dist/chunks/pairing-kyxm98pg.js +0 -102
- package/dist/chunks/pairing-pmjbkszz.js +0 -30
- /package/dist/chunks/{pairing-9rqn6x4v.js → media-uri-9rqn6x4v.js} +0 -0
- /package/dist/chunks/{pairing-h6rt5k9s.js → media-uri-h6rt5k9s.js} +0 -0
- /package/dist/chunks/{pairing-q4bn6dy8.js → media-uri-q4bn6dy8.js} +0 -0
- /package/dist/chunks/{pairing-smaf4a18.js → media-uri-smaf4a18.js} +0 -0
- /package/dist/chunks/{pairing-yc7nft6q.js → media-uri-yc7nft6q.js} +0 -0
package/dist/api.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { LocationMiddleware } from "./location";
|
|
2
2
|
import { FormLocationMiddleware } from "./middleware/form-location";
|
|
3
3
|
import { SessionLocationMiddleware } from "./middleware/session-location";
|
|
4
|
-
export declare const Api: import("@opencode/protocol/api").Api<LocationMiddleware, import("effect/http-api/HttpApiMiddleware").HttpApiMiddleware<import("@opencode/core/instance").Services, readonly [typeof import("@opencode/protocol/errors").LocationNotFoundError], never>, FormLocationMiddleware, import("effect/http-api/HttpApiMiddleware").HttpApiMiddleware<import("@opencode/core/instance").Services, readonly [typeof import("@opencode/protocol/errors").InvalidRequestError, typeof import("@opencode/protocol/errors").SessionNotFoundError, typeof import("@opencode/protocol/errors").LocationNotFoundError], never>, SessionLocationMiddleware, import("effect/http-api/HttpApiMiddleware").HttpApiMiddleware<import("@opencode/core/instance").Services, readonly [typeof import("@opencode/protocol/errors").InvalidRequestError, typeof import("@opencode/protocol/errors").SessionNotFoundError, typeof import("@opencode/protocol/errors").LocationNotFoundError], never>, import("effect/http-api/HttpApiGroup").HttpApiGroup<"server.event", import("effect/http-api/HttpApiEndpoint").HttpApiEndpoint<"event.subscribe", "GET", "/api/event", never,
|
|
4
|
+
export declare const Api: import("@opencode/protocol/api").Api<LocationMiddleware, import("effect/http-api/HttpApiMiddleware").HttpApiMiddleware<import("@opencode/core/instance").Services, readonly [typeof import("@opencode/protocol/errors").LocationNotFoundError], never>, FormLocationMiddleware, import("effect/http-api/HttpApiMiddleware").HttpApiMiddleware<import("@opencode/core/instance").Services, readonly [typeof import("@opencode/protocol/errors").InvalidRequestError, typeof import("@opencode/protocol/errors").SessionNotFoundError, typeof import("@opencode/protocol/errors").LocationNotFoundError], never>, SessionLocationMiddleware, import("effect/http-api/HttpApiMiddleware").HttpApiMiddleware<import("@opencode/core/instance").Services, readonly [typeof import("@opencode/protocol/errors").InvalidRequestError, typeof import("@opencode/protocol/errors").SessionNotFoundError, typeof import("@opencode/protocol/errors").LocationNotFoundError], never>, import("effect/http-api/HttpApiGroup").HttpApiGroup<"server.event", import("effect/http-api/HttpApiEndpoint").HttpApiEndpoint<"event.subscribe", "GET", "/api/event", never, import("effect/Schema").toCodecStringTree<import("effect/Schema").Struct<{
|
|
5
|
+
readonly types: import("effect/Schema").optional<import("effect/Schema").ArrayEnsure<import("effect/Schema").Union<readonly [import("effect/Schema").Literals<readonly ("agent.updated" | "command.updated" | "config.updated" | "credential.switched" | "credential.updated" | "filesystem.changed" | "form.cancelled" | "form.created" | "form.replied" | "installation.update-available" | "installation.updated" | "integration.updated" | "location.shutdown" | "mcp.resources.changed" | "mcp.status.changed" | "model.updated" | "models-dev.refreshed" | "permission.asked" | "permission.replied" | "persistent-pty.added" | "persistent-pty.removed" | "plugin.updated" | "project.updated" | "provider.updated" | "pty.created" | "pty.deleted" | "pty.exited" | "pty.updated" | "reference.updated" | "session.agent.selected" | "session.archived" | "session.compaction.delta" | "session.compaction.ended" | "session.compaction.failed" | "session.compaction.started" | "session.created" | "session.deleted" | "session.execution.failed" | "session.execution.interrupted" | "session.execution.started" | "session.execution.succeeded" | "session.forked" | "session.idle" | "session.inbox.cancelled" | "session.inbox.delivered" | "session.inbox.delivery.changed" | "session.inbox.enqueued" | "session.instructions.updated" | "session.metadata.updated" | "session.model.selected" | "session.moved" | "session.permissions" | "session.reasoning.delta" | "session.reasoning.ended" | "session.reasoning.started" | "session.renamed" | "session.retry.scheduled" | "session.revert.cleared" | "session.revert.committed" | "session.revert.staged" | "session.shell.ended" | "session.shell.started" | "session.skill.activated" | "session.status" | "session.step.ended" | "session.step.failed" | "session.step.started" | "session.step.streamed" | "session.synthetic" | "session.text.delta" | "session.text.ended" | "session.text.started" | "session.tool.called" | "session.tool.failed" | "session.tool.input.delta" | "session.tool.input.ended" | "session.tool.input.started" | "session.tool.progress" | "session.tool.success" | "session.unarchived" | "session.usage.updated" | "session.viewed" | "shell.created" | "shell.deleted" | "shell.exited" | "skill.updated" | "tui.command.execute" | "tui.prompt.append" | "tui.session.select" | "tui.toast.show" | "vcs.branch.updated" | "websearch.updated" | "worktree.resolved" | "worktree.updated")[]>, import("effect/Schema").TemplateLiteral<readonly ["rpc.", import("effect/Schema").String]>]>>>;
|
|
6
|
+
}>>, never, never, import("effect/http-api/HttpApiSchema").StreamSse<import("effect/http-api/HttpApiSchema").SseEventFromData<import("effect/Schema").Union<readonly [import("effect/Schema").Struct<{
|
|
5
7
|
readonly id: import("effect/Schema").brand<import("effect/Schema").String, "Event.ID"> & {
|
|
6
8
|
create: () => string & import("effect/Brand").Brand<"Event.ID">;
|
|
7
9
|
};
|
|
@@ -4193,12 +4195,14 @@ export declare const Api: import("@opencode/protocol/api").Api<LocationMiddlewar
|
|
|
4193
4195
|
readonly additions: import("effect/Schema").Int;
|
|
4194
4196
|
readonly deletions: import("effect/Schema").Int;
|
|
4195
4197
|
readonly status: import("effect/Schema").Literals<readonly ["added", "deleted", "modified"]>;
|
|
4198
|
+
readonly more: import("effect/Schema").decodeTo<import("effect/Schema").optional<import("effect/Schema").toType<import("effect/Schema").Literal<true>>>, import("effect/Schema").optionalKey<import("effect/Schema").Literal<true>>, never, never>;
|
|
4196
4199
|
}>>>>, import("effect/Schema").optionalKey<import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
4197
4200
|
readonly file: import("effect/Schema").String;
|
|
4198
4201
|
readonly patch: import("effect/Schema").String;
|
|
4199
4202
|
readonly additions: import("effect/Schema").Int;
|
|
4200
4203
|
readonly deletions: import("effect/Schema").Int;
|
|
4201
4204
|
readonly status: import("effect/Schema").Literals<readonly ["added", "deleted", "modified"]>;
|
|
4205
|
+
readonly more: import("effect/Schema").decodeTo<import("effect/Schema").optional<import("effect/Schema").toType<import("effect/Schema").Literal<true>>>, import("effect/Schema").optionalKey<import("effect/Schema").Literal<true>>, never, never>;
|
|
4202
4206
|
}>>>, never, never>;
|
|
4203
4207
|
}>;
|
|
4204
4208
|
}>;
|
|
@@ -4226,12 +4230,14 @@ export declare const Api: import("@opencode/protocol/api").Api<LocationMiddlewar
|
|
|
4226
4230
|
readonly additions: import("effect/Schema").Int;
|
|
4227
4231
|
readonly deletions: import("effect/Schema").Int;
|
|
4228
4232
|
readonly status: import("effect/Schema").Literals<readonly ["added", "deleted", "modified"]>;
|
|
4233
|
+
readonly more: import("effect/Schema").decodeTo<import("effect/Schema").optional<import("effect/Schema").toType<import("effect/Schema").Literal<true>>>, import("effect/Schema").optionalKey<import("effect/Schema").Literal<true>>, never, never>;
|
|
4229
4234
|
}>>>>, import("effect/Schema").optionalKey<import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
4230
4235
|
readonly file: import("effect/Schema").String;
|
|
4231
4236
|
readonly patch: import("effect/Schema").String;
|
|
4232
4237
|
readonly additions: import("effect/Schema").Int;
|
|
4233
4238
|
readonly deletions: import("effect/Schema").Int;
|
|
4234
4239
|
readonly status: import("effect/Schema").Literals<readonly ["added", "deleted", "modified"]>;
|
|
4240
|
+
readonly more: import("effect/Schema").decodeTo<import("effect/Schema").optional<import("effect/Schema").toType<import("effect/Schema").Literal<true>>>, import("effect/Schema").optionalKey<import("effect/Schema").Literal<true>>, never, never>;
|
|
4235
4241
|
}>>>, never, never>;
|
|
4236
4242
|
}>;
|
|
4237
4243
|
}>;
|
|
@@ -7008,6 +7014,7 @@ export declare const Api: import("@opencode/protocol/api").Api<LocationMiddlewar
|
|
|
7008
7014
|
readonly additions: number;
|
|
7009
7015
|
readonly deletions: number;
|
|
7010
7016
|
readonly status: "added" | "deleted" | "modified";
|
|
7017
|
+
readonly more?: true | undefined;
|
|
7011
7018
|
}[] | undefined;
|
|
7012
7019
|
};
|
|
7013
7020
|
};
|
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/media-uri-9c4eyh8m.js";
|
|
4
|
+
import"./chunks/media-uri-yet0vexm.js";
|
|
5
|
+
import"./chunks/media-uri-gk0yxcp6.js";
|
|
6
|
+
import"./chunks/media-uri-gqq6kfhc.js";
|
|
7
|
+
import"./chunks/media-uri-smaf4a18.js";
|
|
8
8
|
export {
|
|
9
9
|
Api2 as Api
|
|
10
10
|
};
|
package/dist/auth.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
awaitPlugins2,
|
|
3
3
|
response2
|
|
4
|
-
} from "./
|
|
4
|
+
} from "./media-uri-gqq6kfhc.js";
|
|
5
5
|
import {
|
|
6
6
|
Api2
|
|
7
|
-
} from "./
|
|
7
|
+
} from "./media-uri-9c4eyh8m.js";
|
|
8
8
|
|
|
9
9
|
// src/handlers/model.ts
|
|
10
10
|
import { Model } from "@opencode/core/model";
|
|
11
11
|
import { Effect } from "effect";
|
|
12
12
|
import { HttpApiBuilder } from "effect/http-api";
|
|
13
13
|
var ModelHandler2 = HttpApiBuilder.group(Api2, "server.model", (handlers) => Effect.gen(function* () {
|
|
14
|
-
return handlers.handle("model.list", Effect.fn(function* () {
|
|
14
|
+
return handlers.handle("model.list", Effect.fn(function* (ctx) {
|
|
15
15
|
yield* awaitPlugins2;
|
|
16
16
|
const models = yield* Model.Service;
|
|
17
|
-
return yield* response2(models.available());
|
|
17
|
+
return yield* response2(models.available(ctx.query.types));
|
|
18
18
|
})).handle("model.default", Effect.fn(function* () {
|
|
19
19
|
yield* awaitPlugins2;
|
|
20
20
|
const models = yield* Model.Service;
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
2
|
missingSession2,
|
|
3
3
|
failedMessageDecode2
|
|
4
|
-
} from "./
|
|
4
|
+
} from "./media-uri-smaf4a18.js";
|
|
5
5
|
import {
|
|
6
6
|
Api2
|
|
7
|
-
} from "./
|
|
7
|
+
} from "./media-uri-9c4eyh8m.js";
|
|
8
|
+
import {
|
|
9
|
+
wantsMediaRefs2
|
|
10
|
+
} from "./media-uri-xthc02cw.js";
|
|
8
11
|
|
|
9
12
|
// src/handlers/message.ts
|
|
10
13
|
import { SessionMessage } from "@opencode/core/session/message";
|
|
11
14
|
import { Session } from "@opencode/core/session";
|
|
12
15
|
import { Effect, Option, Schema } from "effect";
|
|
16
|
+
import { HttpServerResponse } from "effect/http";
|
|
13
17
|
import { HttpApiBuilder } from "effect/http-api";
|
|
14
18
|
import { InvalidCursorError } from "@opencode/protocol/errors";
|
|
19
|
+
import { SessionMediaMessagesResponse } from "@opencode/protocol/groups/message";
|
|
15
20
|
var DefaultMessagesLimit = 50;
|
|
16
21
|
var Cursor = Schema.Struct({
|
|
17
22
|
id: SessionMessage.ID,
|
|
@@ -34,22 +39,30 @@ var MessageHandler2 = HttpApiBuilder.group(Api2, "server.message", (handlers) =>
|
|
|
34
39
|
return yield* new InvalidCursorError({ message: "Cursor cannot be combined with order" });
|
|
35
40
|
const decoded = ctx.query.cursor ? Option.getOrUndefined(cursor.decode(ctx.query.cursor)) ?? (yield* new InvalidCursorError({ message: "Invalid cursor" })) : undefined;
|
|
36
41
|
const order = decoded?.order ?? ctx.query.order ?? "desc";
|
|
37
|
-
const
|
|
42
|
+
const input = {
|
|
38
43
|
sessionID: ctx.params.sessionID,
|
|
39
44
|
limit: ctx.query.limit ?? DefaultMessagesLimit,
|
|
40
45
|
order,
|
|
41
46
|
type: ctx.query.type,
|
|
42
47
|
cursor: decoded ? { id: decoded.id, direction: decoded.direction } : undefined
|
|
43
|
-
}).pipe(Effect.catchTag("Session.NotFoundError", missingSession2), Effect.catchTag("Session.MessageDecodeError", failedMessageDecode2));
|
|
44
|
-
const first = messages[0];
|
|
45
|
-
const last = messages.at(-1);
|
|
46
|
-
return {
|
|
47
|
-
data: messages,
|
|
48
|
-
cursor: {
|
|
49
|
-
previous: first ? cursor.encode(first, order, "previous") : undefined,
|
|
50
|
-
next: last ? cursor.encode(last, order, "next") : undefined
|
|
51
|
-
}
|
|
52
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);
|
|
53
66
|
}));
|
|
54
67
|
}));
|
|
55
68
|
|
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./
|
|
2
|
+
layer3
|
|
3
|
+
} from "./media-uri-gqq6kfhc.js";
|
|
4
4
|
import {
|
|
5
5
|
formLocationLayer2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./media-uri-gk0yxcp6.js";
|
|
7
7
|
import {
|
|
8
8
|
sessionLocationLayer2
|
|
9
|
-
} from "./
|
|
9
|
+
} from "./media-uri-yet0vexm.js";
|
|
10
10
|
import {
|
|
11
11
|
Api2
|
|
12
|
-
} from "./
|
|
12
|
+
} from "./media-uri-9c4eyh8m.js";
|
|
13
13
|
import {
|
|
14
14
|
Config2
|
|
15
|
-
} from "./
|
|
15
|
+
} from "./media-uri-j4at0y5c.js";
|
|
16
16
|
import {
|
|
17
17
|
CorsConfig2
|
|
18
|
-
} from "./
|
|
18
|
+
} from "./media-uri-q4bn6dy8.js";
|
|
19
19
|
import {
|
|
20
|
-
|
|
21
|
-
} from "./
|
|
20
|
+
layer4
|
|
21
|
+
} from "./media-uri-b1prsepx.js";
|
|
22
22
|
import {
|
|
23
23
|
node2
|
|
24
|
-
} from "./
|
|
24
|
+
} from "./media-uri-mzs0n5xz.js";
|
|
25
25
|
import {
|
|
26
26
|
handlers2
|
|
27
|
-
} from "./
|
|
27
|
+
} from "./media-uri-ndydfxzp.js";
|
|
28
28
|
import {
|
|
29
29
|
authorizationLayer2
|
|
30
|
-
} from "./
|
|
30
|
+
} from "./media-uri-7b9xm1qg.js";
|
|
31
31
|
import {
|
|
32
32
|
schemaErrorLayer2
|
|
33
|
-
} from "./
|
|
33
|
+
} from "./media-uri-bd8755ek.js";
|
|
34
34
|
|
|
35
35
|
// src/routes.ts
|
|
36
36
|
import { Database } from "@opencode/core/database/database";
|
|
@@ -52,6 +52,7 @@ import { Worktree } from "@opencode/core/worktree";
|
|
|
52
52
|
import { Session } from "@opencode/core/session";
|
|
53
53
|
import { Instance } from "@opencode/core/instance/service";
|
|
54
54
|
import { SessionTransfer } from "@opencode/core/session/transfer";
|
|
55
|
+
import { InstructionEntry } from "@opencode/core/session/instruction-entry";
|
|
55
56
|
import { ShellSelect } from "@opencode/core/shell/select";
|
|
56
57
|
import { Job } from "@opencode/core/job";
|
|
57
58
|
import { Mcp } from "@opencode/core/mcp/index";
|
|
@@ -62,11 +63,13 @@ import { LocationServiceMap } from "@opencode/core/location-service-map";
|
|
|
62
63
|
import { LocationActivity } from "@opencode/core/location-activity";
|
|
63
64
|
import { ModelsDev } from "@opencode/core/models-dev";
|
|
64
65
|
import { SessionRestart } from "@opencode/core/session/execution/restart";
|
|
66
|
+
import { Schedule } from "@opencode/core/schedule";
|
|
65
67
|
import { PluginUpdate } from "@opencode/core/plugin/update";
|
|
66
68
|
import { SdkPlugins } from "@opencode/core/plugin/sdk";
|
|
67
69
|
import { WellKnown } from "@opencode/core/wellknown";
|
|
68
70
|
import { Workspace } from "@opencode/core/workspace";
|
|
69
71
|
import { Watcher } from "@opencode/core/filesystem/watcher";
|
|
72
|
+
import { FileWatch } from "@opencode/core/filesystem/file-watch";
|
|
70
73
|
import { HttpRouter } from "effect/http";
|
|
71
74
|
import { HttpApiBuilder } from "effect/http-api";
|
|
72
75
|
import { Context, Effect, Layer, Option } from "effect";
|
|
@@ -84,6 +87,7 @@ var applicationServiceNodes = [
|
|
|
84
87
|
Session.node,
|
|
85
88
|
Instance.node,
|
|
86
89
|
SessionTransfer.node,
|
|
90
|
+
InstructionEntry.node,
|
|
87
91
|
SdkPlugins.node,
|
|
88
92
|
PluginUpdate.node,
|
|
89
93
|
PermissionSaved.node,
|
|
@@ -95,7 +99,9 @@ var applicationServiceNodes = [
|
|
|
95
99
|
LocationServiceMap.node,
|
|
96
100
|
LocationActivity.node,
|
|
97
101
|
SessionRestart.node,
|
|
98
|
-
|
|
102
|
+
Schedule.node,
|
|
103
|
+
Workspace.node,
|
|
104
|
+
FileWatch.node
|
|
99
105
|
];
|
|
100
106
|
var applicationServices = LayerNode.group(applicationServiceNodes);
|
|
101
107
|
function createRoutes2(options = {}, serviceURLs = () => [], overrides = []) {
|
|
@@ -112,6 +118,7 @@ function makeRoutes(auth, options, serviceURLs, overrides, instances) {
|
|
|
112
118
|
App.node.replace(App.configured(options.app)),
|
|
113
119
|
ModelsDev.node.replace(ModelsDev.configured(options.models)),
|
|
114
120
|
Watcher.node.replace(Watcher.configured({ enabled: options.fs?.filewatcher })),
|
|
121
|
+
FileWatch.node.replace(FileWatch.configured({ enabled: options.fs?.filewatcher })),
|
|
115
122
|
FileSystemSearch.node.replace(FileSystemSearch.configured({ fff: options.fs?.fff })),
|
|
116
123
|
Global.node.replace(Global.layerWith(options.config?.directory ? { config: options.config.directory } : {})),
|
|
117
124
|
Config.node.replace(Config.configured({
|
|
@@ -144,8 +151,8 @@ function makeRoutes(auth, options, serviceURLs, overrides, instances) {
|
|
|
144
151
|
})) : build(overrides);
|
|
145
152
|
return serviceLayer.pipe(Layer.flatMap((context) => {
|
|
146
153
|
const services = Layer.succeedContext(context);
|
|
147
|
-
const requestServices = Layer.merge(Layer.succeedContext(Context.pick(Database.Service, Credential.Service, PermissionSaved.Service, PluginUpdate.Service, Project.Service, WellKnown.Service)(context)),
|
|
148
|
-
const api = HttpApiBuilder.layer(Api2, { openapiPath: "/openapi.json" }).pipe(Layer.provide(handlers2.pipe(Layer.provide(services), Layer.provide(Layer.succeed(CorsConfig2, options)))), Layer.provide(formLocationLayer2), Layer.provide(sessionLocationLayer2), Layer.provide(
|
|
154
|
+
const requestServices = Layer.merge(Layer.succeedContext(Context.pick(Database.Service, Credential.Service, PermissionSaved.Service, PluginUpdate.Service, Project.Service, WellKnown.Service)(context)), layer4(serviceURLs, Context.get(context, Global.Service).tmp, options.app));
|
|
155
|
+
const api = HttpApiBuilder.layer(Api2, { openapiPath: "/openapi.json" }).pipe(Layer.provide(handlers2.pipe(Layer.provide(services), Layer.provide(Layer.succeed(CorsConfig2, options)))), Layer.provide(formLocationLayer2), Layer.provide(sessionLocationLayer2), Layer.provide(layer3), Layer.provide(authorizationLayer2), Layer.provide(schemaErrorLayer2), Layer.provide(auth), HttpRouter.provideRequest(requestServices), Layer.provideMerge(services), Layer.provideMerge(HttpRouter.layer));
|
|
149
156
|
return Layer.merge(api, V1Migration.layer.pipe(Layer.provide(services)));
|
|
150
157
|
}));
|
|
151
158
|
}
|
|
@@ -1,33 +1,35 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Api2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./media-uri-9c4eyh8m.js";
|
|
4
4
|
import {
|
|
5
5
|
SESSION_TTL_SECONDS2,
|
|
6
6
|
Config2,
|
|
7
7
|
issueSession2,
|
|
8
8
|
sessionCookieName2
|
|
9
|
-
} from "./
|
|
9
|
+
} from "./media-uri-j4at0y5c.js";
|
|
10
10
|
import {
|
|
11
11
|
Service3
|
|
12
|
-
} from "./
|
|
12
|
+
} from "./media-uri-b1prsepx.js";
|
|
13
13
|
import {
|
|
14
|
-
|
|
15
|
-
} from "./
|
|
14
|
+
Service4
|
|
15
|
+
} from "./media-uri-mzs0n5xz.js";
|
|
16
16
|
|
|
17
17
|
// src/handlers/server.ts
|
|
18
|
+
import { hostname } from "node:os";
|
|
18
19
|
import { Duration, Effect } from "effect";
|
|
19
20
|
import { HttpServerRequest, HttpServerResponse } from "effect/http";
|
|
20
21
|
import { HttpApiBuilder } from "effect/http-api";
|
|
21
22
|
import { PersistentPty } from "@opencode/core/persistent-pty";
|
|
22
23
|
import { UnauthorizedError } from "@opencode/protocol/errors";
|
|
23
24
|
var ServerHandler2 = HttpApiBuilder.group(Api2, "server.server", (handlers) => Effect.gen(function* () {
|
|
24
|
-
const pairing = yield*
|
|
25
|
+
const pairing = yield* Service4;
|
|
25
26
|
const auth = yield* Config2;
|
|
26
27
|
return handlers.handle("server.info", () => Effect.gen(function* () {
|
|
27
28
|
const info = yield* Service3;
|
|
28
29
|
return {
|
|
29
30
|
version: info.app.version ?? "unknown",
|
|
30
31
|
pid: process.pid ?? 0,
|
|
32
|
+
hostname: hostname() || undefined,
|
|
31
33
|
urls: info.urls(),
|
|
32
34
|
paths: info.paths,
|
|
33
35
|
capabilities: { persistentPty: PersistentPty.available }
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
LocationMiddleware2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./media-uri-gqq6kfhc.js";
|
|
4
4
|
import {
|
|
5
5
|
FormLocationMiddleware2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./media-uri-gk0yxcp6.js";
|
|
7
7
|
import {
|
|
8
8
|
SessionLocationMiddleware2
|
|
9
|
-
} from "./
|
|
9
|
+
} from "./media-uri-yet0vexm.js";
|
|
10
10
|
|
|
11
11
|
// src/api.ts
|
|
12
12
|
import { makeDefaultApi } from "@opencode/protocol/api";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__export
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./media-uri-9rqn6x4v.js";
|
|
4
4
|
|
|
5
5
|
// src/server-info.ts
|
|
6
6
|
var exports_server_info = {};
|
|
@@ -8,14 +8,14 @@ __export(exports_server_info, {
|
|
|
8
8
|
ServerInfo: () => exports_server_info,
|
|
9
9
|
Service: () => Service3,
|
|
10
10
|
connectionURLs: () => connectionURLs2,
|
|
11
|
-
layer: () =>
|
|
11
|
+
layer: () => layer4
|
|
12
12
|
});
|
|
13
13
|
import { Context, Layer } from "effect";
|
|
14
14
|
import { networkInterfaces } from "node:os";
|
|
15
15
|
|
|
16
16
|
class Service3 extends Context.Service()("@opencode/server/ServerInfo") {
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function layer4(urls, tmp, app = {}) {
|
|
19
19
|
return Layer.succeed(Service3, Service3.of({ urls, app, paths: { tmp } }));
|
|
20
20
|
}
|
|
21
21
|
function connectionURLs2(value, requestedHostname) {
|
|
@@ -38,4 +38,4 @@ function connectionURLs2(value, requestedHostname) {
|
|
|
38
38
|
];
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
export { Service3,
|
|
41
|
+
export { Service3, layer4, connectionURLs2, exports_server_info };
|
|
@@ -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
|
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import {
|
|
2
|
+
locationErrors2,
|
|
3
|
+
awaitPlugins2
|
|
4
|
+
} from "./media-uri-gqq6kfhc.js";
|
|
5
|
+
import {
|
|
6
|
+
Api2
|
|
7
|
+
} from "./media-uri-9c4eyh8m.js";
|
|
8
|
+
|
|
9
|
+
// src/handlers/generate.ts
|
|
10
|
+
import { Generate } from "@opencode/core/generate";
|
|
11
|
+
import { Location } from "@opencode/core/location";
|
|
12
|
+
import { LocationServiceMap } from "@opencode/core/location-services";
|
|
13
|
+
import { AbsolutePath } from "@opencode/core/schema";
|
|
14
|
+
import {
|
|
15
|
+
InvalidRequestError,
|
|
16
|
+
ModelNotFoundError,
|
|
17
|
+
ProviderRequestError,
|
|
18
|
+
ServiceUnavailableError,
|
|
19
|
+
UnsupportedModelError
|
|
20
|
+
} from "@opencode/protocol/errors";
|
|
21
|
+
import { Global } from "@opencode/util/global";
|
|
22
|
+
import { Effect } from "effect";
|
|
23
|
+
import { HttpApiBuilder } from "effect/http-api";
|
|
24
|
+
var GenerateHandler2 = HttpApiBuilder.group(Api2, "server.generate", (handlers) => Effect.gen(function* () {
|
|
25
|
+
const global = yield* Global.Service;
|
|
26
|
+
const locations = yield* LocationServiceMap.Service;
|
|
27
|
+
const services = locations.get(Location.Ref.make({ directory: AbsolutePath.make(global.config) }));
|
|
28
|
+
const text = Effect.fn("server.generate.text")(function* (request) {
|
|
29
|
+
yield* awaitPlugins2;
|
|
30
|
+
const generate = yield* Generate.Service;
|
|
31
|
+
return { data: { text: yield* generate.text(request.payload).pipe(Effect.mapError(generateError)) } };
|
|
32
|
+
}, Effect.provide(services), locationErrors2);
|
|
33
|
+
const image = Effect.fn("server.generate.image")(function* (request) {
|
|
34
|
+
yield* awaitPlugins2;
|
|
35
|
+
const generate = yield* Generate.Service;
|
|
36
|
+
return { data: yield* generate.image(request.payload).pipe(Effect.mapError(generateError)) };
|
|
37
|
+
}, Effect.provide(services), locationErrors2);
|
|
38
|
+
const decisions = Effect.fn("server.generate.decisions")(function* (request) {
|
|
39
|
+
const names = new Set(request.payload.questions.map((question) => question.name));
|
|
40
|
+
if (names.size !== request.payload.questions.length)
|
|
41
|
+
return yield* new InvalidRequestError({
|
|
42
|
+
message: "Decision question names must be unique",
|
|
43
|
+
field: "questions"
|
|
44
|
+
});
|
|
45
|
+
yield* awaitPlugins2;
|
|
46
|
+
const generate = yield* Generate.Service;
|
|
47
|
+
return { data: yield* generate.decisions(request.payload).pipe(Effect.mapError(generateError)) };
|
|
48
|
+
}, Effect.provide(services), locationErrors2);
|
|
49
|
+
return handlers.handle("generate.text", text).handle("generate.textLegacy", text).handle("generate.image", image).handle("generate.decisions", decisions);
|
|
50
|
+
}));
|
|
51
|
+
function generateError(error) {
|
|
52
|
+
switch (error._tag) {
|
|
53
|
+
case "Generate.ModelNotFoundError":
|
|
54
|
+
return new ModelNotFoundError({ providerID: error.providerID, modelID: error.modelID, message: error.message });
|
|
55
|
+
case "Generate.UnsupportedModelError":
|
|
56
|
+
return new UnsupportedModelError({
|
|
57
|
+
providerID: error.providerID,
|
|
58
|
+
modelID: error.modelID,
|
|
59
|
+
capability: error.capability,
|
|
60
|
+
message: error.message
|
|
61
|
+
});
|
|
62
|
+
case "Generate.InvalidRequestError":
|
|
63
|
+
return new InvalidRequestError({
|
|
64
|
+
message: error.message,
|
|
65
|
+
...error.field === undefined ? {} : { field: error.field }
|
|
66
|
+
});
|
|
67
|
+
case "Generate.ProviderRequestError":
|
|
68
|
+
return new ProviderRequestError({
|
|
69
|
+
providerID: error.providerID,
|
|
70
|
+
reason: error.reason,
|
|
71
|
+
message: error.message,
|
|
72
|
+
...error.status === undefined ? {} : { status: error.status },
|
|
73
|
+
...error.retryAfterMs === undefined ? {} : { retryAfterMs: error.retryAfterMs }
|
|
74
|
+
});
|
|
75
|
+
case "Generate.UnavailableError":
|
|
76
|
+
return new ServiceUnavailableError({
|
|
77
|
+
message: error.message,
|
|
78
|
+
...error.service === undefined ? {} : { service: error.service }
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export { GenerateHandler2 };
|
|
@@ -2,17 +2,17 @@ import {
|
|
|
2
2
|
locationErrors2,
|
|
3
3
|
response2,
|
|
4
4
|
requestRef2
|
|
5
|
-
} from "./
|
|
5
|
+
} from "./media-uri-gqq6kfhc.js";
|
|
6
6
|
import {
|
|
7
7
|
Api2
|
|
8
|
-
} from "./
|
|
8
|
+
} from "./media-uri-9c4eyh8m.js";
|
|
9
9
|
import {
|
|
10
10
|
CorsConfig2,
|
|
11
11
|
isAllowedRequestOrigin2
|
|
12
|
-
} from "./
|
|
12
|
+
} from "./media-uri-q4bn6dy8.js";
|
|
13
13
|
import {
|
|
14
14
|
runPtySocket2
|
|
15
|
-
} from "./
|
|
15
|
+
} from "./media-uri-h6rt5k9s.js";
|
|
16
16
|
|
|
17
17
|
// src/handlers/pty.ts
|
|
18
18
|
import { Pty } from "@opencode/core/pty";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
awaitPlugins2,
|
|
3
3
|
response2
|
|
4
|
-
} from "./
|
|
4
|
+
} from "./media-uri-gqq6kfhc.js";
|
|
5
5
|
import {
|
|
6
6
|
Api2
|
|
7
|
-
} from "./
|
|
7
|
+
} from "./media-uri-9c4eyh8m.js";
|
|
8
8
|
|
|
9
9
|
// src/handlers/websearch.ts
|
|
10
10
|
import { WebSearch } from "@opencode/core/websearch";
|