@opengeni/api-router 0.15.5 → 0.15.6
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/app.js +1 -1
- package/dist/{chunk-ICRZC3JH.js → chunk-MN7BW3UV.js} +21 -58
- package/dist/{chunk-ICRZC3JH.js.map → chunk-MN7BW3UV.js.map} +1 -1
- package/dist/index.js +1 -1
- package/dist/sandbox/channel-a.d.ts +2 -0
- package/package.json +4 -4
- package/src/routes/sessions.ts +16 -35
- package/src/sandbox/channel-a.ts +7 -2
package/dist/app.js
CHANGED
|
@@ -16092,6 +16092,7 @@ import {
|
|
|
16092
16092
|
releaseLeaseHolder as releaseLeaseHolder2
|
|
16093
16093
|
} from "@opengeni/db";
|
|
16094
16094
|
import { appendAndPublishEvents as appendAndPublishEvents4 } from "@opengeni/events";
|
|
16095
|
+
import { sandboxOperationMetricObserver } from "@opengeni/observability";
|
|
16095
16096
|
import { HTTPException as HTTPException22 } from "hono/http-exception";
|
|
16096
16097
|
import {
|
|
16097
16098
|
buildSelfhostedBackendSession,
|
|
@@ -16111,6 +16112,7 @@ import {
|
|
|
16111
16112
|
import { relayConfigFromSettings as relayConfigFromSettings3, wrapChannelABoxWithRouting } from "@opengeni/core";
|
|
16112
16113
|
async function withChannelA(services, ctx, fn) {
|
|
16113
16114
|
const { db, settings, bus } = services;
|
|
16115
|
+
const onSandboxOperation = services.observability ? sandboxOperationMetricObserver(services.observability) : void 0;
|
|
16114
16116
|
const { accountId, workspaceId, session } = ctx;
|
|
16115
16117
|
if (session.sandboxBackend === "none") {
|
|
16116
16118
|
throw new HTTPException22(409, { message: "sandbox not available" });
|
|
@@ -16194,7 +16196,7 @@ async function withChannelA(services, ctx, fn) {
|
|
|
16194
16196
|
backendId: "selfhosted"
|
|
16195
16197
|
};
|
|
16196
16198
|
const routed = wrapChannelABoxWithRouting(
|
|
16197
|
-
{ db, settings, bus },
|
|
16199
|
+
{ db, settings, bus, ...onSandboxOperation ? { onSandboxOperation } : {} },
|
|
16198
16200
|
{
|
|
16199
16201
|
accountId,
|
|
16200
16202
|
workspaceId,
|
|
@@ -16317,7 +16319,7 @@ async function withChannelA(services, ctx, fn) {
|
|
|
16317
16319
|
}
|
|
16318
16320
|
}
|
|
16319
16321
|
const routed = wrapChannelABoxWithRouting(
|
|
16320
|
-
{ db, settings, bus },
|
|
16322
|
+
{ db, settings, bus, ...onSandboxOperation ? { onSandboxOperation } : {} },
|
|
16321
16323
|
{
|
|
16322
16324
|
accountId,
|
|
16323
16325
|
workspaceId,
|
|
@@ -17089,6 +17091,7 @@ async function serveWorkspaceCaptureFile(row, path, storage) {
|
|
|
17089
17091
|
// src/routes/sessions.ts
|
|
17090
17092
|
function registerSessionRoutes(app, deps) {
|
|
17091
17093
|
const { settings, db, bus, workflowClient, objectStorage } = deps;
|
|
17094
|
+
const channelAServices = { db, settings, bus, observability: deps.observability };
|
|
17092
17095
|
const workspaceCaptureManifestCache = new WorkspaceCaptureManifestCache();
|
|
17093
17096
|
const ptyIdentity = (pty) => ({
|
|
17094
17097
|
leaseId: pty.leaseId,
|
|
@@ -18599,101 +18602,61 @@ function registerSessionRoutes(app, deps) {
|
|
|
18599
18602
|
app.post("/v1/workspaces/:workspaceId/sessions/:sessionId/fs/list", async (c) => {
|
|
18600
18603
|
const ctx = await channelAPreamble(c, "files:read");
|
|
18601
18604
|
const req = await parseChannelABody(c, FsListRequest);
|
|
18602
|
-
const out = await withChannelA(
|
|
18603
|
-
{ db, settings, bus },
|
|
18604
|
-
ctx,
|
|
18605
|
-
({ service }) => service.fsList(req)
|
|
18606
|
-
);
|
|
18605
|
+
const out = await withChannelA(channelAServices, ctx, ({ service }) => service.fsList(req));
|
|
18607
18606
|
return c.json(out);
|
|
18608
18607
|
});
|
|
18609
18608
|
app.post("/v1/workspaces/:workspaceId/sessions/:sessionId/fs/read", async (c) => {
|
|
18610
18609
|
const ctx = await channelAPreamble(c, "files:read");
|
|
18611
18610
|
const req = await parseChannelABody(c, FsReadRequest);
|
|
18612
|
-
const out = await withChannelA(
|
|
18613
|
-
{ db, settings, bus },
|
|
18614
|
-
ctx,
|
|
18615
|
-
({ service }) => service.fsRead(req)
|
|
18616
|
-
);
|
|
18611
|
+
const out = await withChannelA(channelAServices, ctx, ({ service }) => service.fsRead(req));
|
|
18617
18612
|
return c.json(out);
|
|
18618
18613
|
});
|
|
18619
18614
|
app.post("/v1/workspaces/:workspaceId/sessions/:sessionId/fs/write", async (c) => {
|
|
18620
18615
|
const ctx = await channelAPreamble(c, "files:write");
|
|
18621
18616
|
const req = await parseChannelABody(c, FsWriteRequest);
|
|
18622
|
-
const out = await withChannelA(
|
|
18623
|
-
{ db, settings, bus },
|
|
18624
|
-
ctx,
|
|
18625
|
-
({ service }) => service.fsWrite(req)
|
|
18626
|
-
);
|
|
18617
|
+
const out = await withChannelA(channelAServices, ctx, ({ service }) => service.fsWrite(req));
|
|
18627
18618
|
return c.json(out);
|
|
18628
18619
|
});
|
|
18629
18620
|
app.post("/v1/workspaces/:workspaceId/sessions/:sessionId/fs/delete", async (c) => {
|
|
18630
18621
|
const ctx = await channelAPreamble(c, "files:write");
|
|
18631
18622
|
const req = await parseChannelABody(c, FsDeleteRequest);
|
|
18632
|
-
const out = await withChannelA(
|
|
18633
|
-
{ db, settings, bus },
|
|
18634
|
-
ctx,
|
|
18635
|
-
({ service }) => service.fsDelete(req)
|
|
18636
|
-
);
|
|
18623
|
+
const out = await withChannelA(channelAServices, ctx, ({ service }) => service.fsDelete(req));
|
|
18637
18624
|
return c.json(out);
|
|
18638
18625
|
});
|
|
18639
18626
|
app.post("/v1/workspaces/:workspaceId/sessions/:sessionId/fs/move", async (c) => {
|
|
18640
18627
|
const ctx = await channelAPreamble(c, "files:write");
|
|
18641
18628
|
const req = await parseChannelABody(c, FsMoveRequest);
|
|
18642
|
-
const out = await withChannelA(
|
|
18643
|
-
{ db, settings, bus },
|
|
18644
|
-
ctx,
|
|
18645
|
-
({ service }) => service.fsMove(req)
|
|
18646
|
-
);
|
|
18629
|
+
const out = await withChannelA(channelAServices, ctx, ({ service }) => service.fsMove(req));
|
|
18647
18630
|
return c.json(out);
|
|
18648
18631
|
});
|
|
18649
18632
|
app.post("/v1/workspaces/:workspaceId/sessions/:sessionId/fs/mkdir", async (c) => {
|
|
18650
18633
|
const ctx = await channelAPreamble(c, "files:write");
|
|
18651
18634
|
const req = await parseChannelABody(c, FsMkdirRequest);
|
|
18652
|
-
const out = await withChannelA(
|
|
18653
|
-
{ db, settings, bus },
|
|
18654
|
-
ctx,
|
|
18655
|
-
({ service }) => service.fsMkdir(req)
|
|
18656
|
-
);
|
|
18635
|
+
const out = await withChannelA(channelAServices, ctx, ({ service }) => service.fsMkdir(req));
|
|
18657
18636
|
return c.json(out);
|
|
18658
18637
|
});
|
|
18659
18638
|
app.post("/v1/workspaces/:workspaceId/sessions/:sessionId/git/status", async (c) => {
|
|
18660
18639
|
const ctx = await channelAPreamble(c, "files:read");
|
|
18661
18640
|
const req = await parseChannelABody(c, GitStatusRequest);
|
|
18662
|
-
const out = await withChannelA(
|
|
18663
|
-
{ db, settings, bus },
|
|
18664
|
-
ctx,
|
|
18665
|
-
({ service }) => service.gitStatus(req)
|
|
18666
|
-
);
|
|
18641
|
+
const out = await withChannelA(channelAServices, ctx, ({ service }) => service.gitStatus(req));
|
|
18667
18642
|
return c.json(out);
|
|
18668
18643
|
});
|
|
18669
18644
|
app.post("/v1/workspaces/:workspaceId/sessions/:sessionId/git/diff", async (c) => {
|
|
18670
18645
|
const ctx = await channelAPreamble(c, "files:read");
|
|
18671
18646
|
const req = await parseChannelABody(c, GitDiffRequest);
|
|
18672
|
-
const out = await withChannelA(
|
|
18673
|
-
{ db, settings, bus },
|
|
18674
|
-
ctx,
|
|
18675
|
-
({ service }) => service.gitDiff(req)
|
|
18676
|
-
);
|
|
18647
|
+
const out = await withChannelA(channelAServices, ctx, ({ service }) => service.gitDiff(req));
|
|
18677
18648
|
return c.json(out);
|
|
18678
18649
|
});
|
|
18679
18650
|
app.post("/v1/workspaces/:workspaceId/sessions/:sessionId/git/log", async (c) => {
|
|
18680
18651
|
const ctx = await channelAPreamble(c, "files:read");
|
|
18681
18652
|
const req = await parseChannelABody(c, GitLogRequest);
|
|
18682
|
-
const out = await withChannelA(
|
|
18683
|
-
{ db, settings, bus },
|
|
18684
|
-
ctx,
|
|
18685
|
-
({ service }) => service.gitLog(req)
|
|
18686
|
-
);
|
|
18653
|
+
const out = await withChannelA(channelAServices, ctx, ({ service }) => service.gitLog(req));
|
|
18687
18654
|
return c.json(out);
|
|
18688
18655
|
});
|
|
18689
18656
|
app.post("/v1/workspaces/:workspaceId/sessions/:sessionId/git/show", async (c) => {
|
|
18690
18657
|
const ctx = await channelAPreamble(c, "files:read");
|
|
18691
18658
|
const req = await parseChannelABody(c, GitShowRequest);
|
|
18692
|
-
const out = await withChannelA(
|
|
18693
|
-
{ db, settings, bus },
|
|
18694
|
-
ctx,
|
|
18695
|
-
({ service }) => service.gitShow(req)
|
|
18696
|
-
);
|
|
18659
|
+
const out = await withChannelA(channelAServices, ctx, ({ service }) => service.gitShow(req));
|
|
18697
18660
|
return c.json(out);
|
|
18698
18661
|
});
|
|
18699
18662
|
app.get("/v1/workspaces/:workspaceId/sessions/:sessionId/workspace/capture", async (c) => {
|
|
@@ -18747,7 +18710,7 @@ function registerSessionRoutes(app, deps) {
|
|
|
18747
18710
|
const ctx = await channelAPreamble(c, "terminal:attach");
|
|
18748
18711
|
const req = await parseChannelABody(c, TerminalExecRequest);
|
|
18749
18712
|
const out = await withChannelA(
|
|
18750
|
-
|
|
18713
|
+
channelAServices,
|
|
18751
18714
|
ctx,
|
|
18752
18715
|
({ service }) => service.terminalExec(req)
|
|
18753
18716
|
);
|
|
@@ -18762,7 +18725,7 @@ function registerSessionRoutes(app, deps) {
|
|
|
18762
18725
|
});
|
|
18763
18726
|
}
|
|
18764
18727
|
const ptyId = crypto.randomUUID();
|
|
18765
|
-
const out = await withChannelA(
|
|
18728
|
+
const out = await withChannelA(channelAServices, ctx, async (handle) => {
|
|
18766
18729
|
if (!handle.lease) {
|
|
18767
18730
|
throw new HTTPException24(409, {
|
|
18768
18731
|
message: "durable interactive terminals require a session-home provider lease"
|
|
@@ -18853,7 +18816,7 @@ function registerSessionRoutes(app, deps) {
|
|
|
18853
18816
|
throw new HTTPException24(404, { message: "pty not found or closed" });
|
|
18854
18817
|
}
|
|
18855
18818
|
let seq = 1;
|
|
18856
|
-
await withChannelA(
|
|
18819
|
+
await withChannelA(channelAServices, ctx, async (handle) => {
|
|
18857
18820
|
await adoptPtyProcess(ctx, handle, pty);
|
|
18858
18821
|
let output;
|
|
18859
18822
|
try {
|
|
@@ -18915,7 +18878,7 @@ function registerSessionRoutes(app, deps) {
|
|
|
18915
18878
|
if (!pty) {
|
|
18916
18879
|
throw new HTTPException24(404, { message: "pty not found or closed" });
|
|
18917
18880
|
}
|
|
18918
|
-
await withChannelA(
|
|
18881
|
+
await withChannelA(channelAServices, ctx, async (handle) => {
|
|
18919
18882
|
await adoptPtyProcess(ctx, handle, pty);
|
|
18920
18883
|
await handle.service.ptyResize(req, pty.execSessionId);
|
|
18921
18884
|
const updated = await updatePtySessionActivity(db, {
|
|
@@ -18944,7 +18907,7 @@ function registerSessionRoutes(app, deps) {
|
|
|
18944
18907
|
ptyId: req.ptyId
|
|
18945
18908
|
});
|
|
18946
18909
|
if (pty) {
|
|
18947
|
-
await withChannelA(
|
|
18910
|
+
await withChannelA(channelAServices, ctx, async (handle) => {
|
|
18948
18911
|
await adoptPtyProcess(ctx, handle, pty);
|
|
18949
18912
|
await handle.service.ptyClose(req, pty.execSessionId);
|
|
18950
18913
|
const terminal = await getRetainedProcess(db, {
|
|
@@ -23455,4 +23418,4 @@ export {
|
|
|
23455
23418
|
withDefaultEnabledCapabilityMcpTools,
|
|
23456
23419
|
workflowIdForSession2 as workflowIdForSession
|
|
23457
23420
|
};
|
|
23458
|
-
//# sourceMappingURL=chunk-
|
|
23421
|
+
//# sourceMappingURL=chunk-MN7BW3UV.js.map
|