@opencode/server 0.0.0-dev-19794 → 0.0.0-dev-19808
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.js +10 -9
- package/dist/auth.js +12 -17
- package/dist/chunks/workerd-00nn3k4b.js +20 -0
- package/dist/chunks/workerd-04xw3v55.js +23 -0
- package/dist/chunks/workerd-19c9ysa1.js +61 -0
- package/dist/chunks/workerd-1c4qas2w.js +346 -0
- package/dist/chunks/workerd-254zvkj6.js +22 -0
- package/dist/chunks/workerd-2rvsests.js +99 -0
- package/dist/chunks/workerd-2sy3c7de.js +83 -0
- package/dist/chunks/workerd-3kzx88w9.js +26 -0
- package/dist/chunks/workerd-4g0fa6m0.js +32 -0
- package/dist/chunks/workerd-4vn5bvkr.js +25 -0
- package/dist/chunks/workerd-5rwqcaw2.js +33 -0
- package/dist/chunks/workerd-5w24ch67.js +23 -0
- package/dist/chunks/workerd-6gkz39ey.js +55 -0
- package/dist/chunks/workerd-6nvan4e0.js +17 -0
- package/dist/chunks/workerd-6ptwb1q1.js +149 -0
- package/dist/chunks/workerd-75c938bc.js +23 -0
- package/dist/chunks/workerd-7cfyat0f.js +37 -0
- package/dist/chunks/workerd-7rzt3wm8.js +13 -0
- package/dist/chunks/workerd-8bajbwjh.js +40 -0
- package/dist/chunks/workerd-9rqn6x4v.js +16 -0
- package/dist/chunks/workerd-a6yp8301.js +156 -0
- package/dist/chunks/workerd-arj41x43.js +77 -0
- package/dist/chunks/workerd-b0b71rwa.js +39 -0
- package/dist/chunks/workerd-bjrwanme.js +22 -0
- package/dist/chunks/workerd-bkqymx4n.js +26 -0
- package/dist/chunks/workerd-br99j6q1.js +35 -0
- package/dist/chunks/workerd-ceh2h0m9.js +25 -0
- package/dist/chunks/workerd-hezj1jdf.js +7 -0
- package/dist/chunks/workerd-hjnxtxmk.js +34 -0
- package/dist/chunks/workerd-j2pfq4q6.js +42 -0
- package/dist/chunks/workerd-m6wvgbfq.js +60 -0
- package/dist/chunks/workerd-mzr9gftb.js +36 -0
- package/dist/chunks/workerd-n0er2m55.js +163 -0
- package/dist/chunks/workerd-pnqq1zxv.js +29 -0
- package/dist/chunks/workerd-q0ycym90.js +13 -0
- package/dist/chunks/workerd-q4bn6dy8.js +39 -0
- package/dist/chunks/workerd-qnwpcgp7.js +22 -0
- package/dist/chunks/workerd-qzap92t7.js +139 -0
- package/dist/chunks/workerd-r7e9r02j.js +13 -0
- package/dist/chunks/workerd-rcg4y18n.js +59 -0
- package/dist/chunks/workerd-req22b70.js +22 -0
- package/dist/chunks/workerd-smaf4a18.js +28 -0
- package/dist/chunks/workerd-t8yzmczr.js +18 -0
- package/dist/chunks/workerd-x1haxfjx.js +21 -0
- package/dist/chunks/workerd-yc7nft6q.js +5 -0
- package/dist/chunks/workerd-ysabas57.js +13 -0
- package/dist/chunks/workerd-z5shrcz9.js +19 -0
- package/dist/chunks/workerd-zp2jm6dt.js +15 -0
- package/dist/chunks/workerd-zyv89x5n.js +30 -0
- package/dist/cors.js +10 -36
- package/dist/event-feed.js +20 -60
- package/dist/fetch.js +53 -11
- package/dist/handlers/agent.js +11 -17
- package/dist/handlers/command.js +11 -5
- package/dist/handlers/config.js +11 -16
- package/dist/handlers/credential.js +11 -14
- package/dist/handlers/debug.js +11 -11
- package/dist/handlers/event.js +12 -27
- package/dist/handlers/form.js +11 -9
- package/dist/handlers/fs.js +11 -22
- package/dist/handlers/generate.js +11 -15
- package/dist/handlers/integration.js +10 -142
- package/dist/handlers/location.js +11 -16
- package/dist/handlers/mcp.js +11 -31
- package/dist/handlers/message.js +10 -42
- package/dist/handlers/migration.js +11 -7
- package/dist/handlers/model.js +11 -14
- package/dist/handlers/permission.js +11 -57
- package/dist/handlers/persistent-pty.js +12 -135
- package/dist/handlers/plugin.js +11 -47
- package/dist/handlers/project.js +11 -9
- package/dist/handlers/provider.js +11 -20
- package/dist/handlers/pty-socket.js +6 -4
- package/dist/handlers/pty.js +13 -107
- package/dist/handlers/reference.js +11 -5
- package/dist/handlers/rpc.js +11 -15
- package/dist/handlers/server.js +12 -13
- package/dist/handlers/session-error.js +12 -26
- package/dist/handlers/session.js +10 -311
- package/dist/handlers/shell.js +11 -25
- package/dist/handlers/skill.js +11 -5
- package/dist/handlers/vcs.js +11 -19
- package/dist/handlers/websearch.js +11 -31
- package/dist/handlers/worktree.js +11 -37
- package/dist/handlers.js +46 -33
- package/dist/location.js +15 -49
- package/dist/middleware/authorization.js +11 -49
- package/dist/middleware/form-location.js +10 -25
- package/dist/middleware/schema-error.js +8 -15
- package/dist/middleware/session-location.js +10 -19
- package/dist/options.js +5 -1
- package/dist/process.js +108 -28
- package/dist/pty-environment.js +12 -9
- package/dist/request-tracing.js +6 -2
- package/dist/routes.js +52 -118
- package/dist/server-info.js +12 -22
- package/dist/service-status.js +8 -11
- package/dist/workerd.js +80 -12
- package/package.json +8 -8
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
directory: location.directory,
|
|
13
|
-
project: location.project
|
|
14
|
-
});
|
|
15
|
-
})).handle("location.reload", () => LocationServiceMap.reload().pipe(Effect.provideService(LocationServiceMap.Service, locations), Effect.catchCause((cause) => Cause.hasInterruptsOnly(cause) ? Effect.failCause(cause) : Effect.fail(new ServiceUnavailableError({ message: Cause.pretty(cause), service: "location" })))));
|
|
16
|
-
}));
|
|
1
|
+
import {
|
|
2
|
+
LocationHandler2
|
|
3
|
+
} from "../chunks/workerd-req22b70.js";
|
|
4
|
+
import"../chunks/workerd-z5shrcz9.js";
|
|
5
|
+
import"../chunks/workerd-3kzx88w9.js";
|
|
6
|
+
import"../chunks/workerd-5rwqcaw2.js";
|
|
7
|
+
import"../chunks/workerd-6gkz39ey.js";
|
|
8
|
+
import"../chunks/workerd-smaf4a18.js";
|
|
9
|
+
export {
|
|
10
|
+
LocationHandler2 as LocationHandler
|
|
11
|
+
};
|
package/dist/handlers/mcp.js
CHANGED
|
@@ -1,31 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
})).handle("mcp.add", Effect.fn(function* (ctx) {
|
|
13
|
-
yield* (yield* Mcp.Service).add(ctx.params.server, ctx.payload.config);
|
|
14
|
-
return HttpApiSchema.NoContent.make();
|
|
15
|
-
})).handle("mcp.remove", Effect.fn(function* (ctx) {
|
|
16
|
-
const service = yield* Mcp.Service;
|
|
17
|
-
yield* notFound(service.remove(ctx.params.server));
|
|
18
|
-
return HttpApiSchema.NoContent.make();
|
|
19
|
-
})).handle("mcp.connect", Effect.fn(function* (ctx) {
|
|
20
|
-
const service = yield* Mcp.Service;
|
|
21
|
-
yield* notFound(service.connect(ctx.params.server));
|
|
22
|
-
return HttpApiSchema.NoContent.make();
|
|
23
|
-
})).handle("mcp.disconnect", Effect.fn(function* (ctx) {
|
|
24
|
-
const service = yield* Mcp.Service;
|
|
25
|
-
yield* notFound(service.disconnect(ctx.params.server));
|
|
26
|
-
return HttpApiSchema.NoContent.make();
|
|
27
|
-
})).handle("mcp.resource.catalog", Effect.fn(function* () {
|
|
28
|
-
const service = yield* Mcp.Service;
|
|
29
|
-
return yield* response(service.resourceCatalog());
|
|
30
|
-
}));
|
|
31
|
-
}));
|
|
1
|
+
import {
|
|
2
|
+
McpHandler2
|
|
3
|
+
} from "../chunks/workerd-8bajbwjh.js";
|
|
4
|
+
import"../chunks/workerd-z5shrcz9.js";
|
|
5
|
+
import"../chunks/workerd-3kzx88w9.js";
|
|
6
|
+
import"../chunks/workerd-5rwqcaw2.js";
|
|
7
|
+
import"../chunks/workerd-6gkz39ey.js";
|
|
8
|
+
import"../chunks/workerd-smaf4a18.js";
|
|
9
|
+
export {
|
|
10
|
+
McpHandler2 as McpHandler
|
|
11
|
+
};
|
package/dist/handlers/message.js
CHANGED
|
@@ -1,43 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
direction: Schema.Union([Schema.Literal("previous"), Schema.Literal("next")])
|
|
12
|
-
}), decodeCursor = Schema.decodeUnknownSync(Cursor), cursor = {
|
|
13
|
-
encode(message, order, direction) {
|
|
14
|
-
return Buffer.from(JSON.stringify({ id: message.id, order, direction })).toString("base64url");
|
|
15
|
-
},
|
|
16
|
-
decode(input) {
|
|
17
|
-
return decodeCursor(JSON.parse(Buffer.from(input, "base64url").toString("utf8")));
|
|
18
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
MessageHandler2
|
|
3
|
+
} from "../chunks/workerd-rcg4y18n.js";
|
|
4
|
+
import"../chunks/workerd-z5shrcz9.js";
|
|
5
|
+
import"../chunks/workerd-3kzx88w9.js";
|
|
6
|
+
import"../chunks/workerd-5rwqcaw2.js";
|
|
7
|
+
import"../chunks/workerd-6gkz39ey.js";
|
|
8
|
+
import"../chunks/workerd-smaf4a18.js";
|
|
9
|
+
export {
|
|
10
|
+
MessageHandler2 as MessageHandler
|
|
19
11
|
};
|
|
20
|
-
export const MessageHandler = HttpApiBuilder.group(Api, "server.message", (handlers) => Effect.gen(function* () {
|
|
21
|
-
const session = yield* Session.Service;
|
|
22
|
-
return handlers.handle("session.messages", Effect.fn(function* (ctx) {
|
|
23
|
-
if (ctx.query.cursor && ctx.query.order !== void 0)
|
|
24
|
-
return yield* new InvalidCursorError({ message: "Cursor cannot be combined with order" });
|
|
25
|
-
const decoded = yield* Effect.try({
|
|
26
|
-
try: () => ctx.query.cursor ? cursor.decode(ctx.query.cursor) : void 0,
|
|
27
|
-
catch: () => new InvalidCursorError({ message: "Invalid cursor" })
|
|
28
|
-
}), order = decoded?.order ?? ctx.query.order ?? "desc", messages = yield* session.messages({
|
|
29
|
-
sessionID: ctx.params.sessionID,
|
|
30
|
-
limit: ctx.query.limit ?? DefaultMessagesLimit,
|
|
31
|
-
order,
|
|
32
|
-
type: ctx.query.type,
|
|
33
|
-
cursor: decoded ? { id: decoded.id, direction: decoded.direction } : void 0
|
|
34
|
-
}).pipe(Effect.catchTag("Session.NotFoundError", missingSession), Effect.catchTag("Session.MessageDecodeError", failedMessageDecode)), first = messages[0], last = messages.at(-1);
|
|
35
|
-
return {
|
|
36
|
-
data: messages,
|
|
37
|
-
cursor: {
|
|
38
|
-
previous: first ? cursor.encode(first, order, "previous") : void 0,
|
|
39
|
-
next: last ? cursor.encode(last, order, "next") : void 0
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
}));
|
|
43
|
-
}));
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import {
|
|
2
|
+
MigrationHandler2
|
|
3
|
+
} from "../chunks/workerd-7rzt3wm8.js";
|
|
4
|
+
import"../chunks/workerd-z5shrcz9.js";
|
|
5
|
+
import"../chunks/workerd-3kzx88w9.js";
|
|
6
|
+
import"../chunks/workerd-5rwqcaw2.js";
|
|
7
|
+
import"../chunks/workerd-6gkz39ey.js";
|
|
8
|
+
import"../chunks/workerd-smaf4a18.js";
|
|
9
|
+
export {
|
|
10
|
+
MigrationHandler2 as MigrationHandler
|
|
11
|
+
};
|
package/dist/handlers/model.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return yield* response(models.default());
|
|
13
|
-
}));
|
|
14
|
-
}));
|
|
1
|
+
import {
|
|
2
|
+
ModelHandler2
|
|
3
|
+
} from "../chunks/workerd-254zvkj6.js";
|
|
4
|
+
import"../chunks/workerd-z5shrcz9.js";
|
|
5
|
+
import"../chunks/workerd-3kzx88w9.js";
|
|
6
|
+
import"../chunks/workerd-5rwqcaw2.js";
|
|
7
|
+
import"../chunks/workerd-6gkz39ey.js";
|
|
8
|
+
import"../chunks/workerd-smaf4a18.js";
|
|
9
|
+
export {
|
|
10
|
+
ModelHandler2 as ModelHandler
|
|
11
|
+
};
|
|
@@ -1,57 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
function missingRequest(id) {
|
|
13
|
-
return new PermissionNotFoundError({ requestID: id, message: `Permission request not found: ${id}` });
|
|
14
|
-
}
|
|
15
|
-
export const PermissionHandler = HttpApiBuilder.group(Api, "server.permission", (handlers) => Effect.gen(function* () {
|
|
16
|
-
const instances = yield* Instance.Service, sessions = yield* Session.Service, requireOwnedRequest = Effect.fnUntraced(function* (sessionID, requestID) {
|
|
17
|
-
const permission = yield* Permission.Service, request = yield* permission.get(requestID);
|
|
18
|
-
if (!request || request.sessionID !== sessionID)
|
|
19
|
-
return yield* missingRequest(requestID);
|
|
20
|
-
return { permission, request };
|
|
21
|
-
});
|
|
22
|
-
return handlers.handle("permission.request.list", Effect.fn(function* () {
|
|
23
|
-
const permission = yield* Permission.Service;
|
|
24
|
-
return yield* response(permission.list());
|
|
25
|
-
})).handle("session.permission.create", Effect.fn(function* (ctx) {
|
|
26
|
-
return {
|
|
27
|
-
data: yield* (yield* Permission.Service).ask({
|
|
28
|
-
id: ctx.payload.id,
|
|
29
|
-
sessionID: ctx.params.sessionID,
|
|
30
|
-
action: ctx.payload.action,
|
|
31
|
-
resources: ctx.payload.resources,
|
|
32
|
-
save: ctx.payload.save,
|
|
33
|
-
metadata: ctx.payload.metadata,
|
|
34
|
-
source: ctx.payload.source,
|
|
35
|
-
agent: ctx.payload.agent
|
|
36
|
-
}).pipe(Effect.catchTag("Session.NotFoundError", missingSession))
|
|
37
|
-
};
|
|
38
|
-
})).handle("session.permission.list", Effect.fn(function* (ctx) {
|
|
39
|
-
const session = yield* sessionInfo(sessions, ctx.params.sessionID);
|
|
40
|
-
return { data: yield* Permission.Service.use((permission) => permission.forSession(ctx.params.sessionID)).pipe(instances.provide(session)) };
|
|
41
|
-
})).handle("session.permission.get", Effect.fn(function* (ctx) {
|
|
42
|
-
return { data: (yield* requireOwnedRequest(ctx.params.sessionID, ctx.params.requestID)).request };
|
|
43
|
-
})).handle("session.permission.reply", Effect.fn(function* (ctx) {
|
|
44
|
-
yield* (yield* requireOwnedRequest(ctx.params.sessionID, ctx.params.requestID)).permission.reply({ requestID: ctx.params.requestID, reply: ctx.payload.decision, message: ctx.payload.message }).pipe(Effect.catchTag("Permission.NotFoundError", () => missingRequest(ctx.params.requestID)));
|
|
45
|
-
return HttpApiSchema.NoContent.make();
|
|
46
|
-
})).handle("permission.saved.list", Effect.fn(function* (ctx) {
|
|
47
|
-
const location = yield* Location.Service;
|
|
48
|
-
return {
|
|
49
|
-
data: yield* (yield* PermissionSaved.Service).list({
|
|
50
|
-
projectID: ctx.query.projectID ?? location.project.id
|
|
51
|
-
})
|
|
52
|
-
};
|
|
53
|
-
})).handle("permission.saved.remove", Effect.fn(function* (ctx) {
|
|
54
|
-
yield* (yield* PermissionSaved.Service).remove(ctx.params.id);
|
|
55
|
-
return HttpApiSchema.NoContent.make();
|
|
56
|
-
}));
|
|
57
|
-
}));
|
|
1
|
+
import {
|
|
2
|
+
PermissionHandler2
|
|
3
|
+
} from "../chunks/workerd-arj41x43.js";
|
|
4
|
+
import"../chunks/workerd-z5shrcz9.js";
|
|
5
|
+
import"../chunks/workerd-3kzx88w9.js";
|
|
6
|
+
import"../chunks/workerd-5rwqcaw2.js";
|
|
7
|
+
import"../chunks/workerd-6gkz39ey.js";
|
|
8
|
+
import"../chunks/workerd-smaf4a18.js";
|
|
9
|
+
export {
|
|
10
|
+
PermissionHandler2 as PermissionHandler
|
|
11
|
+
};
|
|
@@ -1,136 +1,13 @@
|
|
|
1
|
-
import { PersistentPty } from "@opencode/core/persistent-pty";
|
|
2
|
-
import { PtyTicket } from "@opencode/core/pty/ticket";
|
|
3
|
-
import { ForbiddenError, PtyNotFoundError, ServiceUnavailableError } from "@opencode/protocol/errors";
|
|
4
1
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const tickets = yield* PtyTicket.Service, cors = yield* CorsConfig, pty = yield* PersistentPty.Service;
|
|
18
|
-
return handlers.handle("persistentPty.read", Effect.fn(function* (ctx) {
|
|
19
|
-
return { data: yield* pty.read(ctx.params.sessionID, ctx.query.lines).pipe(mapUnavailable) };
|
|
20
|
-
})).handle("persistentPty.list", Effect.fn(function* (ctx) {
|
|
21
|
-
return { data: yield* pty.list(ctx.params.sessionID).pipe(mapUnavailable) };
|
|
22
|
-
})).handle("persistentPty.create", Effect.fn(function* (ctx) {
|
|
23
|
-
return {
|
|
24
|
-
data: yield* pty.create(ctx.params.sessionID, {
|
|
25
|
-
command: ctx.payload.command,
|
|
26
|
-
args: ctx.payload.args,
|
|
27
|
-
cwd: ctx.payload.cwd,
|
|
28
|
-
title: ctx.payload.title,
|
|
29
|
-
env: ctx.payload.env,
|
|
30
|
-
cols: ctx.payload.size?.cols,
|
|
31
|
-
rows: ctx.payload.size?.rows
|
|
32
|
-
}).pipe(Effect.catchTag("PersistentPty.UnavailableError", unavailable))
|
|
33
|
-
};
|
|
34
|
-
})).handle("persistentPty.shutdown", Effect.fn(function* () {
|
|
35
|
-
yield* pty.shutdown().pipe(mapUnavailable);
|
|
36
|
-
return HttpApiSchema.NoContent.make();
|
|
37
|
-
})).handle("persistentPty.handoff", Effect.fn(function* () {
|
|
38
|
-
return { handoff: yield* pty.handoff().pipe(mapUnavailable) };
|
|
39
|
-
})).handle("persistentPty.get", Effect.fn(function* (ctx) {
|
|
40
|
-
return { data: yield* pty.get(ctx.params.ptyID).pipe(mapTerminalError) };
|
|
41
|
-
})).handle("persistentPty.update", Effect.fn(function* (ctx) {
|
|
42
|
-
yield* pty.resize(ctx.params.ptyID, ctx.payload.size.cols, ctx.payload.size.rows, ctx.payload.attachmentID).pipe(mapTerminalError);
|
|
43
|
-
return { data: yield* pty.get(ctx.params.ptyID).pipe(mapTerminalError) };
|
|
44
|
-
})).handle("persistentPty.snapshot", Effect.fn(function* (ctx) {
|
|
45
|
-
return { data: yield* pty.snapshot(ctx.params.ptyID).pipe(mapTerminalError) };
|
|
46
|
-
})).handle("persistentPty.remove", Effect.fn(function* (ctx) {
|
|
47
|
-
yield* pty.remove(ctx.params.ptyID).pipe(mapTerminalError);
|
|
48
|
-
return HttpApiSchema.NoContent.make();
|
|
49
|
-
})).handle("persistentPty.connectToken", Effect.fn(function* (ctx) {
|
|
50
|
-
const request = yield* HttpServerRequest.HttpServerRequest;
|
|
51
|
-
if (request.headers[PTY_CONNECT_TOKEN_HEADER] !== PTY_CONNECT_TOKEN_HEADER_VALUE || !isAllowedRequestOrigin(request.headers.origin, request.headers.host, cors))
|
|
52
|
-
return yield* new ForbiddenError({ message: "Invalid persistent PTY connect token request" });
|
|
53
|
-
yield* pty.get(ctx.params.ptyID).pipe(mapTerminalError);
|
|
54
|
-
return { data: yield* tickets.issue({ ptyID: ctx.params.ptyID }) };
|
|
55
|
-
})).handleRaw("persistentPty.connect", Effect.fn("PersistentPtyHandler.connect")(function* (ctx) {
|
|
56
|
-
const url = new URL(ctx.request.url, "http://localhost"), ticket = url.searchParams.get(PTY_CONNECT_TICKET_QUERY);
|
|
57
|
-
if (ticket) {
|
|
58
|
-
if (!(isAllowedRequestOrigin(ctx.request.headers.origin, ctx.request.headers.host, cors) ? yield* tickets.consume({ ticket, ptyID: ctx.params.ptyID }) : !1))
|
|
59
|
-
return HttpServerResponse.empty({ status: 403 });
|
|
60
|
-
}
|
|
61
|
-
const cursor = Number(url.searchParams.get("cursor") ?? "0"), role = url.searchParams.get("role") === "observer" ? "observer" : "controller", framedInput = url.searchParams.get("input_protocol") === "1", attachmentID = url.searchParams.get("attachment_id") ?? crypto.randomUUID();
|
|
62
|
-
if (!Number.isSafeInteger(cursor) || cursor < 0)
|
|
63
|
-
return HttpServerResponse.empty({ status: 400 });
|
|
64
|
-
const socket = yield* Effect.orDie(ctx.request.upgrade), write = yield* socket.writer, outbox = yield* Queue.unbounded(), input = yield* Semaphore.make(1);
|
|
65
|
-
let attachment;
|
|
66
|
-
const onOpen = Effect.gen(function* () {
|
|
67
|
-
attachment = yield* pty.attach(ctx.params.ptyID, {
|
|
68
|
-
cursor,
|
|
69
|
-
attachmentID,
|
|
70
|
-
role,
|
|
71
|
-
takeover: url.searchParams.get("takeover") === "true",
|
|
72
|
-
onEvent: (event) => {
|
|
73
|
-
if (event.type === "output")
|
|
74
|
-
Queue.offerUnsafe(outbox, event.data);
|
|
75
|
-
if (event.type === "resized")
|
|
76
|
-
Queue.offerUnsafe(outbox, JSON.stringify({ ...event, checkpoint: Buffer.from(event.checkpoint).toString("base64") }));
|
|
77
|
-
if (event.type !== "output" && event.type !== "resized")
|
|
78
|
-
Queue.offerUnsafe(outbox, JSON.stringify(event));
|
|
79
|
-
},
|
|
80
|
-
onEnd: () => Queue.offerUnsafe(outbox, new Socket.CloseEvent(1000))
|
|
81
|
-
}).pipe(Effect.catchTags({
|
|
82
|
-
"PersistentPty.NotFoundError": () => Effect.succeed(void 0),
|
|
83
|
-
"PersistentPty.UnavailableError": () => Effect.succeed(void 0)
|
|
84
|
-
}));
|
|
85
|
-
if (!attachment) {
|
|
86
|
-
Queue.offerUnsafe(outbox, new Socket.CloseEvent(4404, "terminal unavailable"));
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
Queue.offerUnsafe(outbox, JSON.stringify({
|
|
90
|
-
type: "attached",
|
|
91
|
-
attachmentID,
|
|
92
|
-
inputProtocol: framedInput ? 1 : 0,
|
|
93
|
-
info: attachment.info,
|
|
94
|
-
role: attachment.role,
|
|
95
|
-
generation: attachment.generation,
|
|
96
|
-
replay: {
|
|
97
|
-
requestedOffset: attachment.replay.requestedOffset,
|
|
98
|
-
availableOffset: attachment.replay.availableOffset,
|
|
99
|
-
endOffset: attachment.replay.endOffset,
|
|
100
|
-
truncated: attachment.replay.truncated
|
|
101
|
-
}
|
|
102
|
-
}));
|
|
103
|
-
if (attachment.replay.data.length > 0)
|
|
104
|
-
Queue.offerUnsafe(outbox, attachment.replay.data);
|
|
105
|
-
Queue.offerUnsafe(outbox, JSON.stringify({ type: "replay_complete", endOffset: attachment.replay.endOffset }));
|
|
106
|
-
attachment.activate();
|
|
107
|
-
}), drain = Effect.gen(function* () {
|
|
108
|
-
while (!0) {
|
|
109
|
-
const item = yield* Queue.take(outbox);
|
|
110
|
-
yield* write(item);
|
|
111
|
-
if (item instanceof Socket.CloseEvent)
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
yield* runPtySocket(drain, socket.runRaw((message) => input.withPermit(Effect.suspend(() => {
|
|
116
|
-
if (!attachment)
|
|
117
|
-
return Effect.void;
|
|
118
|
-
const data = typeof message === "string" ? Buffer.from(message) : message;
|
|
119
|
-
if (!framedInput)
|
|
120
|
-
return pty.input(ctx.params.ptyID, attachmentID, attachment.info.size.cols, attachment.info.size.rows, data).pipe(Effect.ignore);
|
|
121
|
-
if (data.byteLength < 5)
|
|
122
|
-
return Effect.void;
|
|
123
|
-
const view = new DataView(data.buffer, data.byteOffset, data.byteLength), type = data[0], cols = view.getUint16(1), rows = view.getUint16(3);
|
|
124
|
-
if (type !== 0 && type !== 1 || cols === 0 || rows === 0)
|
|
125
|
-
return Effect.void;
|
|
126
|
-
if (type === 0)
|
|
127
|
-
return pty.control(ctx.params.ptyID, attachmentID, cols, rows).pipe(Effect.ignore);
|
|
128
|
-
return pty.input(ctx.params.ptyID, attachmentID, cols, rows, data.subarray(5)).pipe(Effect.ignore);
|
|
129
|
-
})), { onOpen }), () => attachment?.detach()).pipe(Effect.catchReason("SocketError", "SocketCloseError", () => Effect.void), Effect.orDie);
|
|
130
|
-
return HttpServerResponse.empty();
|
|
131
|
-
}));
|
|
132
|
-
}));
|
|
133
|
-
const mapUnavailable = (effect) => effect.pipe(Effect.catchTag("PersistentPty.UnavailableError", unavailable)), mapTerminalError = (effect) => effect.pipe(Effect.catchTags({
|
|
134
|
-
"PersistentPty.NotFoundError": (error) => new PtyNotFoundError({ ptyID: error.ptyID, message: `PTY session not found: ${error.ptyID}` }),
|
|
135
|
-
"PersistentPty.UnavailableError": unavailable
|
|
136
|
-
})), unavailable = (error) => new ServiceUnavailableError({ message: error.message, service: "opencode-pty" });
|
|
2
|
+
PersistentPtyHandler2
|
|
3
|
+
} from "../chunks/workerd-n0er2m55.js";
|
|
4
|
+
import"../chunks/workerd-hezj1jdf.js";
|
|
5
|
+
import"../chunks/workerd-q4bn6dy8.js";
|
|
6
|
+
import"../chunks/workerd-z5shrcz9.js";
|
|
7
|
+
import"../chunks/workerd-3kzx88w9.js";
|
|
8
|
+
import"../chunks/workerd-5rwqcaw2.js";
|
|
9
|
+
import"../chunks/workerd-6gkz39ey.js";
|
|
10
|
+
import"../chunks/workerd-smaf4a18.js";
|
|
11
|
+
export {
|
|
12
|
+
PersistentPtyHandler2 as PersistentPtyHandler
|
|
13
|
+
};
|
package/dist/handlers/plugin.js
CHANGED
|
@@ -1,47 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
...new Set(inventory.flatMap((plugin) => plugin.source.type === "package" ? [plugin.source.target] : []))
|
|
13
|
-
].filter((target) => ctx.payload.target === void 0 || target === ctx.payload.target);
|
|
14
|
-
if (ctx.payload.target !== void 0 && !targets.length)
|
|
15
|
-
return yield* new InvalidRequestError({
|
|
16
|
-
message: `Plugin package is not in the current server inventory: ${ctx.payload.target}`,
|
|
17
|
-
field: "target"
|
|
18
|
-
});
|
|
19
|
-
const updates = yield* PluginUpdate.Service, outdated = new Map(yield* Effect.forEach(targets, (target) => updates.check(target, { refresh: !0 }).pipe(Effect.map((value) => [target, value])), { concurrency: "unbounded" }));
|
|
20
|
-
return yield* response(Effect.succeed(inventory.map((plugin) => {
|
|
21
|
-
if (plugin.source.type !== "package" || !outdated.has(plugin.source.target))
|
|
22
|
-
return plugin;
|
|
23
|
-
return {
|
|
24
|
-
...plugin,
|
|
25
|
-
source: {
|
|
26
|
-
type: "package",
|
|
27
|
-
target: plugin.source.target,
|
|
28
|
-
...plugin.source.version ? { version: plugin.source.version } : {},
|
|
29
|
-
...outdated.get(plugin.source.target) ? { outdated: !0 } : {},
|
|
30
|
-
...plugin.source.updating ? { updating: !0 } : {}
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
})));
|
|
34
|
-
})).handle("plugin.update", (ctx) => Effect.gen(function* () {
|
|
35
|
-
const plugins = yield* Plugin.Service, inventory = new Set((yield* plugins.list()).flatMap((plugin) => plugin.source.type === "package" ? [plugin.source.target] : [])), unknown = ctx.payload.targets.filter((target) => !inventory.has(target));
|
|
36
|
-
if (unknown.length)
|
|
37
|
-
return yield* new InvalidRequestError({
|
|
38
|
-
message: `Plugin packages are not in the current server inventory: ${unknown.join(", ")}`,
|
|
39
|
-
field: "targets"
|
|
40
|
-
});
|
|
41
|
-
const updates = yield* PluginUpdate.Service, failures = yield* Effect.forEach(ctx.payload.targets, (target) => updates.update(target).pipe(Effect.exit, Effect.map((exit) => Exit.isFailure(exit) ? [`${target}: ${Cause.pretty(exit.cause)}`] : [])), { concurrency: "unbounded" }).pipe(Effect.map((results) => results.flat()));
|
|
42
|
-
if (failures.length)
|
|
43
|
-
return yield* new ServiceUnavailableError({
|
|
44
|
-
message: `Failed to update plugin packages: ${failures.join("; ")}`,
|
|
45
|
-
service: "plugin"
|
|
46
|
-
});
|
|
47
|
-
})));
|
|
1
|
+
import {
|
|
2
|
+
PluginHandler2
|
|
3
|
+
} from "../chunks/workerd-19c9ysa1.js";
|
|
4
|
+
import"../chunks/workerd-z5shrcz9.js";
|
|
5
|
+
import"../chunks/workerd-3kzx88w9.js";
|
|
6
|
+
import"../chunks/workerd-5rwqcaw2.js";
|
|
7
|
+
import"../chunks/workerd-6gkz39ey.js";
|
|
8
|
+
import"../chunks/workerd-smaf4a18.js";
|
|
9
|
+
export {
|
|
10
|
+
PluginHandler2 as PluginHandler
|
|
11
|
+
};
|
package/dist/handlers/project.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import {
|
|
2
|
+
ProjectHandler2
|
|
3
|
+
} from "../chunks/workerd-zp2jm6dt.js";
|
|
4
|
+
import"../chunks/workerd-z5shrcz9.js";
|
|
5
|
+
import"../chunks/workerd-3kzx88w9.js";
|
|
6
|
+
import"../chunks/workerd-5rwqcaw2.js";
|
|
7
|
+
import"../chunks/workerd-6gkz39ey.js";
|
|
8
|
+
import"../chunks/workerd-smaf4a18.js";
|
|
9
|
+
export {
|
|
10
|
+
ProjectHandler2 as ProjectHandler
|
|
11
|
+
};
|
|
@@ -1,20 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const provider = yield* (yield* Provider.Service).get(ctx.params.providerID);
|
|
13
|
-
if (!provider)
|
|
14
|
-
return yield* new ProviderNotFoundError({
|
|
15
|
-
providerID: ctx.params.providerID,
|
|
16
|
-
message: `Provider not found: ${ctx.params.providerID}`
|
|
17
|
-
});
|
|
18
|
-
return yield* response(Effect.succeed(provider));
|
|
19
|
-
}));
|
|
20
|
-
}));
|
|
1
|
+
import {
|
|
2
|
+
ProviderHandler2
|
|
3
|
+
} from "../chunks/workerd-pnqq1zxv.js";
|
|
4
|
+
import"../chunks/workerd-z5shrcz9.js";
|
|
5
|
+
import"../chunks/workerd-3kzx88w9.js";
|
|
6
|
+
import"../chunks/workerd-5rwqcaw2.js";
|
|
7
|
+
import"../chunks/workerd-6gkz39ey.js";
|
|
8
|
+
import"../chunks/workerd-smaf4a18.js";
|
|
9
|
+
export {
|
|
10
|
+
ProviderHandler2 as ProviderHandler
|
|
11
|
+
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import {
|
|
2
|
+
runPtySocket2
|
|
3
|
+
} from "../chunks/workerd-hezj1jdf.js";
|
|
4
|
+
export {
|
|
5
|
+
runPtySocket2 as runPtySocket
|
|
6
|
+
};
|