@opencode/server 2.0.8 → 2.0.10
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 +4 -4
- package/dist/api.js +10 -9
- package/dist/auth.js +12 -17
- package/dist/chunks/auth-0ar9gf7q.js +55 -0
- package/dist/chunks/auth-0qzy9yxk.js +163 -0
- package/dist/chunks/auth-1wj0ectp.js +22 -0
- package/dist/chunks/auth-23w8t84j.js +26 -0
- package/dist/chunks/auth-34e6wr3b.js +13 -0
- package/dist/chunks/auth-3582t7j8.js +139 -0
- package/dist/chunks/auth-40g8rvw4.js +59 -0
- package/dist/chunks/auth-5p62ed52.js +36 -0
- package/dist/chunks/auth-6aya8ky6.js +39 -0
- package/dist/chunks/auth-760vtqy2.js +29 -0
- package/dist/chunks/auth-7bj707s9.js +99 -0
- package/dist/chunks/auth-7qtja2kq.js +15 -0
- package/dist/chunks/auth-8e21y1bd.js +20 -0
- package/dist/chunks/auth-8nbs1vvt.js +34 -0
- package/dist/chunks/auth-8ygjd1s8.js +40 -0
- package/dist/chunks/auth-9rqn6x4v.js +16 -0
- package/dist/chunks/auth-b4atwt7w.js +37 -0
- package/dist/chunks/auth-bgzrbsek.js +13 -0
- package/dist/chunks/auth-bkb1xk38.js +42 -0
- package/dist/chunks/auth-bkk2wfbz.js +23 -0
- package/dist/chunks/auth-byzd2nk7.js +21 -0
- package/dist/chunks/auth-cm8xmqjn.js +13 -0
- package/dist/chunks/auth-d2g7egyw.js +25 -0
- package/dist/chunks/auth-e09mshwt.js +23 -0
- package/dist/chunks/auth-erwrh284.js +156 -0
- package/dist/chunks/auth-frv6gfy7.js +33 -0
- package/dist/chunks/auth-fyjxk8m3.js +22 -0
- package/dist/chunks/auth-gsks0nj8.js +149 -0
- package/dist/chunks/auth-hezj1jdf.js +7 -0
- package/dist/chunks/auth-kv6ycdgm.js +77 -0
- package/dist/chunks/auth-m6wvgbfq.js +60 -0
- package/dist/chunks/auth-p5hgn93y.js +26 -0
- package/dist/chunks/auth-pd1pbg0v.js +17 -0
- package/dist/chunks/auth-q4bn6dy8.js +39 -0
- package/dist/chunks/auth-r4dhhtgz.js +346 -0
- package/dist/chunks/auth-rjpqaa8h.js +83 -0
- package/dist/chunks/auth-smaf4a18.js +28 -0
- package/dist/chunks/auth-t8yzmczr.js +18 -0
- package/dist/chunks/auth-tk6nqkmh.js +22 -0
- package/dist/chunks/auth-txhx6f1m.js +13 -0
- package/dist/chunks/auth-vgxn80m1.js +61 -0
- package/dist/chunks/auth-xpxp1sqb.js +22 -0
- package/dist/chunks/auth-xsrtpxyd.js +23 -0
- package/dist/chunks/auth-yc7nft6q.js +5 -0
- package/dist/chunks/auth-z3nth2hg.js +35 -0
- package/dist/chunks/auth-z6kg9h7e.js +19 -0
- package/dist/chunks/auth-zw9j8b8g.js +32 -0
- package/dist/chunks/auth-zxvt7wd3.js +25 -0
- package/dist/chunks/auth-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.d.ts +1 -1
- 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.d.ts +2 -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,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/auth-760vtqy2.js";
|
|
4
|
+
import"../chunks/auth-z6kg9h7e.js";
|
|
5
|
+
import"../chunks/auth-23w8t84j.js";
|
|
6
|
+
import"../chunks/auth-frv6gfy7.js";
|
|
7
|
+
import"../chunks/auth-0ar9gf7q.js";
|
|
8
|
+
import"../chunks/auth-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/auth-hezj1jdf.js";
|
|
4
|
+
export {
|
|
5
|
+
runPtySocket2 as runPtySocket
|
|
6
|
+
};
|
package/dist/handlers/pty.js
CHANGED
|
@@ -1,108 +1,14 @@
|
|
|
1
|
-
import { Pty } from "@opencode/core/pty";
|
|
2
|
-
import { PtyProtocol } from "@opencode/core/pty/protocol";
|
|
3
|
-
import { PtyTicket } from "@opencode/core/pty/ticket";
|
|
4
|
-
import { Location } from "@opencode/core/location";
|
|
5
|
-
import { Effect, Queue } from "effect";
|
|
6
|
-
import { HttpServerRequest, HttpServerResponse } from "effect/unstable/http";
|
|
7
|
-
import { HttpApiBuilder, HttpApiSchema } from "effect/unstable/httpapi";
|
|
8
|
-
import { Socket } from "effect/unstable/socket";
|
|
9
|
-
import { Api } from "../api";
|
|
10
|
-
import { CorsConfig, isAllowedRequestOrigin } from "../cors";
|
|
11
|
-
import { ForbiddenError, PtyNotFoundError } from "@opencode/protocol/errors";
|
|
12
1
|
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return handlers.handle("pty.list", Effect.fn(function* () {
|
|
27
|
-
const pty = yield* Pty.Service;
|
|
28
|
-
return yield* response(pty.list());
|
|
29
|
-
})).handle("pty.create", Effect.fn(function* (ctx) {
|
|
30
|
-
const pty = yield* Pty.Service, location = yield* Location.Service, cwd = ctx.payload.cwd || location.directory;
|
|
31
|
-
return yield* response(pty.create({
|
|
32
|
-
...ctx.payload,
|
|
33
|
-
args: ctx.payload.args ? [...ctx.payload.args] : void 0,
|
|
34
|
-
cwd,
|
|
35
|
-
env: {
|
|
36
|
-
...ctx.payload.env,
|
|
37
|
-
...yield* environment.get({ directory: location.directory, cwd })
|
|
38
|
-
}
|
|
39
|
-
}));
|
|
40
|
-
})).handle("pty.get", Effect.fn(function* (ctx) {
|
|
41
|
-
const pty = yield* Pty.Service;
|
|
42
|
-
return yield* response(pty.get(ctx.params.ptyID).pipe(Effect.catchTag("Pty.NotFoundError", () => new PtyNotFoundError({
|
|
43
|
-
ptyID: ctx.params.ptyID,
|
|
44
|
-
message: `PTY session not found: ${ctx.params.ptyID}`
|
|
45
|
-
}))));
|
|
46
|
-
})).handle("pty.update", Effect.fn(function* (ctx) {
|
|
47
|
-
const pty = yield* Pty.Service;
|
|
48
|
-
return yield* response(pty.update(ctx.params.ptyID, {
|
|
49
|
-
...ctx.payload,
|
|
50
|
-
size: ctx.payload.size ? { ...ctx.payload.size } : void 0
|
|
51
|
-
}).pipe(Effect.catchTag("Pty.NotFoundError", () => new PtyNotFoundError({
|
|
52
|
-
ptyID: ctx.params.ptyID,
|
|
53
|
-
message: `PTY session not found: ${ctx.params.ptyID}`
|
|
54
|
-
}))));
|
|
55
|
-
})).handle("pty.remove", Effect.fn(function* (ctx) {
|
|
56
|
-
yield* (yield* Pty.Service).remove(ctx.params.ptyID).pipe(Effect.catchTag("Pty.NotFoundError", () => new PtyNotFoundError({
|
|
57
|
-
ptyID: ctx.params.ptyID,
|
|
58
|
-
message: `PTY session not found: ${ctx.params.ptyID}`
|
|
59
|
-
})));
|
|
60
|
-
return HttpApiSchema.NoContent.make();
|
|
61
|
-
})).handle("pty.connectToken", Effect.fn(function* (ctx) {
|
|
62
|
-
const request = yield* HttpServerRequest.HttpServerRequest;
|
|
63
|
-
if (request.headers[PTY_CONNECT_TOKEN_HEADER] !== PTY_CONNECT_TOKEN_HEADER_VALUE || !isAllowedRequestOrigin(request.headers.origin, request.headers.host, cors))
|
|
64
|
-
return yield* new ForbiddenError({ message: "Invalid PTY connect token request" });
|
|
65
|
-
yield* (yield* Pty.Service).get(ctx.params.ptyID).pipe(Effect.catchTag("Pty.NotFoundError", () => new PtyNotFoundError({
|
|
66
|
-
ptyID: ctx.params.ptyID,
|
|
67
|
-
message: `PTY session not found: ${ctx.params.ptyID}`
|
|
68
|
-
})));
|
|
69
|
-
return yield* response(tickets.issue({ ptyID: ctx.params.ptyID, ...yield* ticketScope }));
|
|
70
|
-
})).handleRaw("pty.connect", Effect.fn("PtyHandler.connect")(function* (ctx) {
|
|
71
|
-
const pty = yield* Pty.Service;
|
|
72
|
-
if (!(yield* pty.get(ctx.params.ptyID).pipe(Effect.as(!0), Effect.catchTag("Pty.NotFoundError", () => Effect.succeed(!1)))))
|
|
73
|
-
return HttpServerResponse.empty({ status: 404 });
|
|
74
|
-
const url = new URL(ctx.request.url, "http://localhost"), ticket = url.searchParams.get(PTY_CONNECT_TICKET_QUERY);
|
|
75
|
-
if (ticket) {
|
|
76
|
-
if (!(isAllowedRequestOrigin(ctx.request.headers.origin, ctx.request.headers.host, cors) ? yield* tickets.consume({ ticket, ptyID: ctx.params.ptyID, ...yield* ticketScope }) : !1))
|
|
77
|
-
return HttpServerResponse.empty({ status: 403 });
|
|
78
|
-
}
|
|
79
|
-
const parsedCursor = url.searchParams.get("cursor"), cursorNumber = parsedCursor === null ? void 0 : Number(parsedCursor), cursor = cursorNumber !== void 0 && Number.isSafeInteger(cursorNumber) && cursorNumber >= -1 ? cursorNumber : void 0, socket = yield* Effect.orDie(ctx.request.upgrade), write = yield* socket.writer, closeAccepted = (event) => socket.runRaw(() => Effect.void, { onOpen: write(event).pipe(Effect.catch(() => Effect.void)) }).pipe(Effect.timeout("1 second"), Effect.catchReason("SocketError", "SocketCloseError", () => Effect.void), Effect.catch(() => Effect.void)), outbox = yield* Queue.unbounded(), attachment = yield* pty.attach(ctx.params.ptyID, {
|
|
80
|
-
cursor,
|
|
81
|
-
onData: (chunk) => Queue.offerUnsafe(outbox, chunk),
|
|
82
|
-
onEnd: () => Queue.offerUnsafe(outbox, new Socket.CloseEvent(1000))
|
|
83
|
-
}).pipe(Effect.catchTags({
|
|
84
|
-
"Pty.NotFoundError": () => closeAccepted(new Socket.CloseEvent(4404, "session not found")).pipe(Effect.as(void 0)),
|
|
85
|
-
"Pty.ExitedError": () => closeAccepted(new Socket.CloseEvent(4404, "session exited")).pipe(Effect.as(void 0))
|
|
86
|
-
}));
|
|
87
|
-
if (!attachment)
|
|
88
|
-
return HttpServerResponse.empty();
|
|
89
|
-
for (const chunk of PtyProtocol.chunks(attachment.replay))
|
|
90
|
-
Queue.offerUnsafe(outbox, chunk);
|
|
91
|
-
Queue.offerUnsafe(outbox, PtyProtocol.metaFrame(attachment.cursor));
|
|
92
|
-
attachment.activate();
|
|
93
|
-
const drain = Effect.gen(function* () {
|
|
94
|
-
while (!0) {
|
|
95
|
-
const item = yield* Queue.take(outbox);
|
|
96
|
-
yield* write(item);
|
|
97
|
-
if (item instanceof Socket.CloseEvent)
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
yield* runPtySocket(drain, socket.runRaw((message) => {
|
|
102
|
-
const decoded = PtyProtocol.decodeInput(message);
|
|
103
|
-
if (decoded !== void 0)
|
|
104
|
-
attachment.write(decoded);
|
|
105
|
-
}), attachment.detach).pipe(Effect.catchReason("SocketError", "SocketCloseError", () => Effect.void), Effect.orDie);
|
|
106
|
-
return HttpServerResponse.empty();
|
|
107
|
-
}));
|
|
108
|
-
}));
|
|
2
|
+
PtyHandler2
|
|
3
|
+
} from "../chunks/auth-3582t7j8.js";
|
|
4
|
+
import"../chunks/auth-hezj1jdf.js";
|
|
5
|
+
import"../chunks/auth-bkk2wfbz.js";
|
|
6
|
+
import"../chunks/auth-q4bn6dy8.js";
|
|
7
|
+
import"../chunks/auth-z6kg9h7e.js";
|
|
8
|
+
import"../chunks/auth-23w8t84j.js";
|
|
9
|
+
import"../chunks/auth-frv6gfy7.js";
|
|
10
|
+
import"../chunks/auth-0ar9gf7q.js";
|
|
11
|
+
import"../chunks/auth-smaf4a18.js";
|
|
12
|
+
export {
|
|
13
|
+
PtyHandler2 as PtyHandler
|
|
14
|
+
};
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
|
|
1
|
+
import {
|
|
2
|
+
ReferenceHandler2
|
|
3
|
+
} from "../chunks/auth-cm8xmqjn.js";
|
|
4
|
+
import"../chunks/auth-z6kg9h7e.js";
|
|
5
|
+
import"../chunks/auth-23w8t84j.js";
|
|
6
|
+
import"../chunks/auth-frv6gfy7.js";
|
|
7
|
+
import"../chunks/auth-0ar9gf7q.js";
|
|
8
|
+
import"../chunks/auth-smaf4a18.js";
|
|
9
|
+
export {
|
|
10
|
+
ReferenceHandler2 as ReferenceHandler
|
|
11
|
+
};
|
package/dist/handlers/rpc.js
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
type: error.type,
|
|
13
|
-
message: error.message,
|
|
14
|
-
...error.data === void 0 ? {} : { data: error.data }
|
|
15
|
-
})), Effect.catchDefect((defect) => Effect.logError("rpc call failed", { rpc: params.rpcID, method: params.method, defect }).pipe(Effect.andThen(Effect.fail(new RpcInternalError({ type: "rpc.internal", message: "RPC call failed" }))))))));
|
|
1
|
+
import {
|
|
2
|
+
RpcHandler2
|
|
3
|
+
} from "../chunks/auth-1wj0ectp.js";
|
|
4
|
+
import"../chunks/auth-z6kg9h7e.js";
|
|
5
|
+
import"../chunks/auth-23w8t84j.js";
|
|
6
|
+
import"../chunks/auth-frv6gfy7.js";
|
|
7
|
+
import"../chunks/auth-0ar9gf7q.js";
|
|
8
|
+
import"../chunks/auth-smaf4a18.js";
|
|
9
|
+
export {
|
|
10
|
+
RpcHandler2 as RpcHandler
|
|
11
|
+
};
|
package/dist/handlers/server.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
})));
|
|
1
|
+
import {
|
|
2
|
+
ServerHandler2
|
|
3
|
+
} from "../chunks/auth-byzd2nk7.js";
|
|
4
|
+
import"../chunks/auth-5p62ed52.js";
|
|
5
|
+
import"../chunks/auth-z6kg9h7e.js";
|
|
6
|
+
import"../chunks/auth-23w8t84j.js";
|
|
7
|
+
import"../chunks/auth-frv6gfy7.js";
|
|
8
|
+
import"../chunks/auth-0ar9gf7q.js";
|
|
9
|
+
import"../chunks/auth-smaf4a18.js";
|
|
10
|
+
export {
|
|
11
|
+
ServerHandler2 as ServerHandler
|
|
12
|
+
};
|
|
@@ -1,26 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
messageID: error.messageID,
|
|
14
|
-
message: `Message not found: ${error.messageID}`
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
export function failedMessageDecode(error) {
|
|
18
|
-
const ref = `err_${crypto.randomUUID().slice(0, 8)}`;
|
|
19
|
-
return Effect.logError("failed to decode session message").pipe(Effect.annotateLogs({ ref, sessionID: error.sessionID, messageID: error.messageID }), Effect.andThen(Effect.fail(new UnknownError({ message: "Unexpected server error. Check server logs for details.", ref }))));
|
|
20
|
-
}
|
|
21
|
-
export function failedSnapshot(operation, sessionID) {
|
|
22
|
-
return (error) => {
|
|
23
|
-
const ref = `err_${crypto.randomUUID().slice(0, 8)}`;
|
|
24
|
-
return Effect.logError(`failed to ${operation}`, { cause: error }).pipe(Effect.annotateLogs({ ref, sessionID }), Effect.andThen(Effect.fail(new UnknownError({ message: "Unexpected server error. Check server logs for details.", ref }))));
|
|
25
|
-
};
|
|
26
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
missingSession2,
|
|
3
|
+
missingMessage2,
|
|
4
|
+
failedMessageDecode2,
|
|
5
|
+
failedSnapshot2
|
|
6
|
+
} from "../chunks/auth-smaf4a18.js";
|
|
7
|
+
export {
|
|
8
|
+
failedMessageDecode2 as failedMessageDecode,
|
|
9
|
+
failedSnapshot2 as failedSnapshot,
|
|
10
|
+
missingMessage2 as missingMessage,
|
|
11
|
+
missingSession2 as missingSession
|
|
12
|
+
};
|
package/dist/handlers/session.js
CHANGED
|
@@ -1,312 +1,11 @@
|
|
|
1
|
-
import { Session } from "@opencode/core/session";
|
|
2
|
-
import { SessionStats } from "@opencode/core/session/stats";
|
|
3
|
-
import { SessionTitle } from "@opencode/core/session/title";
|
|
4
|
-
import { SessionTransfer } from "@opencode/core/session/transfer";
|
|
5
|
-
import { InstructionEntry } from "@opencode/core/session/instruction-entry";
|
|
6
|
-
import { Form } from "@opencode/core/form";
|
|
7
|
-
import { DateTime, Effect, Stream } from "effect";
|
|
8
|
-
import { HttpApiBuilder, HttpApiSchema } from "effect/unstable/httpapi";
|
|
9
|
-
import { Api } from "../api";
|
|
10
|
-
import { SessionsCursor } from "@opencode/protocol/groups/session";
|
|
11
1
|
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
SessionBusyError,
|
|
23
|
-
SkillNotFoundError
|
|
24
|
-
} from "@opencode/protocol/errors";
|
|
25
|
-
import { AbsolutePath } from "@opencode/core/schema";
|
|
26
|
-
import { failedMessageDecode, failedSnapshot, missingMessage, missingSession } from "./session-error";
|
|
27
|
-
const DefaultSessionsLimit = 50;
|
|
28
|
-
function missingForm(id) {
|
|
29
|
-
return new FormNotFoundError({ id, message: `Form not found: ${id}` });
|
|
30
|
-
}
|
|
31
|
-
export const SessionHandler = HttpApiBuilder.group(Api, "server.session", (handlers) => Effect.gen(function* () {
|
|
32
|
-
const session = yield* Session.Service, transfer = yield* SessionTransfer.Service, requireOwnedForm = Effect.fnUntraced(function* (sessionID, formID) {
|
|
33
|
-
const form = yield* Form.Service, info = yield* form.get(formID).pipe(Effect.catchTag("Form.NotFoundError", () => missingForm(formID)));
|
|
34
|
-
if (info.sessionID !== sessionID)
|
|
35
|
-
return yield* missingForm(formID);
|
|
36
|
-
return { form, info };
|
|
37
|
-
}), busySession = (error) => new SessionBusyError({
|
|
38
|
-
sessionID: error.sessionID,
|
|
39
|
-
message: `Session is busy: ${error.sessionID}`
|
|
40
|
-
}), pendingMutation = (effect, conflict) => effect.pipe(Effect.catchTag("Session.NotFoundError", missingSession), Effect.catchTag("Session.InboxConflictError", (error) => new ConflictError({ resource: error.inboxID, message: `${conflict}: ${error.inboxID}` })), Effect.as(HttpApiSchema.NoContent.make()));
|
|
41
|
-
return handlers.handle("session.list", Effect.fn(function* (ctx) {
|
|
42
|
-
const query = ctx.query.cursor !== void 0 ? yield* SessionsCursor.parse(ctx.query.cursor).pipe(Effect.mapError(() => new InvalidCursorError({ message: "Invalid cursor" }))) : ctx.query, sessions = (yield* session.list({
|
|
43
|
-
...query,
|
|
44
|
-
limit: ctx.query.limit ?? DefaultSessionsLimit
|
|
45
|
-
})).data, first = sessions[0], last = sessions.at(-1);
|
|
46
|
-
return {
|
|
47
|
-
data: sessions,
|
|
48
|
-
cursor: {
|
|
49
|
-
previous: first ? SessionsCursor.make({
|
|
50
|
-
...query,
|
|
51
|
-
anchor: {
|
|
52
|
-
id: first.id,
|
|
53
|
-
time: DateTime.toEpochMillis(first.time.updated),
|
|
54
|
-
direction: "previous"
|
|
55
|
-
}
|
|
56
|
-
}) : void 0,
|
|
57
|
-
next: last ? SessionsCursor.make({
|
|
58
|
-
...query,
|
|
59
|
-
anchor: {
|
|
60
|
-
id: last.id,
|
|
61
|
-
time: DateTime.toEpochMillis(last.time.updated),
|
|
62
|
-
direction: "next"
|
|
63
|
-
}
|
|
64
|
-
}) : void 0
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
})).handle("session.stats", Effect.fn(function* (ctx) {
|
|
68
|
-
const timezone = ctx.query.timezone ?? "UTC";
|
|
69
|
-
yield* Effect.try({
|
|
70
|
-
try: () => new Intl.DateTimeFormat("en-US", { timeZone: timezone }),
|
|
71
|
-
catch: () => new InvalidRequestError({ message: `Invalid time zone: ${timezone}` })
|
|
72
|
-
});
|
|
73
|
-
return {
|
|
74
|
-
data: yield* SessionStats.get({
|
|
75
|
-
from: ctx.query.from,
|
|
76
|
-
to: ctx.query.to,
|
|
77
|
-
projectID: ctx.query.project,
|
|
78
|
-
timezone,
|
|
79
|
-
tools: ctx.query.tools
|
|
80
|
-
}).pipe(Effect.mapError(() => new InvalidRequestError({ message: "Stats range must end after it starts" })))
|
|
81
|
-
};
|
|
82
|
-
})).handle("session.create", Effect.fn(function* (ctx) {
|
|
83
|
-
return {
|
|
84
|
-
data: yield* session.create({
|
|
85
|
-
id: ctx.payload.id,
|
|
86
|
-
title: ctx.payload.title,
|
|
87
|
-
agent: ctx.payload.agent,
|
|
88
|
-
model: ctx.payload.model,
|
|
89
|
-
metadata: ctx.payload.metadata,
|
|
90
|
-
permissions: ctx.payload.permissions,
|
|
91
|
-
location: ctx.payload.location ?? { directory: AbsolutePath.make(process.cwd()) }
|
|
92
|
-
}).pipe(Effect.orDie)
|
|
93
|
-
};
|
|
94
|
-
})).handle("session.import", Effect.fn(function* (ctx) {
|
|
95
|
-
return {
|
|
96
|
-
data: yield* transfer.import({
|
|
97
|
-
data: { info: ctx.payload.info, messages: ctx.payload.messages },
|
|
98
|
-
location: ctx.payload.location ?? { directory: AbsolutePath.make(process.cwd()) }
|
|
99
|
-
}).pipe(Effect.catchTag("Session.NotFoundError", missingSession), Effect.catchTag("SessionTransfer.ImportConflictError", (error) => new ConflictError({
|
|
100
|
-
message: `Session already exists: ${error.sessionID}`,
|
|
101
|
-
resource: error.sessionID
|
|
102
|
-
})))
|
|
103
|
-
};
|
|
104
|
-
})).handle("session.export", Effect.fn(function* (ctx) {
|
|
105
|
-
return {
|
|
106
|
-
data: yield* transfer.export({ sessionID: ctx.params.sessionID, sanitize: ctx.query.sanitize }).pipe(Effect.catchTag("Session.NotFoundError", missingSession), Effect.catchTag("Session.MessageDecodeError", failedMessageDecode))
|
|
107
|
-
};
|
|
108
|
-
})).handle("session.active", Effect.fn(function* () {
|
|
109
|
-
const active = yield* session.active;
|
|
110
|
-
return {
|
|
111
|
-
data: Object.fromEntries(Array.from(active, (sessionID) => [sessionID, { type: "running" }]))
|
|
112
|
-
};
|
|
113
|
-
})).handle("session.get", Effect.fn(function* (ctx) {
|
|
114
|
-
return {
|
|
115
|
-
data: yield* session.get(ctx.params.sessionID).pipe(Effect.catchTag("Session.NotFoundError", missingSession))
|
|
116
|
-
};
|
|
117
|
-
})).handle("session.view", Effect.fn(function* (ctx) {
|
|
118
|
-
yield* session.view({ sessionID: ctx.params.sessionID, idle: DateTime.toEpochMillis(ctx.payload.idle) }).pipe(Effect.catchTag("Session.NotFoundError", missingSession));
|
|
119
|
-
return HttpApiSchema.NoContent.make();
|
|
120
|
-
})).handle("session.remove", Effect.fn(function* (ctx) {
|
|
121
|
-
yield* session.remove(ctx.params.sessionID).pipe(Effect.catchTag("Session.NotFoundError", missingSession));
|
|
122
|
-
return HttpApiSchema.NoContent.make();
|
|
123
|
-
})).handle("session.environment", Effect.fn(function* (ctx) {
|
|
124
|
-
yield* session.environment({ sessionID: ctx.params.sessionID, variables: ctx.payload.variables }).pipe(Effect.catchTag("Session.NotFoundError", missingSession));
|
|
125
|
-
return HttpApiSchema.NoContent.make();
|
|
126
|
-
})).handle("session.fork", Effect.fn(function* (ctx) {
|
|
127
|
-
return {
|
|
128
|
-
data: yield* session.fork({ sessionID: ctx.params.sessionID, before: ctx.payload.before }).pipe(Effect.catchTag("Session.NotFoundError", missingSession), Effect.catchTag("Session.MessageNotFoundError", missingMessage), Effect.catchTag("Session.ForkEmptyError", (error) => new InvalidRequestError({ message: error.message, kind: "empty_session" })))
|
|
129
|
-
};
|
|
130
|
-
})).handle("session.switchAgent", Effect.fn(function* (ctx) {
|
|
131
|
-
yield* session.switchAgent({ sessionID: ctx.params.sessionID, agent: ctx.payload.agent }).pipe(Effect.catchTag("Session.NotFoundError", missingSession));
|
|
132
|
-
return HttpApiSchema.NoContent.make();
|
|
133
|
-
})).handle("session.switchModel", Effect.fn(function* (ctx) {
|
|
134
|
-
yield* session.switchModel({ sessionID: ctx.params.sessionID, model: ctx.payload.model }).pipe(Effect.catchTag("Session.NotFoundError", missingSession));
|
|
135
|
-
return HttpApiSchema.NoContent.make();
|
|
136
|
-
})).handle("session.update", Effect.fn(function* (ctx) {
|
|
137
|
-
yield* session.get(ctx.params.sessionID).pipe(Effect.catchTag("Session.NotFoundError", missingSession));
|
|
138
|
-
if (ctx.payload.title !== void 0)
|
|
139
|
-
if (ctx.payload.title)
|
|
140
|
-
yield* session.rename({ sessionID: ctx.params.sessionID, title: ctx.payload.title }).pipe(Effect.catchTag("Session.NotFoundError", missingSession));
|
|
141
|
-
else
|
|
142
|
-
yield* (yield* SessionTitle.Service).generate(ctx.params.sessionID);
|
|
143
|
-
if (ctx.payload.permissions !== void 0)
|
|
144
|
-
yield* session.setPermissions({ sessionID: ctx.params.sessionID, permissions: ctx.payload.permissions }).pipe(Effect.catchTag("Session.NotFoundError", missingSession));
|
|
145
|
-
return HttpApiSchema.NoContent.make();
|
|
146
|
-
})).handle("session.move", Effect.fn(function* (ctx) {
|
|
147
|
-
yield* session.move({
|
|
148
|
-
sessionID: ctx.params.sessionID,
|
|
149
|
-
directory: ctx.payload.directory,
|
|
150
|
-
delivery: ctx.payload.delivery
|
|
151
|
-
}).pipe(Effect.catchTag("Session.NotFoundError", missingSession), Effect.catchTag("Session.DestinationNotFoundError", (error) => Effect.fail(new InvalidRequestError({ message: `Directory does not exist: ${error.directory}` }))), Effect.catchTag("Session.DestinationNotDirectoryError", (error) => Effect.fail(new InvalidRequestError({ message: `Not a directory: ${error.directory}` }))), Effect.catchTag("Session.DestinationUnavailableError", (error) => Effect.fail(new InvalidRequestError({ message: `Directory is unavailable: ${error.directory}` }))));
|
|
152
|
-
return HttpApiSchema.NoContent.make();
|
|
153
|
-
})).handle("session.prompt", Effect.fn(function* (ctx) {
|
|
154
|
-
return {
|
|
155
|
-
data: yield* session.prompt({
|
|
156
|
-
sessionID: ctx.params.sessionID,
|
|
157
|
-
id: ctx.payload.id,
|
|
158
|
-
text: ctx.payload.text,
|
|
159
|
-
files: ctx.payload.files,
|
|
160
|
-
agents: ctx.payload.agents,
|
|
161
|
-
skills: ctx.payload.skills,
|
|
162
|
-
metadata: ctx.payload.metadata,
|
|
163
|
-
delivery: ctx.payload.delivery,
|
|
164
|
-
resume: ctx.payload.resume
|
|
165
|
-
}).pipe(Effect.catchTag("Session.NotFoundError", missingSession), Effect.catchTag("Session.PromptConflictError", (error) => Effect.fail(new ConflictError({
|
|
166
|
-
message: `Prompt message ID conflicts with an existing durable record: ${error.messageID}`,
|
|
167
|
-
resource: error.messageID
|
|
168
|
-
}))), Effect.catchTag("Session.AttachmentError", (error) => Effect.fail(new InvalidRequestError({ message: error.message, field: "files" }))), Effect.catchTag("Session.SkillNotFoundError", (error) => Effect.fail(new InvalidRequestError({ message: `Skill not found: ${error.skill}`, field: "skills" }))))
|
|
169
|
-
};
|
|
170
|
-
})).handle("session.command", Effect.fn(function* (ctx) {
|
|
171
|
-
yield* session.command({
|
|
172
|
-
sessionID: ctx.params.sessionID,
|
|
173
|
-
command: ctx.payload.name,
|
|
174
|
-
text: ctx.payload.text,
|
|
175
|
-
files: ctx.payload.files,
|
|
176
|
-
agents: ctx.payload.agents,
|
|
177
|
-
skills: ctx.payload.skills,
|
|
178
|
-
delivery: ctx.payload.delivery
|
|
179
|
-
}).pipe(Effect.catchTag("Session.NotFoundError", missingSession), Effect.catchTag("Command.NotFoundError", (error) => Effect.fail(new CommandNotFoundError({
|
|
180
|
-
command: error.command,
|
|
181
|
-
message: error.message
|
|
182
|
-
}))), Effect.catchTag("Command.ExecutionError", (error) => Effect.fail(new CommandExecutionError({
|
|
183
|
-
command: error.command,
|
|
184
|
-
message: error.message
|
|
185
|
-
}))));
|
|
186
|
-
return HttpApiSchema.NoContent.make();
|
|
187
|
-
})).handle("session.skill", Effect.fn(function* (ctx) {
|
|
188
|
-
yield* session.skill({
|
|
189
|
-
sessionID: ctx.params.sessionID,
|
|
190
|
-
skill: ctx.payload.id,
|
|
191
|
-
resume: ctx.payload.resume
|
|
192
|
-
}).pipe(Effect.catchTag("Session.NotFoundError", missingSession), Effect.catchTag("Session.SkillNotFoundError", (error) => Effect.fail(new SkillNotFoundError({ skill: error.skill, message: `Skill not found: ${error.skill}` }))));
|
|
193
|
-
return HttpApiSchema.NoContent.make();
|
|
194
|
-
})).handle("session.synthetic", Effect.fn(function* (ctx) {
|
|
195
|
-
return { data: yield* session.synthetic({
|
|
196
|
-
id: ctx.payload.id,
|
|
197
|
-
sessionID: ctx.params.sessionID,
|
|
198
|
-
text: ctx.payload.text,
|
|
199
|
-
description: ctx.payload.description,
|
|
200
|
-
metadata: ctx.payload.metadata,
|
|
201
|
-
delivery: ctx.payload.delivery,
|
|
202
|
-
resume: ctx.payload.resume
|
|
203
|
-
}).pipe(Effect.catchTag("Session.NotFoundError", missingSession), Effect.catchTag("Session.SyntheticConflictError", (error) => Effect.fail(new ConflictError({
|
|
204
|
-
message: `Synthetic input ID conflicts with an existing durable record: ${error.inputID}`,
|
|
205
|
-
resource: error.inputID
|
|
206
|
-
})))) };
|
|
207
|
-
})).handle("session.shell", Effect.fn(function* (ctx) {
|
|
208
|
-
yield* session.shell({ sessionID: ctx.params.sessionID, id: ctx.payload.id, command: ctx.payload.command }).pipe(Effect.catchTag("Session.NotFoundError", missingSession));
|
|
209
|
-
return HttpApiSchema.NoContent.make();
|
|
210
|
-
})).handle("session.compact", Effect.fn(function* (ctx) {
|
|
211
|
-
return {
|
|
212
|
-
data: yield* session.compact({ sessionID: ctx.params.sessionID, id: ctx.payload.id, delivery: ctx.payload.delivery }).pipe(Effect.catchTag("Session.NotFoundError", missingSession), Effect.catchTag("Session.CompactionConflictError", (error) => Effect.fail(new ConflictError({
|
|
213
|
-
message: `Compaction input ID conflicts with an existing durable record: ${error.inputID}`,
|
|
214
|
-
resource: error.inputID
|
|
215
|
-
}))))
|
|
216
|
-
};
|
|
217
|
-
})).handle("session.wait", Effect.fn(function* (ctx) {
|
|
218
|
-
yield* session.wait(ctx.params.sessionID).pipe(Effect.catchTag("Session.NotFoundError", missingSession));
|
|
219
|
-
return HttpApiSchema.NoContent.make();
|
|
220
|
-
})).handle("session.revert.stage", Effect.fn(function* (ctx) {
|
|
221
|
-
yield* Effect.log("session.revert.stage", {
|
|
222
|
-
sessionID: ctx.params.sessionID,
|
|
223
|
-
messageID: ctx.payload.messageID,
|
|
224
|
-
files: ctx.payload.files
|
|
225
|
-
});
|
|
226
|
-
return {
|
|
227
|
-
data: yield* session.revert.stage({ ...ctx.params, ...ctx.payload }).pipe(Effect.catchTag("Session.NotFoundError", missingSession), Effect.catchTag("Session.MessageNotFoundError", missingMessage), Effect.catchTag("Session.BusyError", busySession), Effect.catchTag("Snapshot.Error", failedSnapshot("stage session revert", ctx.params.sessionID)))
|
|
228
|
-
};
|
|
229
|
-
})).handle("session.revert.clear", Effect.fn(function* (ctx) {
|
|
230
|
-
yield* Effect.log("session.revert.clear", { sessionID: ctx.params.sessionID });
|
|
231
|
-
yield* session.revert.clear(ctx.params.sessionID).pipe(Effect.catchTag("Session.NotFoundError", missingSession), Effect.catchTag("Session.BusyError", busySession), Effect.catchTag("Snapshot.Error", failedSnapshot("clear session revert", ctx.params.sessionID)));
|
|
232
|
-
return HttpApiSchema.NoContent.make();
|
|
233
|
-
})).handle("session.revert.commit", Effect.fn(function* (ctx) {
|
|
234
|
-
yield* Effect.log("session.revert.commit", { sessionID: ctx.params.sessionID });
|
|
235
|
-
yield* session.revert.commit(ctx.params.sessionID).pipe(Effect.catchTag("Session.NotFoundError", missingSession), Effect.catchTag("Session.BusyError", busySession));
|
|
236
|
-
return HttpApiSchema.NoContent.make();
|
|
237
|
-
})).handle("session.context", Effect.fn(function* (ctx) {
|
|
238
|
-
return {
|
|
239
|
-
data: yield* session.context(ctx.params.sessionID).pipe(Effect.catchTag("Session.NotFoundError", missingSession), Effect.catchTag("Session.MessageDecodeError", failedMessageDecode))
|
|
240
|
-
};
|
|
241
|
-
})).handle("session.diff", Effect.fn(function* (ctx) {
|
|
242
|
-
return {
|
|
243
|
-
data: yield* session.diff({ sessionID: ctx.params.sessionID, ...ctx.query }).pipe(Effect.catchTag("Session.NotFoundError", missingSession), Effect.catchTag("Session.MessageNotFoundError", missingMessage), Effect.catchTag("Session.TurnRangeError", (error) => new InvalidRequestError({ message: error.message, field: error.field })), Effect.catchTag("Snapshot.Error", failedSnapshot("diff session turn", ctx.params.sessionID)))
|
|
244
|
-
};
|
|
245
|
-
})).handle("session.inbox.list", Effect.fn(function* (ctx) {
|
|
246
|
-
return {
|
|
247
|
-
data: yield* session.inbox(ctx.params.sessionID).pipe(Effect.catchTag("Session.NotFoundError", missingSession))
|
|
248
|
-
};
|
|
249
|
-
})).handle("session.inbox.cancel", Effect.fn(function* (ctx) {
|
|
250
|
-
yield* session.cancelInbox({ sessionID: ctx.params.sessionID, inboxID: ctx.params.inboxID }).pipe(Effect.catchTag("Session.NotFoundError", missingSession), Effect.catchTag("Session.InboxConflictError", () => Effect.void));
|
|
251
|
-
return HttpApiSchema.NoContent.make();
|
|
252
|
-
})).handle("session.inbox.update", Effect.fn(function* (ctx) {
|
|
253
|
-
return yield* pendingMutation(ctx.payload.delivery === "steer" ? session.steerInbox({ sessionID: ctx.params.sessionID, inboxID: ctx.params.inboxID }) : session.queueInbox({ sessionID: ctx.params.sessionID, inboxID: ctx.params.inboxID }), `Pending input cannot change to ${ctx.payload.delivery}`);
|
|
254
|
-
})).handle("session.instructions.entry.list", Effect.fn(function* (ctx) {
|
|
255
|
-
return { data: yield* (yield* InstructionEntry.Service).list(ctx.params.sessionID) };
|
|
256
|
-
})).handle("session.instructions.entry.put", Effect.fn(function* (ctx) {
|
|
257
|
-
yield* (yield* InstructionEntry.Service).put({ sessionID: ctx.params.sessionID, key: ctx.params.key, value: ctx.payload.value });
|
|
258
|
-
return HttpApiSchema.NoContent.make();
|
|
259
|
-
})).handle("session.instructions.entry.remove", Effect.fn(function* (ctx) {
|
|
260
|
-
yield* (yield* InstructionEntry.Service).remove({ sessionID: ctx.params.sessionID, key: ctx.params.key });
|
|
261
|
-
return HttpApiSchema.NoContent.make();
|
|
262
|
-
})).handle("session.generate", Effect.fn(function* (ctx) {
|
|
263
|
-
return { data: { text: yield* session.generate({ sessionID: ctx.params.sessionID, prompt: ctx.payload.prompt }).pipe(Effect.mapError((error) => error._tag === "Session.NotFoundError" ? missingSession(error) : new ServiceUnavailableError({ message: error.message, service: "session generation" }))) } };
|
|
264
|
-
})).handle("session.log", Effect.fn(function* (ctx) {
|
|
265
|
-
yield* session.get(ctx.params.sessionID).pipe(Effect.catchTag("Session.NotFoundError", missingSession));
|
|
266
|
-
return session.log({ sessionID: ctx.params.sessionID, after: ctx.query.after, follow: ctx.query.follow }).pipe(Stream.orDie);
|
|
267
|
-
})).handle("session.interrupt", Effect.fn(function* (ctx) {
|
|
268
|
-
return { interrupted: yield* session.interrupt(ctx.params.sessionID, { resume: ctx.query.resume }) };
|
|
269
|
-
})).handle("session.background", Effect.fn(function* (ctx) {
|
|
270
|
-
yield* session.background(ctx.params.sessionID).pipe(Effect.catchTag("Session.NotFoundError", missingSession));
|
|
271
|
-
return HttpApiSchema.NoContent.make();
|
|
272
|
-
})).handle("session.message", Effect.fn(function* (ctx) {
|
|
273
|
-
yield* session.get(ctx.params.sessionID).pipe(Effect.catchTag("Session.NotFoundError", missingSession));
|
|
274
|
-
const message = yield* session.message(ctx.params);
|
|
275
|
-
if (message)
|
|
276
|
-
return { data: message };
|
|
277
|
-
return yield* new MessageNotFoundError({
|
|
278
|
-
sessionID: ctx.params.sessionID,
|
|
279
|
-
messageID: ctx.params.messageID,
|
|
280
|
-
message: `Message not found: ${ctx.params.messageID}`
|
|
281
|
-
});
|
|
282
|
-
})).handle("session.form.list", Effect.fn(function* (ctx) {
|
|
283
|
-
return { data: yield* (yield* Form.Service).list({ sessionID: ctx.params.sessionID }) };
|
|
284
|
-
})).handle("session.form.create", Effect.fn(function* (ctx) {
|
|
285
|
-
return { data: yield* (yield* Form.Service).create({
|
|
286
|
-
id: ctx.payload.id,
|
|
287
|
-
sessionID: ctx.params.sessionID,
|
|
288
|
-
title: ctx.payload.title,
|
|
289
|
-
metadata: ctx.payload.metadata,
|
|
290
|
-
fields: ctx.payload.fields
|
|
291
|
-
}).pipe(Effect.catchTags({
|
|
292
|
-
"Form.AlreadyExistsError": (error) => new ConflictError({ resource: error.id, message: error.message }),
|
|
293
|
-
"Form.InvalidFormError": (error) => new InvalidRequestError({ message: error.message, field: "fields" })
|
|
294
|
-
})) };
|
|
295
|
-
})).handle("session.form.get", Effect.fn(function* (ctx) {
|
|
296
|
-
const owned = yield* requireOwnedForm(ctx.params.sessionID, ctx.params.formID), state = yield* owned.form.state(ctx.params.formID).pipe(Effect.catchTag("Form.NotFoundError", () => missingForm(ctx.params.formID)));
|
|
297
|
-
return { data: { ...owned.info, state } };
|
|
298
|
-
})).handle("session.form.reply", Effect.fn(function* (ctx) {
|
|
299
|
-
yield* (yield* requireOwnedForm(ctx.params.sessionID, ctx.params.formID)).form.reply({ id: ctx.params.formID, answer: ctx.payload.answer }).pipe(Effect.catchTags({
|
|
300
|
-
"Form.AlreadySettledError": (error) => new FormAlreadySettledError({ id: error.id, message: error.message }),
|
|
301
|
-
"Form.InvalidAnswerError": (error) => new FormInvalidAnswerError({ id: error.id, message: error.message }),
|
|
302
|
-
"Form.NotFoundError": () => missingForm(ctx.params.formID)
|
|
303
|
-
}));
|
|
304
|
-
return HttpApiSchema.NoContent.make();
|
|
305
|
-
})).handle("session.form.cancel", Effect.fn(function* (ctx) {
|
|
306
|
-
yield* (yield* requireOwnedForm(ctx.params.sessionID, ctx.params.formID)).form.cancel(ctx.params.formID).pipe(Effect.catchTags({
|
|
307
|
-
"Form.AlreadySettledError": (error) => new FormAlreadySettledError({ id: error.id, message: error.message }),
|
|
308
|
-
"Form.NotFoundError": () => missingForm(ctx.params.formID)
|
|
309
|
-
}));
|
|
310
|
-
return HttpApiSchema.NoContent.make();
|
|
311
|
-
}));
|
|
312
|
-
}));
|
|
2
|
+
SessionHandler2
|
|
3
|
+
} from "../chunks/auth-r4dhhtgz.js";
|
|
4
|
+
import"../chunks/auth-z6kg9h7e.js";
|
|
5
|
+
import"../chunks/auth-23w8t84j.js";
|
|
6
|
+
import"../chunks/auth-frv6gfy7.js";
|
|
7
|
+
import"../chunks/auth-0ar9gf7q.js";
|
|
8
|
+
import"../chunks/auth-smaf4a18.js";
|
|
9
|
+
export {
|
|
10
|
+
SessionHandler2 as SessionHandler
|
|
11
|
+
};
|
package/dist/handlers/shell.js
CHANGED
|
@@ -1,25 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
})).handle("shell.create", Effect.fn(function* (ctx) {
|
|
13
|
-
const shell = yield* Shell.Service, location = yield* Location.Service;
|
|
14
|
-
return yield* response(shell.create({ ...ctx.payload, cwd: ctx.payload.cwd || location.directory }).pipe(Effect.orDie));
|
|
15
|
-
})).handle("shell.get", Effect.fn(function* (ctx) {
|
|
16
|
-
const shell = yield* Shell.Service;
|
|
17
|
-
return yield* response(shell.get(ctx.params.id).pipe(Effect.catchTag("Shell.NotFoundError", () => new ShellNotFoundError({ id: ctx.params.id, message: `Shell command not found: ${ctx.params.id}` }))));
|
|
18
|
-
})).handle("shell.output", Effect.fn(function* (ctx) {
|
|
19
|
-
const shell = yield* Shell.Service;
|
|
20
|
-
return yield* response(shell.output(ctx.params.id, { cursor: ctx.query.cursor, limit: ctx.query.limit }).pipe(Effect.catchTag("Shell.NotFoundError", () => new ShellNotFoundError({ id: ctx.params.id, message: `Shell command not found: ${ctx.params.id}` }))));
|
|
21
|
-
})).handle("shell.remove", Effect.fn(function* (ctx) {
|
|
22
|
-
yield* (yield* Shell.Service).remove(ctx.params.id).pipe(Effect.catchTag("Shell.NotFoundError", () => Effect.void));
|
|
23
|
-
return HttpApiSchema.NoContent.make();
|
|
24
|
-
}));
|
|
25
|
-
}));
|
|
1
|
+
import {
|
|
2
|
+
ShellHandler2
|
|
3
|
+
} from "../chunks/auth-z3nth2hg.js";
|
|
4
|
+
import"../chunks/auth-z6kg9h7e.js";
|
|
5
|
+
import"../chunks/auth-23w8t84j.js";
|
|
6
|
+
import"../chunks/auth-frv6gfy7.js";
|
|
7
|
+
import"../chunks/auth-0ar9gf7q.js";
|
|
8
|
+
import"../chunks/auth-smaf4a18.js";
|
|
9
|
+
export {
|
|
10
|
+
ShellHandler2 as ShellHandler
|
|
11
|
+
};
|