@opengeni/runtime 4.0.0 → 4.0.1-canary.35916963870001
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/assets/codemode-client.json +1 -1
- package/dist/{chunk-WIHICNWS.js → chunk-JFMOX5OE.js} +63 -11
- package/dist/chunk-JFMOX5OE.js.map +1 -0
- package/dist/{chunk-5HJEVOMJ.js → chunk-ROCWOHGM.js} +138 -30
- package/dist/chunk-ROCWOHGM.js.map +1 -0
- package/dist/index.d.ts +8 -1
- package/dist/index.js +6 -2
- package/dist/operational-instructions.d.ts +1 -1
- package/dist/sandbox/browser-control-client.d.ts +20 -0
- package/dist/sandbox/index.js +1 -1
- package/dist/sandbox/routing/routing-session.d.ts +2 -1
- package/dist/sandbox/turn-tool-cancellation.d.ts +1 -1
- package/dist/workspace-tool-gateway.js +2 -2
- package/package.json +11 -11
- package/src/bundled_default_skills/opengeni-help/SKILL.md +14 -0
- package/src/bundled_management_skills/opengeni-skills/SKILL.md +1 -1
- package/src/bundled_site_skills/opengeni-sites/SKILL.md +23 -2
- package/src/index.ts +97 -16
- package/src/interaction-tools.ts +72 -13
- package/src/operational-instructions.ts +5 -1
- package/src/sandbox/browser-control-client.ts +109 -23
- package/src/sandbox/routing/routing-session.ts +6 -1
- package/src/sandbox/turn-tool-cancellation.ts +12 -2
- package/dist/chunk-5HJEVOMJ.js.map +0 -1
- package/dist/chunk-WIHICNWS.js.map +0 -1
|
@@ -17696,7 +17696,7 @@ var RoutingSandboxSession = class {
|
|
|
17696
17696
|
/** Make a retained process session-owned before exposing its live locator.
|
|
17697
17697
|
* Provider yield alone is not adoption: short commands can still finish and
|
|
17698
17698
|
* return inline during the model-facing eager-wait window. */
|
|
17699
|
-
async adoptRetainedProcessAsBackgroundCommand(providerSessionId) {
|
|
17699
|
+
async adoptRetainedProcessAsBackgroundCommand(providerSessionId, command) {
|
|
17700
17700
|
const record = this.retainedProcess(providerSessionId);
|
|
17701
17701
|
if (!this.canAdoptRetainedProcessAsBackgroundCommand(providerSessionId)) {
|
|
17702
17702
|
throw new RoutingUnsupportedError("backgroundCommandAdoption", record.backend.kind);
|
|
@@ -17712,7 +17712,8 @@ var RoutingSandboxSession = class {
|
|
|
17712
17712
|
await this.captureRetainedOutput(record);
|
|
17713
17713
|
record.backgroundAdoption ??= this.deps.adoptProcessAsBackgroundCommand({
|
|
17714
17714
|
backend: record.backend,
|
|
17715
|
-
process: record.process
|
|
17715
|
+
process: record.process,
|
|
17716
|
+
command
|
|
17716
17717
|
});
|
|
17717
17718
|
try {
|
|
17718
17719
|
await record.backgroundAdoption;
|
|
@@ -19008,6 +19009,7 @@ var TurnToolCancellationControllerImpl = class {
|
|
|
19008
19009
|
if (retainedProcess && processSession) {
|
|
19009
19010
|
this.shellSessions.set(retainedProcess.providerSessionId, {
|
|
19010
19011
|
sessionId: retainedProcess.providerSessionId,
|
|
19012
|
+
command: parsed.cmd,
|
|
19011
19013
|
markerPath,
|
|
19012
19014
|
token,
|
|
19013
19015
|
interactive,
|
|
@@ -19037,6 +19039,7 @@ var TurnToolCancellationControllerImpl = class {
|
|
|
19037
19039
|
if (sessionId !== null) {
|
|
19038
19040
|
const state = {
|
|
19039
19041
|
sessionId,
|
|
19042
|
+
command: parsed.cmd,
|
|
19040
19043
|
markerPath: useRemoteOpCancellation ? null : markerPath,
|
|
19041
19044
|
token: useRemoteOpCancellation ? null : token,
|
|
19042
19045
|
interactive,
|
|
@@ -19213,7 +19216,10 @@ This process is turn-scoped; it will stop when this turn ends or is interrupted.
|
|
|
19213
19216
|
`;
|
|
19214
19217
|
}
|
|
19215
19218
|
if (state.processSession?.adoptRetainedProcessAsBackgroundCommand) {
|
|
19216
|
-
await state.processSession.adoptRetainedProcessAsBackgroundCommand(
|
|
19219
|
+
await state.processSession.adoptRetainedProcessAsBackgroundCommand(
|
|
19220
|
+
state.sessionId,
|
|
19221
|
+
state.command
|
|
19222
|
+
);
|
|
19217
19223
|
this.shellSessions.delete(state.sessionId);
|
|
19218
19224
|
}
|
|
19219
19225
|
return runningCommandBanner(
|
|
@@ -33043,6 +33049,7 @@ function shellQuote5(value) {
|
|
|
33043
33049
|
// src/sandbox/browser-control-client.ts
|
|
33044
33050
|
import { createHash as createHash7, randomUUID as randomUUID8 } from "crypto";
|
|
33045
33051
|
import { posix as posixPath2 } from "path";
|
|
33052
|
+
import { parseBrowserFrameMetadata } from "@opengeni/sdk";
|
|
33046
33053
|
import {
|
|
33047
33054
|
BROWSER_CONTROL_MAX_JSON_BYTES,
|
|
33048
33055
|
BROWSER_CONTROL_PORT as BROWSER_CONTROL_PORT2,
|
|
@@ -33530,7 +33537,10 @@ var BrowserControlClient = class {
|
|
|
33530
33537
|
return await this.requestJson(input);
|
|
33531
33538
|
}
|
|
33532
33539
|
async requestBytesForSession(input) {
|
|
33533
|
-
return await this.requestBytes(input);
|
|
33540
|
+
return await this.requestBytes({ ...input, surface: "computer" });
|
|
33541
|
+
}
|
|
33542
|
+
async requestBrowserBytesForSession(input) {
|
|
33543
|
+
return await this.requestBytes({ ...input, surface: "browser" });
|
|
33534
33544
|
}
|
|
33535
33545
|
async requestJson(input, retryNativeEndpoint = true) {
|
|
33536
33546
|
const requireHostFetch = this.session.requireHostFetchController === true;
|
|
@@ -33766,10 +33776,10 @@ var BrowserControlClient = class {
|
|
|
33766
33776
|
const data = await readBytes(
|
|
33767
33777
|
this.session,
|
|
33768
33778
|
responsePath,
|
|
33769
|
-
COMPUTER_SCREENSHOT_MAX_BYTES,
|
|
33779
|
+
input.surface === "browser" ? 24 * 1024 * 1024 : COMPUTER_SCREENSHOT_MAX_BYTES,
|
|
33770
33780
|
timeoutMs
|
|
33771
33781
|
);
|
|
33772
|
-
return
|
|
33782
|
+
return controllerImageFrame(data, headers, input);
|
|
33773
33783
|
} catch (error) {
|
|
33774
33784
|
if (error instanceof BrowserControlRequestError || error instanceof BrowserControlProtocolError || error instanceof RangeError) {
|
|
33775
33785
|
throw error;
|
|
@@ -33917,6 +33927,18 @@ var BrowserControlSessionClient = class {
|
|
|
33917
33927
|
})
|
|
33918
33928
|
);
|
|
33919
33929
|
}
|
|
33930
|
+
async capture(targetId) {
|
|
33931
|
+
return await this.parent.requestBrowserBytesForSession({
|
|
33932
|
+
method: "GET",
|
|
33933
|
+
path: this.targetPath(targetId, "screenshot?format=jpeg&quality=55"),
|
|
33934
|
+
token: this.viewToken,
|
|
33935
|
+
expectedFrameEvidence: {
|
|
33936
|
+
browserSessionId: this.reference.browserSessionId,
|
|
33937
|
+
controllerGeneration: this.reference.controllerGeneration,
|
|
33938
|
+
targetId: requireOpaqueId(targetId, "browser target id")
|
|
33939
|
+
}
|
|
33940
|
+
});
|
|
33941
|
+
}
|
|
33920
33942
|
async readClipboard() {
|
|
33921
33943
|
return BrowserClipboard.parse(
|
|
33922
33944
|
await this.parent.requestForSession({
|
|
@@ -34250,12 +34272,42 @@ async function requestExposedControllerBytes(endpoint, input, defaultTimeoutMs)
|
|
|
34250
34272
|
throw new BrowserControlProtocolError("browser controller image response is invalid");
|
|
34251
34273
|
}
|
|
34252
34274
|
const declaredLength = Number(response.headers.get("content-length"));
|
|
34253
|
-
|
|
34254
|
-
|
|
34255
|
-
|
|
34275
|
+
const maxBytes = input.surface === "browser" ? 24 * 1024 * 1024 : COMPUTER_SCREENSHOT_MAX_BYTES;
|
|
34276
|
+
if (Number.isFinite(declaredLength) && declaredLength > maxBytes) {
|
|
34277
|
+
await response.body?.cancel("frame exceeds its byte bound").catch(() => void 0);
|
|
34278
|
+
throw new RangeError("frame exceeds its byte bound");
|
|
34256
34279
|
}
|
|
34257
34280
|
const data = new Uint8Array(await response.arrayBuffer());
|
|
34258
|
-
return
|
|
34281
|
+
return controllerImageFrame(data, response.headers, input);
|
|
34282
|
+
}
|
|
34283
|
+
function controllerImageFrame(data, headers, input) {
|
|
34284
|
+
return input.surface === "browser" ? browserControlFrame(data, headers, input.expectedFrameEvidence) : computerControlFrame(data, headers, input.expectedFrameEvidence);
|
|
34285
|
+
}
|
|
34286
|
+
function browserControlFrame(data, headers, expected) {
|
|
34287
|
+
if (data.byteLength < 1 || data.byteLength > 24 * 1024 * 1024) {
|
|
34288
|
+
throw new RangeError("browser frame exceeds its byte bound");
|
|
34289
|
+
}
|
|
34290
|
+
const get = (name) => headers.get(name.toLowerCase()) ?? null;
|
|
34291
|
+
const mediaType = get("content-type")?.split(";", 1)[0]?.trim().toLowerCase();
|
|
34292
|
+
if (mediaType !== "image/jpeg" && mediaType !== "image/png") {
|
|
34293
|
+
throw new BrowserControlProtocolError("browser frame media type is invalid");
|
|
34294
|
+
}
|
|
34295
|
+
const metadataHeader = get("x-opengeni-browser-frame");
|
|
34296
|
+
if (!metadataHeader || metadataHeader.length > 64 * 1024 || !/^[A-Za-z0-9_-]+$/u.test(metadataHeader)) {
|
|
34297
|
+
throw new BrowserControlProtocolError("browser frame metadata is invalid");
|
|
34298
|
+
}
|
|
34299
|
+
let metadata;
|
|
34300
|
+
try {
|
|
34301
|
+
metadata = parseBrowserFrameMetadata(
|
|
34302
|
+
JSON.parse(Buffer.from(metadataHeader, "base64url").toString("utf8"))
|
|
34303
|
+
);
|
|
34304
|
+
} catch {
|
|
34305
|
+
throw new BrowserControlProtocolError("browser frame metadata is invalid");
|
|
34306
|
+
}
|
|
34307
|
+
if (metadata.browserSessionId !== expected.browserSessionId || metadata.controllerGeneration !== expected.controllerGeneration || metadata.targetId !== expected.targetId || metadata.mediaType !== mediaType) {
|
|
34308
|
+
throw new BrowserControlProtocolError("browser frame evidence does not match its request");
|
|
34309
|
+
}
|
|
34310
|
+
return { data, mediaType, metadataHeader, metadata };
|
|
34259
34311
|
}
|
|
34260
34312
|
function computerControlFrame(data, headers, expected) {
|
|
34261
34313
|
if (data.byteLength < 1 || data.byteLength > COMPUTER_SCREENSHOT_MAX_BYTES) {
|
|
@@ -38565,4 +38617,4 @@ export {
|
|
|
38565
38617
|
collectSandboxEnvironment2 as collectSandboxEnvironment,
|
|
38566
38618
|
parseExposedPorts2 as parseExposedPorts
|
|
38567
38619
|
};
|
|
38568
|
-
//# sourceMappingURL=chunk-
|
|
38620
|
+
//# sourceMappingURL=chunk-JFMOX5OE.js.map
|