@withgateway/sdk 0.2.8 → 0.3.0
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/README.md +24 -8
- package/dist/cli.js +2695 -657
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +2675 -637
- package/dist/cli.mjs.map +1 -1
- package/dist/files/index.d.mts +1 -0
- package/dist/files/index.d.ts +1 -0
- package/dist/files/index.js +1443 -36
- package/dist/files/index.js.map +1 -1
- package/dist/files/index.mjs +1441 -28
- package/dist/files/index.mjs.map +1 -1
- package/dist/{index-Cz8Q6Keo.d.mts → index-D6oi1TWE.d.mts} +93 -34
- package/dist/{index-BO2SNSgy.d.ts → index-DAb-FCMg.d.ts} +93 -34
- package/dist/index.d.mts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +1986 -235
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1941 -218
- package/dist/index.mjs.map +1 -1
- package/dist/media-CbcAfQvd.d.mts +83 -0
- package/dist/media-CbcAfQvd.d.ts +83 -0
- package/dist/traces/index.d.mts +1 -0
- package/dist/traces/index.d.ts +1 -0
- package/dist/traces/index.js +1440 -33
- package/dist/traces/index.js.map +1 -1
- package/dist/traces/index.mjs +1438 -25
- package/dist/traces/index.mjs.map +1 -1
- package/dist/tracing/index.d.mts +2 -1
- package/dist/tracing/index.d.ts +2 -1
- package/dist/tracing/index.js +512 -11
- package/dist/tracing/index.js.map +1 -1
- package/dist/tracing/index.mjs +501 -10
- package/dist/tracing/index.mjs.map +1 -1
- package/dist/worlds/index.d.mts +614 -25
- package/dist/worlds/index.d.ts +614 -25
- package/dist/worlds/index.js +1923 -214
- package/dist/worlds/index.js.map +1 -1
- package/dist/worlds/index.mjs +1910 -201
- package/dist/worlds/index.mjs.map +1 -1
- package/package.json +1 -1
- package/runtime/gatewaysdk/environment/_toml.py +3 -10
- package/runtime/gatewaysdk/environment/schema/api.py +38 -56
- package/runtime/gatewaysdk/environment/schema/grading.py +1 -5
- package/runtime/gatewaysdk/environment/schema/host.py +53 -90
- package/runtime/gatewaysdk/environment/schema/local.py +15 -7
- package/runtime/gatewaysdk/environment/schema/runtime.py +9 -9
- package/runtime/gatewaysdk/environment/schema/skills/benchmarks-getting-started/SKILL.md +3 -3
- package/runtime/gatewaysdk/environment/schema/skills/connector-schema-authoring/SKILL.md +1 -1
- package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/SKILL.md +18 -18
- package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/cli-mcp-map.md +4 -2
- package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/gotchas.md +5 -1
- package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/new-world-sandbox.md +5 -3
- package/runtime/gatewaysdk/environment/schema/store.py +15 -6
- package/runtime/gatewaysdk/environment/schema/tasks.py +25 -1
- package/skills/benchmarks-getting-started/SKILL.md +3 -3
- package/skills/connector-schema-authoring/SKILL.md +1 -1
- package/skills/connector-schema-authoring/world-schema.md +1 -1
- package/skills/worlds-getting-started/SKILL.md +18 -18
- package/skills/worlds-getting-started/references/cli-mcp-map.md +4 -2
- package/skills/worlds-getting-started/references/gotchas.md +5 -1
- package/skills/worlds-getting-started/references/new-world-sandbox.md +5 -3
package/dist/index.js
CHANGED
|
@@ -464,6 +464,115 @@ var init_scores = __esm({
|
|
|
464
464
|
}
|
|
465
465
|
});
|
|
466
466
|
|
|
467
|
+
// src/worlds/transport.ts
|
|
468
|
+
function platformTimeoutMs(env = process.env) {
|
|
469
|
+
const raw = env[PLATFORM_TIMEOUT_ENV];
|
|
470
|
+
if (raw === void 0 || raw === "") return PLATFORM_TIMEOUT_DEFAULT_MS;
|
|
471
|
+
const value = Number(raw);
|
|
472
|
+
if (Number.isInteger(value) && value > 0) return value;
|
|
473
|
+
throw new Error(`${PLATFORM_TIMEOUT_ENV} must be a positive whole number of milliseconds, not \`${raw}\`.`);
|
|
474
|
+
}
|
|
475
|
+
var PLATFORM_TIMEOUT_ENV, PLATFORM_TIMEOUT_DEFAULT_MS, CHECK_HOST, RETRY, CAUSES, UNKNOWN_CAUSE, TransportCause, UnreachableError, PlatformTransport;
|
|
476
|
+
var init_transport = __esm({
|
|
477
|
+
"src/worlds/transport.ts"() {
|
|
478
|
+
"use strict";
|
|
479
|
+
PLATFORM_TIMEOUT_ENV = "GATEWAY_TIMEOUT_MS";
|
|
480
|
+
PLATFORM_TIMEOUT_DEFAULT_MS = 12e4;
|
|
481
|
+
CHECK_HOST = "Check GATEWAY_HOST (or --host) points at a running platform, then retry.";
|
|
482
|
+
RETRY = "Retry; if it repeats, check the network between here and the platform.";
|
|
483
|
+
CAUSES = {
|
|
484
|
+
ECONNREFUSED: { reason: "connection refused", next: CHECK_HOST },
|
|
485
|
+
ENOTFOUND: { reason: "DNS lookup failed", next: CHECK_HOST },
|
|
486
|
+
EAI_AGAIN: { reason: "DNS lookup failed", next: CHECK_HOST },
|
|
487
|
+
ETIMEDOUT: { reason: "connect timed out", next: CHECK_HOST },
|
|
488
|
+
UND_ERR_CONNECT_TIMEOUT: { reason: "connect timed out", next: CHECK_HOST },
|
|
489
|
+
EHOSTUNREACH: { reason: "host unreachable", next: CHECK_HOST },
|
|
490
|
+
ENETUNREACH: { reason: "network unreachable", next: RETRY },
|
|
491
|
+
ECONNRESET: { reason: "connection dropped", next: RETRY },
|
|
492
|
+
UND_ERR_SOCKET: { reason: "connection dropped", next: RETRY },
|
|
493
|
+
EPIPE: { reason: "connection dropped", next: RETRY }
|
|
494
|
+
};
|
|
495
|
+
UNKNOWN_CAUSE = { reason: "network error", next: CHECK_HOST };
|
|
496
|
+
TransportCause = class _TransportCause {
|
|
497
|
+
constructor(reason, detail, next) {
|
|
498
|
+
this.reason = reason;
|
|
499
|
+
this.detail = detail;
|
|
500
|
+
this.next = next;
|
|
501
|
+
}
|
|
502
|
+
reason;
|
|
503
|
+
detail;
|
|
504
|
+
next;
|
|
505
|
+
static timeout(timeoutMs) {
|
|
506
|
+
return new _TransportCause(
|
|
507
|
+
`timed out after ${timeoutMs / 1e3}s`,
|
|
508
|
+
null,
|
|
509
|
+
`Retry; if the platform is slow, raise ${PLATFORM_TIMEOUT_ENV} (milliseconds per request).`
|
|
510
|
+
);
|
|
511
|
+
}
|
|
512
|
+
static of(error) {
|
|
513
|
+
const cause = error instanceof Error && error.cause instanceof Error ? error.cause : void 0;
|
|
514
|
+
const code = cause && "code" in cause && typeof cause.code === "string" ? cause.code : null;
|
|
515
|
+
const message = cause?.message ?? (error instanceof Error ? error.message : String(error));
|
|
516
|
+
const known = code && CAUSES[code] || UNKNOWN_CAUSE;
|
|
517
|
+
return new _TransportCause(known.reason, code ? `${code}: ${message}` : message, known.next);
|
|
518
|
+
}
|
|
519
|
+
describe() {
|
|
520
|
+
return this.detail === null ? this.reason : `${this.reason} (${this.detail})`;
|
|
521
|
+
}
|
|
522
|
+
};
|
|
523
|
+
UnreachableError = class extends Error {
|
|
524
|
+
constructor(host, method, route, failure) {
|
|
525
|
+
super(`${method} ${route}: no answer from ${host}: ${failure.describe()}. ${failure.next}`);
|
|
526
|
+
this.host = host;
|
|
527
|
+
this.method = method;
|
|
528
|
+
this.route = route;
|
|
529
|
+
this.failure = failure;
|
|
530
|
+
this.name = "UnreachableError";
|
|
531
|
+
}
|
|
532
|
+
host;
|
|
533
|
+
method;
|
|
534
|
+
route;
|
|
535
|
+
failure;
|
|
536
|
+
};
|
|
537
|
+
PlatformTransport = class {
|
|
538
|
+
constructor(endpoint, timeoutMs = platformTimeoutMs()) {
|
|
539
|
+
this.endpoint = endpoint;
|
|
540
|
+
this.timeoutMs = timeoutMs;
|
|
541
|
+
}
|
|
542
|
+
endpoint;
|
|
543
|
+
timeoutMs;
|
|
544
|
+
/** A request that legitimately takes longer (a sandbox exec, a world create) waits its own budget; every other one waits the default. */
|
|
545
|
+
budget(ownMs) {
|
|
546
|
+
return Math.max(ownMs ?? 0, this.timeoutMs);
|
|
547
|
+
}
|
|
548
|
+
async send(method, route, body, opts = {}) {
|
|
549
|
+
const timeoutMs = this.budget(opts.timeoutMs);
|
|
550
|
+
const payload = body === void 0 ? {} : { body: JSON.stringify(body) };
|
|
551
|
+
const controller = new AbortController();
|
|
552
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
553
|
+
try {
|
|
554
|
+
const res = await fetch(`${this.endpoint.host}${route}`, {
|
|
555
|
+
method,
|
|
556
|
+
headers: {
|
|
557
|
+
"content-type": "application/json",
|
|
558
|
+
accept: "application/json",
|
|
559
|
+
authorization: "Basic " + Buffer.from(`${this.endpoint.publicKey}:${this.endpoint.secretKey}`).toString("base64")
|
|
560
|
+
},
|
|
561
|
+
...payload,
|
|
562
|
+
signal: controller.signal
|
|
563
|
+
});
|
|
564
|
+
return { status: res.status, ok: res.ok, text: await res.text() };
|
|
565
|
+
} catch (error) {
|
|
566
|
+
const cause = controller.signal.aborted ? TransportCause.timeout(timeoutMs) : TransportCause.of(error);
|
|
567
|
+
throw new UnreachableError(this.endpoint.host, method, route, cause);
|
|
568
|
+
} finally {
|
|
569
|
+
clearTimeout(timer);
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
});
|
|
575
|
+
|
|
467
576
|
// src/worlds/browserReconnect.ts
|
|
468
577
|
async function closeConnection(c) {
|
|
469
578
|
await c.context.close();
|
|
@@ -647,7 +756,7 @@ function withoutUiToken(url) {
|
|
|
647
756
|
const [beforeHash, hash] = splitHash(url);
|
|
648
757
|
const q = beforeHash.indexOf("?");
|
|
649
758
|
if (q < 0) return url;
|
|
650
|
-
const kept = beforeHash.slice(q + 1).split("&").filter((
|
|
759
|
+
const kept = beforeHash.slice(q + 1).split("&").filter((pair3) => pair3 !== "" && pair3.split("=")[0] !== UI_TOKEN_QUERY);
|
|
651
760
|
return beforeHash.slice(0, q) + (kept.length ? `?${kept.join("&")}` : "") + hash;
|
|
652
761
|
}
|
|
653
762
|
function splitHash(url) {
|
|
@@ -782,7 +891,7 @@ var SURFACE_KINDS, BROWSER_TIERS, DEFAULT_VIEWPORT, SETTLE_TIMEOUT_MS, SETTLE_QU
|
|
|
782
891
|
var init_browser = __esm({
|
|
783
892
|
"src/worlds/browser.ts"() {
|
|
784
893
|
"use strict";
|
|
785
|
-
|
|
894
|
+
init_session2();
|
|
786
895
|
init_browserReconnect();
|
|
787
896
|
SURFACE_KINDS = ["tools", "api", "ui", "browser"];
|
|
788
897
|
BROWSER_TIERS = ["standard", "premium"];
|
|
@@ -928,6 +1037,10 @@ var init_browser = __esm({
|
|
|
928
1037
|
get agentId() {
|
|
929
1038
|
return this.recorder?.agentId ?? null;
|
|
930
1039
|
}
|
|
1040
|
+
/** `text` with this session's credentials (UI token, browser address) removed. */
|
|
1041
|
+
scrub(text2) {
|
|
1042
|
+
return this.scrubber.scrub(text2);
|
|
1043
|
+
}
|
|
931
1044
|
watchNetwork(page) {
|
|
932
1045
|
page.on("request", () => {
|
|
933
1046
|
this.inflight += 1;
|
|
@@ -1214,6 +1327,1269 @@ var init_browser = __esm({
|
|
|
1214
1327
|
}
|
|
1215
1328
|
});
|
|
1216
1329
|
|
|
1330
|
+
// src/worlds/nativeComputer/actions.ts
|
|
1331
|
+
function toNumber(value) {
|
|
1332
|
+
if (typeof value !== "number" || !Number.isFinite(value))
|
|
1333
|
+
throw new Error(`not a number: ${JSON.stringify(value) ?? String(value)}`);
|
|
1334
|
+
return value;
|
|
1335
|
+
}
|
|
1336
|
+
function toInt(value) {
|
|
1337
|
+
return Math.trunc(toNumber(value));
|
|
1338
|
+
}
|
|
1339
|
+
var ACTION_NAMES, SECRET_TEXT, BOUNDS, ComputerAction;
|
|
1340
|
+
var init_actions = __esm({
|
|
1341
|
+
"src/worlds/nativeComputer/actions.ts"() {
|
|
1342
|
+
"use strict";
|
|
1343
|
+
ACTION_NAMES = [
|
|
1344
|
+
"screenshot",
|
|
1345
|
+
"zoom",
|
|
1346
|
+
"click",
|
|
1347
|
+
"move",
|
|
1348
|
+
"mouse_down",
|
|
1349
|
+
"mouse_up",
|
|
1350
|
+
"drag",
|
|
1351
|
+
"scroll",
|
|
1352
|
+
"type",
|
|
1353
|
+
"key",
|
|
1354
|
+
"hold_key",
|
|
1355
|
+
"wait",
|
|
1356
|
+
"cursor_position",
|
|
1357
|
+
"history"
|
|
1358
|
+
];
|
|
1359
|
+
SECRET_TEXT = "[redacted]";
|
|
1360
|
+
BOUNDS = {
|
|
1361
|
+
seconds: [0, 300],
|
|
1362
|
+
repeat: [1, 100],
|
|
1363
|
+
count: [1, 3],
|
|
1364
|
+
dx: [-1e4, 1e4],
|
|
1365
|
+
dy: [-1e4, 1e4]
|
|
1366
|
+
};
|
|
1367
|
+
ComputerAction = class {
|
|
1368
|
+
constructor(name, args = {}) {
|
|
1369
|
+
this.name = name;
|
|
1370
|
+
this.args = args;
|
|
1371
|
+
if (!ACTION_NAMES.includes(name))
|
|
1372
|
+
throw new Error(`unknown computer action: ${name}`);
|
|
1373
|
+
for (const [key2, [low, high]] of Object.entries(BOUNDS)) {
|
|
1374
|
+
const value = args[key2];
|
|
1375
|
+
if (value !== void 0 && !(Number(value) >= low && Number(value) <= high))
|
|
1376
|
+
throw new Error(
|
|
1377
|
+
`${name} ${key2} must be between ${low} and ${high}, got ${String(value)}`
|
|
1378
|
+
);
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
name;
|
|
1382
|
+
args;
|
|
1383
|
+
/** Flat arguments for the browser timeline and the trace: lists become
|
|
1384
|
+
* `"x,y"` strings, and typed text is withheld when it went into a
|
|
1385
|
+
* credential field. */
|
|
1386
|
+
recordArgs(secretText) {
|
|
1387
|
+
const out = {};
|
|
1388
|
+
for (const [key2, value] of Object.entries(this.args))
|
|
1389
|
+
out[key2] = Array.isArray(value) ? value.flat().join(",") : value;
|
|
1390
|
+
if (secretText && "text" in out) out.text = SECRET_TEXT;
|
|
1391
|
+
return out;
|
|
1392
|
+
}
|
|
1393
|
+
};
|
|
1394
|
+
}
|
|
1395
|
+
});
|
|
1396
|
+
|
|
1397
|
+
// src/worlds/nativeComputer/display.ts
|
|
1398
|
+
var FIT_STEP, Display;
|
|
1399
|
+
var init_display = __esm({
|
|
1400
|
+
"src/worlds/nativeComputer/display.ts"() {
|
|
1401
|
+
"use strict";
|
|
1402
|
+
FIT_STEP = 0.98;
|
|
1403
|
+
Display = class _Display {
|
|
1404
|
+
constructor(width, height, viewportWidth, viewportHeight) {
|
|
1405
|
+
this.width = width;
|
|
1406
|
+
this.height = height;
|
|
1407
|
+
this.viewportWidth = viewportWidth;
|
|
1408
|
+
this.viewportHeight = viewportHeight;
|
|
1409
|
+
}
|
|
1410
|
+
width;
|
|
1411
|
+
height;
|
|
1412
|
+
viewportWidth;
|
|
1413
|
+
viewportHeight;
|
|
1414
|
+
/** `size` when the caller names one; otherwise the largest downscale of the
|
|
1415
|
+
* viewport (at most 1:1) that `fits` the provider's limits. */
|
|
1416
|
+
static forViewport(viewport, size, fits = () => true) {
|
|
1417
|
+
const { width, height } = viewport;
|
|
1418
|
+
if (size) return _Display.sized(size[0], size[1], width, height);
|
|
1419
|
+
let scale = 1;
|
|
1420
|
+
while (!fits(Math.round(width * scale), Math.round(height * scale)))
|
|
1421
|
+
scale *= FIT_STEP;
|
|
1422
|
+
return new _Display(
|
|
1423
|
+
Math.round(width * scale),
|
|
1424
|
+
Math.round(height * scale),
|
|
1425
|
+
width,
|
|
1426
|
+
height
|
|
1427
|
+
);
|
|
1428
|
+
}
|
|
1429
|
+
/** A caller's display keeps the viewport's shape: screenshots are scaled
|
|
1430
|
+
* uniformly, so another aspect ratio would map clicks off the image. */
|
|
1431
|
+
static sized(width, height, viewportWidth, viewportHeight) {
|
|
1432
|
+
if (width <= 0 || height <= 0)
|
|
1433
|
+
throw new Error(`display ${width}x${height} must be positive`);
|
|
1434
|
+
const sameShape = width * viewportHeight / viewportWidth;
|
|
1435
|
+
if (Math.abs(sameShape - height) > 1)
|
|
1436
|
+
throw new Error(
|
|
1437
|
+
`display ${width}x${height} must keep the viewport's aspect ratio (${viewportWidth}x${viewportHeight}); try ${width}x${Math.round(sameShape)}`
|
|
1438
|
+
);
|
|
1439
|
+
return new _Display(width, height, viewportWidth, viewportHeight);
|
|
1440
|
+
}
|
|
1441
|
+
get scaled() {
|
|
1442
|
+
return this.width !== this.viewportWidth || this.height !== this.viewportHeight;
|
|
1443
|
+
}
|
|
1444
|
+
get scale() {
|
|
1445
|
+
return Math.min(
|
|
1446
|
+
this.width / this.viewportWidth,
|
|
1447
|
+
this.height / this.viewportHeight
|
|
1448
|
+
);
|
|
1449
|
+
}
|
|
1450
|
+
toPage(x, y) {
|
|
1451
|
+
return [
|
|
1452
|
+
x * this.viewportWidth / this.width,
|
|
1453
|
+
y * this.viewportHeight / this.height
|
|
1454
|
+
];
|
|
1455
|
+
}
|
|
1456
|
+
};
|
|
1457
|
+
}
|
|
1458
|
+
});
|
|
1459
|
+
|
|
1460
|
+
// src/worlds/nativeComputer/screen.ts
|
|
1461
|
+
function pngWidth(png) {
|
|
1462
|
+
if (png.length < 24 || !png.subarray(0, 8).equals(PNG_SIGNATURE)) return null;
|
|
1463
|
+
return png.readUInt32BE(16);
|
|
1464
|
+
}
|
|
1465
|
+
function isNativePage(page) {
|
|
1466
|
+
const candidate = page;
|
|
1467
|
+
const mouse = candidate?.mouse;
|
|
1468
|
+
return typeof candidate?.context === "function" && NATIVE_METHODS.every((m) => typeof mouse?.[m] === "function");
|
|
1469
|
+
}
|
|
1470
|
+
var FOCUSED_FIELD_JS, SECRET_FOCUS, DRAG_STEPS, PNG_SIGNATURE, NATIVE_METHODS, Screen;
|
|
1471
|
+
var init_screen = __esm({
|
|
1472
|
+
"src/worlds/nativeComputer/screen.ts"() {
|
|
1473
|
+
"use strict";
|
|
1474
|
+
init_browser();
|
|
1475
|
+
FOCUSED_FIELD_JS = "(() => { let e = document.activeElement; const inner = (el) => (el.shadowRoot && el.shadowRoot.activeElement) || (el.contentDocument && el.contentDocument.activeElement); while (e && inner(e)) e = inner(e); if (!e) return ''; if (e.tagName === 'IFRAME' || e.tagName === 'FRAME') return 'frame'; if (!(e.tagName === 'INPUT' || e.tagName === 'TEXTAREA' || e.isContentEditable)) return 'opaque'; return [e.type, e.name, e.id, e.getAttribute('autocomplete')].filter(Boolean).join(' '); })()";
|
|
1476
|
+
SECRET_FOCUS = ["password", "frame", "opaque"];
|
|
1477
|
+
DRAG_STEPS = 5;
|
|
1478
|
+
PNG_SIGNATURE = Buffer.from([
|
|
1479
|
+
137,
|
|
1480
|
+
80,
|
|
1481
|
+
78,
|
|
1482
|
+
71,
|
|
1483
|
+
13,
|
|
1484
|
+
10,
|
|
1485
|
+
26,
|
|
1486
|
+
10
|
|
1487
|
+
]);
|
|
1488
|
+
NATIVE_METHODS = ["move", "click", "down", "up", "wheel"];
|
|
1489
|
+
Screen = class {
|
|
1490
|
+
constructor(browser, display) {
|
|
1491
|
+
this.browser = browser;
|
|
1492
|
+
this.display = display;
|
|
1493
|
+
}
|
|
1494
|
+
browser;
|
|
1495
|
+
display;
|
|
1496
|
+
cursor = [0, 0];
|
|
1497
|
+
pixelRatio = 1;
|
|
1498
|
+
handlers = {
|
|
1499
|
+
screenshot: async () => ({ image: await this.screenshot() }),
|
|
1500
|
+
zoom: (a) => this.zoom(a),
|
|
1501
|
+
click: (a) => this.click(a),
|
|
1502
|
+
move: (a) => this.held(a.args.modifiers ?? [], () => this.moveTo(this.point(a))),
|
|
1503
|
+
mouse_down: async (a) => {
|
|
1504
|
+
await this.page.mouse.down({ button: a.args.button ?? "left" });
|
|
1505
|
+
return {};
|
|
1506
|
+
},
|
|
1507
|
+
mouse_up: async (a) => {
|
|
1508
|
+
await this.page.mouse.up({ button: a.args.button ?? "left" });
|
|
1509
|
+
return {};
|
|
1510
|
+
},
|
|
1511
|
+
drag: (a) => this.drag(a),
|
|
1512
|
+
scroll: (a) => this.scroll(a),
|
|
1513
|
+
type: async (a) => {
|
|
1514
|
+
await this.page.keyboard.type(a.args.text ?? "");
|
|
1515
|
+
return {};
|
|
1516
|
+
},
|
|
1517
|
+
key: (a) => this.key(a),
|
|
1518
|
+
hold_key: (a) => this.held(
|
|
1519
|
+
a.args.keys ?? [],
|
|
1520
|
+
() => this.page.waitForTimeout((a.args.seconds ?? 0) * 1e3)
|
|
1521
|
+
),
|
|
1522
|
+
wait: async (a) => {
|
|
1523
|
+
await this.page.waitForTimeout((a.args.seconds ?? 0) * 1e3);
|
|
1524
|
+
return {};
|
|
1525
|
+
},
|
|
1526
|
+
cursor_position: async () => ({
|
|
1527
|
+
text: `X=${this.cursor[0]}, Y=${this.cursor[1]}`
|
|
1528
|
+
}),
|
|
1529
|
+
history: async (a) => {
|
|
1530
|
+
const navigate = {
|
|
1531
|
+
back: () => this.page.goBack(),
|
|
1532
|
+
forward: () => this.page.goForward()
|
|
1533
|
+
};
|
|
1534
|
+
await navigate[a.args.direction ?? "back"]();
|
|
1535
|
+
return {};
|
|
1536
|
+
}
|
|
1537
|
+
};
|
|
1538
|
+
/** The live page (a new object after a reconnect), as pixel-level Playwright. */
|
|
1539
|
+
get page() {
|
|
1540
|
+
const page = this.browser.page;
|
|
1541
|
+
if (!isNativePage(page))
|
|
1542
|
+
throw new Error(
|
|
1543
|
+
"native computer use needs a Playwright page (mouse.move/click/down/up/wheel, context())"
|
|
1544
|
+
);
|
|
1545
|
+
return page;
|
|
1546
|
+
}
|
|
1547
|
+
run(action) {
|
|
1548
|
+
return this.handlers[action.name](action);
|
|
1549
|
+
}
|
|
1550
|
+
/** A PNG of the viewport at the model's display size. */
|
|
1551
|
+
async screenshot() {
|
|
1552
|
+
if (!this.display.scaled) return this.page.screenshot({ type: "png" });
|
|
1553
|
+
const { viewportWidth: width, viewportHeight: height } = this.display;
|
|
1554
|
+
return this.capture({ x: 0, y: 0, width, height }, this.display.scale);
|
|
1555
|
+
}
|
|
1556
|
+
/** Whether keystrokes go to a credential field (a password input, or one
|
|
1557
|
+
* named like a token, key or PIN), looking through shadow roots and
|
|
1558
|
+
* same-origin frames. An unreadable page, a cross-origin frame or a focus
|
|
1559
|
+
* that is not a text field (a closed shadow root's host) counts as one. */
|
|
1560
|
+
async focusedFieldIsSecret() {
|
|
1561
|
+
let described;
|
|
1562
|
+
try {
|
|
1563
|
+
described = String(await this.page.evaluate(FOCUSED_FIELD_JS) ?? "");
|
|
1564
|
+
} catch {
|
|
1565
|
+
return true;
|
|
1566
|
+
}
|
|
1567
|
+
return SECRET_FOCUS.some((prefix) => described.startsWith(prefix)) || SECRET_KEY.test(described);
|
|
1568
|
+
}
|
|
1569
|
+
/** CDP renders a clip at the page's device pixel ratio as well as its
|
|
1570
|
+
* `scale` (a Retina host doubles it), so a capture of the wrong width
|
|
1571
|
+
* measures that ratio and is taken once more, corrected. */
|
|
1572
|
+
async capture(clip, scale) {
|
|
1573
|
+
const wanted = Math.round(clip.width * scale);
|
|
1574
|
+
const png = await this.cdpCapture(clip, scale / this.pixelRatio);
|
|
1575
|
+
const width = pngWidth(png);
|
|
1576
|
+
if (width === null || Math.abs(width - wanted) <= 1) return png;
|
|
1577
|
+
this.pixelRatio *= width / wanted;
|
|
1578
|
+
return this.cdpCapture(clip, scale / this.pixelRatio);
|
|
1579
|
+
}
|
|
1580
|
+
async cdpCapture(clip, scale) {
|
|
1581
|
+
const page = this.page;
|
|
1582
|
+
const session = await page.context().newCDPSession(page);
|
|
1583
|
+
try {
|
|
1584
|
+
const shot = await session.send("Page.captureScreenshot", {
|
|
1585
|
+
format: "png",
|
|
1586
|
+
clip: { ...clip, scale }
|
|
1587
|
+
});
|
|
1588
|
+
return Buffer.from(shot.data, "base64");
|
|
1589
|
+
} finally {
|
|
1590
|
+
await session.detach();
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
point(action) {
|
|
1594
|
+
const { x, y } = action.args;
|
|
1595
|
+
return x === void 0 || y === void 0 ? this.cursor : [x, y];
|
|
1596
|
+
}
|
|
1597
|
+
async moveTo(point2, steps = 1) {
|
|
1598
|
+
const [x, y] = this.display.toPage(point2[0], point2[1]);
|
|
1599
|
+
await this.page.mouse.move(x, y, { steps });
|
|
1600
|
+
this.cursor = point2;
|
|
1601
|
+
}
|
|
1602
|
+
async held(modifiers, fn) {
|
|
1603
|
+
for (const key2 of modifiers) await this.page.keyboard.down(key2);
|
|
1604
|
+
try {
|
|
1605
|
+
await fn();
|
|
1606
|
+
} finally {
|
|
1607
|
+
for (const key2 of [...modifiers].reverse())
|
|
1608
|
+
await this.page.keyboard.up(key2);
|
|
1609
|
+
}
|
|
1610
|
+
return {};
|
|
1611
|
+
}
|
|
1612
|
+
async zoom(action) {
|
|
1613
|
+
const [x0, y0, x1, y1] = action.args.region ?? [0, 0, 0, 0];
|
|
1614
|
+
const [left, top] = this.display.toPage(x0, y0);
|
|
1615
|
+
const [right, bottom] = this.display.toPage(x1, y1);
|
|
1616
|
+
if (right <= left || bottom <= top)
|
|
1617
|
+
throw new Error("zoom region must have x1 > x0 and y1 > y0");
|
|
1618
|
+
const width = right - left;
|
|
1619
|
+
const height = bottom - top;
|
|
1620
|
+
const scale = Math.min(
|
|
1621
|
+
this.display.width / width,
|
|
1622
|
+
this.display.height / height
|
|
1623
|
+
);
|
|
1624
|
+
return {
|
|
1625
|
+
image: await this.capture({ x: left, y: top, width, height }, scale)
|
|
1626
|
+
};
|
|
1627
|
+
}
|
|
1628
|
+
async click(action) {
|
|
1629
|
+
const point2 = this.point(action);
|
|
1630
|
+
return this.held(action.args.modifiers ?? [], async () => {
|
|
1631
|
+
await this.moveTo(point2);
|
|
1632
|
+
const [x, y] = this.display.toPage(point2[0], point2[1]);
|
|
1633
|
+
await this.page.mouse.click(x, y, {
|
|
1634
|
+
button: action.args.button ?? "left",
|
|
1635
|
+
clickCount: action.args.count ?? 1
|
|
1636
|
+
});
|
|
1637
|
+
});
|
|
1638
|
+
}
|
|
1639
|
+
async drag(action) {
|
|
1640
|
+
const path16 = action.args.path ?? [];
|
|
1641
|
+
if (path16.length < 2) throw new Error("a drag needs at least two points");
|
|
1642
|
+
return this.held(action.args.modifiers ?? [], async () => {
|
|
1643
|
+
await this.moveTo(path16[0]);
|
|
1644
|
+
await this.page.mouse.down({ button: "left" });
|
|
1645
|
+
try {
|
|
1646
|
+
for (const point2 of path16.slice(1)) await this.moveTo(point2, DRAG_STEPS);
|
|
1647
|
+
} finally {
|
|
1648
|
+
await this.page.mouse.up({ button: "left" });
|
|
1649
|
+
}
|
|
1650
|
+
});
|
|
1651
|
+
}
|
|
1652
|
+
async scroll(action) {
|
|
1653
|
+
await this.moveTo(this.point(action));
|
|
1654
|
+
const scale = this.display.scale;
|
|
1655
|
+
return this.held(
|
|
1656
|
+
action.args.modifiers ?? [],
|
|
1657
|
+
() => this.page.mouse.wheel(
|
|
1658
|
+
(action.args.dx ?? 0) / scale,
|
|
1659
|
+
(action.args.dy ?? 0) / scale
|
|
1660
|
+
)
|
|
1661
|
+
);
|
|
1662
|
+
}
|
|
1663
|
+
async key(action) {
|
|
1664
|
+
const combo = (action.args.keys ?? []).join("+");
|
|
1665
|
+
for (let i = 0; i < (action.args.repeat ?? 1); i += 1)
|
|
1666
|
+
await this.page.keyboard.press(combo);
|
|
1667
|
+
return {};
|
|
1668
|
+
}
|
|
1669
|
+
};
|
|
1670
|
+
}
|
|
1671
|
+
});
|
|
1672
|
+
|
|
1673
|
+
// src/tracing/media.ts
|
|
1674
|
+
async function putBytes(url, data, headers) {
|
|
1675
|
+
const controller = new AbortController();
|
|
1676
|
+
const timer = setTimeout(() => controller.abort(), PUT_TIMEOUT_MS);
|
|
1677
|
+
try {
|
|
1678
|
+
const res = await fetch(url, {
|
|
1679
|
+
method: "PUT",
|
|
1680
|
+
body: new Uint8Array(data),
|
|
1681
|
+
headers,
|
|
1682
|
+
signal: controller.signal
|
|
1683
|
+
});
|
|
1684
|
+
return {
|
|
1685
|
+
status: res.status,
|
|
1686
|
+
error: res.ok ? null : (await res.text()).slice(0, MAX_UPLOAD_ERROR)
|
|
1687
|
+
};
|
|
1688
|
+
} catch (error) {
|
|
1689
|
+
return {
|
|
1690
|
+
status: NETWORK_FAILURE_STATUS,
|
|
1691
|
+
error: error instanceof Error ? error.name : "Error"
|
|
1692
|
+
};
|
|
1693
|
+
} finally {
|
|
1694
|
+
clearTimeout(timer);
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
var import_node_crypto, MEDIA_PATH, MAX_MEDIA_BYTES, PUT_TIMEOUT_MS, MAX_UPLOAD_ERROR, NETWORK_FAILURE_STATUS, MediaUploadError, MediaReference, MediaUploader;
|
|
1698
|
+
var init_media = __esm({
|
|
1699
|
+
"src/tracing/media.ts"() {
|
|
1700
|
+
"use strict";
|
|
1701
|
+
import_node_crypto = require("crypto");
|
|
1702
|
+
init_transport();
|
|
1703
|
+
MEDIA_PATH = "/api/public/media";
|
|
1704
|
+
MAX_MEDIA_BYTES = 5 * 1024 * 1024;
|
|
1705
|
+
PUT_TIMEOUT_MS = 3e4;
|
|
1706
|
+
MAX_UPLOAD_ERROR = 500;
|
|
1707
|
+
NETWORK_FAILURE_STATUS = 599;
|
|
1708
|
+
MediaUploadError = class extends Error {
|
|
1709
|
+
constructor(message, status) {
|
|
1710
|
+
super(message);
|
|
1711
|
+
this.status = status;
|
|
1712
|
+
this.name = "MediaUploadError";
|
|
1713
|
+
}
|
|
1714
|
+
status;
|
|
1715
|
+
};
|
|
1716
|
+
MediaReference = class {
|
|
1717
|
+
constructor(mediaId, contentType) {
|
|
1718
|
+
this.mediaId = mediaId;
|
|
1719
|
+
this.contentType = contentType;
|
|
1720
|
+
}
|
|
1721
|
+
mediaId;
|
|
1722
|
+
contentType;
|
|
1723
|
+
toString() {
|
|
1724
|
+
return `@@@langfuseMedia:type=${this.contentType}|id=${this.mediaId}|source=bytes@@@`;
|
|
1725
|
+
}
|
|
1726
|
+
};
|
|
1727
|
+
MediaUploader = class _MediaUploader {
|
|
1728
|
+
constructor(transport, put = putBytes, maxBytes = MAX_MEDIA_BYTES) {
|
|
1729
|
+
this.transport = transport;
|
|
1730
|
+
this.put = put;
|
|
1731
|
+
this.maxBytes = maxBytes;
|
|
1732
|
+
}
|
|
1733
|
+
transport;
|
|
1734
|
+
put;
|
|
1735
|
+
maxBytes;
|
|
1736
|
+
/** The uploader for `GATEWAY_HOST` / `GATEWAY_PUBLIC_KEY` /
|
|
1737
|
+
* `GATEWAY_SECRET_KEY` (the keys tracing exports with); null when any is unset. */
|
|
1738
|
+
static fromEnv(env = process.env) {
|
|
1739
|
+
const host = env.GATEWAY_HOST;
|
|
1740
|
+
const publicKey = env.GATEWAY_PUBLIC_KEY;
|
|
1741
|
+
const secretKey = env.GATEWAY_SECRET_KEY;
|
|
1742
|
+
if (!host || !publicKey || !secretKey) return null;
|
|
1743
|
+
return new _MediaUploader(
|
|
1744
|
+
new PlatformTransport({
|
|
1745
|
+
host: host.replace(/\/$/, ""),
|
|
1746
|
+
publicKey,
|
|
1747
|
+
secretKey
|
|
1748
|
+
})
|
|
1749
|
+
);
|
|
1750
|
+
}
|
|
1751
|
+
/** Store `data` linked to the trace (and observation) and return its reference. */
|
|
1752
|
+
async upload(data, link) {
|
|
1753
|
+
if (data.length > this.maxBytes)
|
|
1754
|
+
throw new MediaUploadError(
|
|
1755
|
+
`media is ${data.length} bytes, over the ${this.maxBytes}-byte cap`
|
|
1756
|
+
);
|
|
1757
|
+
const sha256Hash = (0, import_node_crypto.createHash)("sha256").update(data).digest("base64");
|
|
1758
|
+
const answer = await this.send("POST", MEDIA_PATH, {
|
|
1759
|
+
traceId: link.traceId,
|
|
1760
|
+
observationId: link.observationId,
|
|
1761
|
+
contentType: link.contentType,
|
|
1762
|
+
contentLength: data.length,
|
|
1763
|
+
sha256Hash,
|
|
1764
|
+
field: link.field
|
|
1765
|
+
});
|
|
1766
|
+
if (typeof answer.mediaId !== "string" || !answer.mediaId)
|
|
1767
|
+
throw new MediaUploadError(
|
|
1768
|
+
"POST /api/public/media answered without a mediaId"
|
|
1769
|
+
);
|
|
1770
|
+
const reference = new MediaReference(answer.mediaId, link.contentType);
|
|
1771
|
+
if (answer.uploadUrl)
|
|
1772
|
+
await this.store(reference, answer.uploadUrl, data, sha256Hash);
|
|
1773
|
+
return reference;
|
|
1774
|
+
}
|
|
1775
|
+
async store(reference, url, data, sha256Hash) {
|
|
1776
|
+
const started = Date.now();
|
|
1777
|
+
const { status, error } = await this.put(url, data, {
|
|
1778
|
+
"Content-Type": reference.contentType,
|
|
1779
|
+
"x-amz-checksum-sha256": sha256Hash,
|
|
1780
|
+
"x-ms-blob-type": "BlockBlob"
|
|
1781
|
+
});
|
|
1782
|
+
await this.send(
|
|
1783
|
+
"PATCH",
|
|
1784
|
+
`${MEDIA_PATH}/${encodeURIComponent(reference.mediaId)}`,
|
|
1785
|
+
{
|
|
1786
|
+
uploadedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1787
|
+
uploadHttpStatus: status,
|
|
1788
|
+
uploadHttpError: error,
|
|
1789
|
+
uploadTimeMs: Date.now() - started
|
|
1790
|
+
}
|
|
1791
|
+
);
|
|
1792
|
+
if (status < 200 || status >= 300)
|
|
1793
|
+
throw new MediaUploadError(
|
|
1794
|
+
`media storage refused the upload (HTTP ${status})`,
|
|
1795
|
+
status
|
|
1796
|
+
);
|
|
1797
|
+
}
|
|
1798
|
+
async send(method, route, body) {
|
|
1799
|
+
const reply = await this.transport.send(method, route, body);
|
|
1800
|
+
if (!reply.ok)
|
|
1801
|
+
throw new MediaUploadError(
|
|
1802
|
+
`${method} ${route} -> ${reply.status}`,
|
|
1803
|
+
reply.status
|
|
1804
|
+
);
|
|
1805
|
+
return reply.text ? JSON.parse(reply.text) : {};
|
|
1806
|
+
}
|
|
1807
|
+
};
|
|
1808
|
+
}
|
|
1809
|
+
});
|
|
1810
|
+
|
|
1811
|
+
// src/worlds/nativeComputer/trace.ts
|
|
1812
|
+
function loadOtelApi() {
|
|
1813
|
+
if (otelApi !== void 0) return otelApi;
|
|
1814
|
+
try {
|
|
1815
|
+
otelApi = require("@opentelemetry/api");
|
|
1816
|
+
} catch {
|
|
1817
|
+
otelApi = null;
|
|
1818
|
+
}
|
|
1819
|
+
return otelApi;
|
|
1820
|
+
}
|
|
1821
|
+
function errorText(error) {
|
|
1822
|
+
return error instanceof Error ? `${error.name}: ${error.message}` : String(error);
|
|
1823
|
+
}
|
|
1824
|
+
function errorName(error) {
|
|
1825
|
+
return error instanceof Error ? error.name : "Error";
|
|
1826
|
+
}
|
|
1827
|
+
var SPAN_PREFIX, MAX_UPLOAD_FAILURES, TRACER_NAME, MAX_ERROR, otelApi, ActionTracer;
|
|
1828
|
+
var init_trace = __esm({
|
|
1829
|
+
"src/worlds/nativeComputer/trace.ts"() {
|
|
1830
|
+
"use strict";
|
|
1831
|
+
init_media();
|
|
1832
|
+
SPAN_PREFIX = "computer.";
|
|
1833
|
+
MAX_UPLOAD_FAILURES = 3;
|
|
1834
|
+
TRACER_NAME = "@withgateway/sdk";
|
|
1835
|
+
MAX_ERROR = 1e3;
|
|
1836
|
+
ActionTracer = class _ActionTracer {
|
|
1837
|
+
constructor(media, warn3 = (m) => console.warn(m)) {
|
|
1838
|
+
this.media = media;
|
|
1839
|
+
this.warn = warn3;
|
|
1840
|
+
}
|
|
1841
|
+
media;
|
|
1842
|
+
warn;
|
|
1843
|
+
failures = 0;
|
|
1844
|
+
warned = false;
|
|
1845
|
+
static fromEnv() {
|
|
1846
|
+
return new _ActionTracer(MediaUploader.fromEnv());
|
|
1847
|
+
}
|
|
1848
|
+
/** `args` are already redacted. A failure's status goes through `scrub`:
|
|
1849
|
+
* browser errors quote the session's ws URL and UI token. */
|
|
1850
|
+
async span(action, args, run, capture, scrub) {
|
|
1851
|
+
const otel = loadOtelApi();
|
|
1852
|
+
if (!otel) return run();
|
|
1853
|
+
const { SpanStatusCode: SpanStatusCode3, trace: trace5 } = otel;
|
|
1854
|
+
const attributes = {
|
|
1855
|
+
"gateway.observation.type": "tool",
|
|
1856
|
+
"tool.name": SPAN_PREFIX + action.name,
|
|
1857
|
+
"gateway.observation.input": JSON.stringify({
|
|
1858
|
+
action: action.name,
|
|
1859
|
+
...args
|
|
1860
|
+
})
|
|
1861
|
+
};
|
|
1862
|
+
return trace5.getTracer(TRACER_NAME).startActiveSpan(
|
|
1863
|
+
SPAN_PREFIX + action.name,
|
|
1864
|
+
{ attributes },
|
|
1865
|
+
async (span) => {
|
|
1866
|
+
try {
|
|
1867
|
+
const result = await run();
|
|
1868
|
+
await this.finish(span, result, capture);
|
|
1869
|
+
span.setStatus({ code: SpanStatusCode3.OK });
|
|
1870
|
+
return result;
|
|
1871
|
+
} catch (error) {
|
|
1872
|
+
span.setStatus({
|
|
1873
|
+
code: SpanStatusCode3.ERROR,
|
|
1874
|
+
message: scrub(errorText(error)).slice(0, MAX_ERROR)
|
|
1875
|
+
});
|
|
1876
|
+
throw error;
|
|
1877
|
+
} finally {
|
|
1878
|
+
span.end();
|
|
1879
|
+
}
|
|
1880
|
+
}
|
|
1881
|
+
);
|
|
1882
|
+
}
|
|
1883
|
+
async finish(span, result, capture) {
|
|
1884
|
+
if (!span.isRecording()) return;
|
|
1885
|
+
const output = {
|
|
1886
|
+
screenshot: await this.screenshot(span, result, capture)
|
|
1887
|
+
};
|
|
1888
|
+
if (result.text !== void 0) output.text = result.text;
|
|
1889
|
+
span.setAttribute("gateway.observation.output", JSON.stringify(output));
|
|
1890
|
+
}
|
|
1891
|
+
async screenshot(span, result, capture) {
|
|
1892
|
+
let png;
|
|
1893
|
+
try {
|
|
1894
|
+
png = result.image ?? await capture();
|
|
1895
|
+
} catch (error) {
|
|
1896
|
+
return `[screenshot unavailable: ${errorName(error)}]`;
|
|
1897
|
+
}
|
|
1898
|
+
return this.reference(png, span);
|
|
1899
|
+
}
|
|
1900
|
+
async reference(png, span) {
|
|
1901
|
+
if (!this.media)
|
|
1902
|
+
return "[screenshot not uploaded: GATEWAY_HOST / GATEWAY_PUBLIC_KEY / GATEWAY_SECRET_KEY unset]";
|
|
1903
|
+
if (this.failures >= MAX_UPLOAD_FAILURES)
|
|
1904
|
+
return "[screenshot not uploaded: uploads disabled after repeated failures]";
|
|
1905
|
+
const { traceId, spanId } = span.spanContext();
|
|
1906
|
+
try {
|
|
1907
|
+
const reference = await this.media.upload(png, {
|
|
1908
|
+
contentType: "image/png",
|
|
1909
|
+
traceId,
|
|
1910
|
+
observationId: spanId,
|
|
1911
|
+
field: "output"
|
|
1912
|
+
});
|
|
1913
|
+
this.failures = 0;
|
|
1914
|
+
return reference.toString();
|
|
1915
|
+
} catch (error) {
|
|
1916
|
+
return this.failed(error);
|
|
1917
|
+
}
|
|
1918
|
+
}
|
|
1919
|
+
failed(error) {
|
|
1920
|
+
this.failures += 1;
|
|
1921
|
+
if (!this.warned) {
|
|
1922
|
+
this.warned = true;
|
|
1923
|
+
this.warn(
|
|
1924
|
+
`native computer: screenshot upload failed (${errorName(error)}: ${error instanceof Error ? error.message : String(error)}); spans keep going without it`
|
|
1925
|
+
);
|
|
1926
|
+
}
|
|
1927
|
+
return `[screenshot not uploaded: ${errorName(error)}]`;
|
|
1928
|
+
}
|
|
1929
|
+
};
|
|
1930
|
+
}
|
|
1931
|
+
});
|
|
1932
|
+
|
|
1933
|
+
// src/worlds/nativeComputer/base.ts
|
|
1934
|
+
function readField(item, ...names) {
|
|
1935
|
+
const record = item ?? {};
|
|
1936
|
+
return names.map((name) => record[name]).find((value) => value !== void 0 && value !== null);
|
|
1937
|
+
}
|
|
1938
|
+
var REPLAYABLE, SETTLING, EVENT_PREFIX, NativeComputer;
|
|
1939
|
+
var init_base = __esm({
|
|
1940
|
+
"src/worlds/nativeComputer/base.ts"() {
|
|
1941
|
+
"use strict";
|
|
1942
|
+
init_browser();
|
|
1943
|
+
init_actions();
|
|
1944
|
+
init_display();
|
|
1945
|
+
init_screen();
|
|
1946
|
+
init_trace();
|
|
1947
|
+
REPLAYABLE = /* @__PURE__ */ new Set(["screenshot", "zoom", "cursor_position", "wait"]);
|
|
1948
|
+
SETTLING = /* @__PURE__ */ new Set(["click", "mouse_up", "drag", "key", "history"]);
|
|
1949
|
+
EVENT_PREFIX = "computer_";
|
|
1950
|
+
NativeComputer = class _NativeComputer {
|
|
1951
|
+
constructor(browser, options = {}) {
|
|
1952
|
+
this.browser = browser;
|
|
1953
|
+
const kind = this.constructor;
|
|
1954
|
+
this.display = Display.forViewport(
|
|
1955
|
+
browser.viewport,
|
|
1956
|
+
options.display,
|
|
1957
|
+
(w, h) => kind.fits(w, h)
|
|
1958
|
+
);
|
|
1959
|
+
this.screen = new Screen(browser, this.display);
|
|
1960
|
+
this.tracer = options.tracer ?? ActionTracer.fromEnv();
|
|
1961
|
+
}
|
|
1962
|
+
browser;
|
|
1963
|
+
static kinds = /* @__PURE__ */ new Map();
|
|
1964
|
+
display;
|
|
1965
|
+
screen;
|
|
1966
|
+
tracer;
|
|
1967
|
+
queue = Promise.resolve();
|
|
1968
|
+
static register(provider, kind) {
|
|
1969
|
+
_NativeComputer.kinds.set(provider, kind);
|
|
1970
|
+
}
|
|
1971
|
+
static get providers() {
|
|
1972
|
+
return [..._NativeComputer.kinds.keys()].sort();
|
|
1973
|
+
}
|
|
1974
|
+
static forProvider(provider, browser, options = {}) {
|
|
1975
|
+
const Kind = _NativeComputer.kinds.get(provider);
|
|
1976
|
+
if (!Kind)
|
|
1977
|
+
throw new Error(
|
|
1978
|
+
`unknown computer-use provider '${provider}'; choose from ${_NativeComputer.providers.join(", ")}`
|
|
1979
|
+
);
|
|
1980
|
+
return new Kind(browser, options);
|
|
1981
|
+
}
|
|
1982
|
+
/** Whether a screenshot of this size is within the provider's limits. */
|
|
1983
|
+
static fits(_width, _height) {
|
|
1984
|
+
return true;
|
|
1985
|
+
}
|
|
1986
|
+
/** Run one provider-shaped action (an OpenAI action object, or an Anthropic
|
|
1987
|
+
* `{ action: "left_click", ... }` input) and return what it produced: the
|
|
1988
|
+
* door for any agent framework that hands actions over one at a time. */
|
|
1989
|
+
executeAction(raw) {
|
|
1990
|
+
return this.perform(this.parse(raw));
|
|
1991
|
+
}
|
|
1992
|
+
/** Run one action on the page: reported on the session's browser timeline
|
|
1993
|
+
* and, when tracing is on, as a span with the screen after. */
|
|
1994
|
+
async perform(action) {
|
|
1995
|
+
const secret = action.name === "type" && await this.screen.focusedFieldIsSecret();
|
|
1996
|
+
const event = EVENT_PREFIX + action.name;
|
|
1997
|
+
const args = redactActionArgs(event, action.recordArgs(secret));
|
|
1998
|
+
return this.tracer.span(
|
|
1999
|
+
action,
|
|
2000
|
+
args,
|
|
2001
|
+
() => this.browser.act(
|
|
2002
|
+
event,
|
|
2003
|
+
args,
|
|
2004
|
+
() => this.runOnScreen(action),
|
|
2005
|
+
this.onLoss(action)
|
|
2006
|
+
),
|
|
2007
|
+
() => this.screen.screenshot(),
|
|
2008
|
+
(text2) => this.browser.scrub(text2)
|
|
2009
|
+
);
|
|
2010
|
+
}
|
|
2011
|
+
async performAll(actions) {
|
|
2012
|
+
const results = [];
|
|
2013
|
+
for (const action of actions) results.push(await this.perform(action));
|
|
2014
|
+
return results;
|
|
2015
|
+
}
|
|
2016
|
+
/** The screen as the model sees it, as a traced `screenshot` action. */
|
|
2017
|
+
async screenshot() {
|
|
2018
|
+
return (await this.perform(new ComputerAction("screenshot"))).image ?? Buffer.alloc(0);
|
|
2019
|
+
}
|
|
2020
|
+
/** Run `fn` after every earlier call made through here: the AI SDK starts a
|
|
2021
|
+
* step's tool calls concurrently, but one screen takes one action at a time. */
|
|
2022
|
+
serial(fn) {
|
|
2023
|
+
const next = this.queue.then(fn, fn);
|
|
2024
|
+
this.queue = next.catch(() => void 0);
|
|
2025
|
+
return next;
|
|
2026
|
+
}
|
|
2027
|
+
async runOnScreen(action) {
|
|
2028
|
+
const result = await this.screen.run(action);
|
|
2029
|
+
if (SETTLING.has(action.name)) await this.browser.settle();
|
|
2030
|
+
return result;
|
|
2031
|
+
}
|
|
2032
|
+
onLoss(action) {
|
|
2033
|
+
return REPLAYABLE.has(action.name) ? "retry" : "report";
|
|
2034
|
+
}
|
|
2035
|
+
};
|
|
2036
|
+
}
|
|
2037
|
+
});
|
|
2038
|
+
|
|
2039
|
+
// src/worlds/nativeComputer/keys.ts
|
|
2040
|
+
function playwrightKey(token) {
|
|
2041
|
+
return KEY_NAMES[token.toLowerCase()] ?? token;
|
|
2042
|
+
}
|
|
2043
|
+
function letterOrName(key2) {
|
|
2044
|
+
return /^[a-zA-Z]$/.test(key2) ? key2.toLowerCase() : playwrightKey(key2);
|
|
2045
|
+
}
|
|
2046
|
+
function modifierChord(text2) {
|
|
2047
|
+
return typeof text2 === "string" && text2 ? [...KeyChord.fromXdotool(text2).keys] : [];
|
|
2048
|
+
}
|
|
2049
|
+
function modifierKeys(keys) {
|
|
2050
|
+
return Array.isArray(keys) && keys.length > 0 ? [...KeyChord.fromKeys(keys.map(String)).keys] : [];
|
|
2051
|
+
}
|
|
2052
|
+
var F_KEYS, KEY_NAMES, KeyChord;
|
|
2053
|
+
var init_keys = __esm({
|
|
2054
|
+
"src/worlds/nativeComputer/keys.ts"() {
|
|
2055
|
+
"use strict";
|
|
2056
|
+
F_KEYS = Object.fromEntries(
|
|
2057
|
+
Array.from({ length: 12 }, (_, i) => [`f${i + 1}`, `F${i + 1}`])
|
|
2058
|
+
);
|
|
2059
|
+
KEY_NAMES = {
|
|
2060
|
+
return: "Enter",
|
|
2061
|
+
enter: "Enter",
|
|
2062
|
+
kp_enter: "Enter",
|
|
2063
|
+
esc: "Escape",
|
|
2064
|
+
escape: "Escape",
|
|
2065
|
+
tab: "Tab",
|
|
2066
|
+
space: "Space",
|
|
2067
|
+
backspace: "Backspace",
|
|
2068
|
+
delete: "Delete",
|
|
2069
|
+
del: "Delete",
|
|
2070
|
+
insert: "Insert",
|
|
2071
|
+
home: "Home",
|
|
2072
|
+
end: "End",
|
|
2073
|
+
pageup: "PageUp",
|
|
2074
|
+
page_up: "PageUp",
|
|
2075
|
+
prior: "PageUp",
|
|
2076
|
+
pagedown: "PageDown",
|
|
2077
|
+
page_down: "PageDown",
|
|
2078
|
+
next: "PageDown",
|
|
2079
|
+
up: "ArrowUp",
|
|
2080
|
+
arrowup: "ArrowUp",
|
|
2081
|
+
down: "ArrowDown",
|
|
2082
|
+
arrowdown: "ArrowDown",
|
|
2083
|
+
left: "ArrowLeft",
|
|
2084
|
+
arrowleft: "ArrowLeft",
|
|
2085
|
+
right: "ArrowRight",
|
|
2086
|
+
arrowright: "ArrowRight",
|
|
2087
|
+
ctrl: "Control",
|
|
2088
|
+
control: "Control",
|
|
2089
|
+
shift: "Shift",
|
|
2090
|
+
alt: "Alt",
|
|
2091
|
+
option: "Alt",
|
|
2092
|
+
super: "Meta",
|
|
2093
|
+
meta: "Meta",
|
|
2094
|
+
cmd: "Meta",
|
|
2095
|
+
command: "Meta",
|
|
2096
|
+
win: "Meta",
|
|
2097
|
+
capslock: "CapsLock",
|
|
2098
|
+
caps_lock: "CapsLock",
|
|
2099
|
+
plus: "+",
|
|
2100
|
+
minus: "-",
|
|
2101
|
+
...F_KEYS
|
|
2102
|
+
};
|
|
2103
|
+
KeyChord = class _KeyChord {
|
|
2104
|
+
constructor(keys) {
|
|
2105
|
+
this.keys = keys;
|
|
2106
|
+
if (keys.length === 0)
|
|
2107
|
+
throw new Error("a key action needs at least one key");
|
|
2108
|
+
}
|
|
2109
|
+
keys;
|
|
2110
|
+
/** `ctrl+shift+t` / `Return`: Anthropic's vocabulary, case kept. */
|
|
2111
|
+
static fromXdotool(text2) {
|
|
2112
|
+
return new _KeyChord(
|
|
2113
|
+
text2.trim().split("+").filter(Boolean).map(playwrightKey)
|
|
2114
|
+
);
|
|
2115
|
+
}
|
|
2116
|
+
/** `["CTRL", "A"]`: OpenAI's vocabulary. A lone letter is the unshifted key. */
|
|
2117
|
+
static fromKeys(keys) {
|
|
2118
|
+
return new _KeyChord(keys.map(letterOrName));
|
|
2119
|
+
}
|
|
2120
|
+
/** What `page.keyboard.press` takes: `Control+a`. */
|
|
2121
|
+
get combo() {
|
|
2122
|
+
return this.keys.join("+");
|
|
2123
|
+
}
|
|
2124
|
+
};
|
|
2125
|
+
}
|
|
2126
|
+
});
|
|
2127
|
+
|
|
2128
|
+
// src/worlds/nativeComputer/anthropic.ts
|
|
2129
|
+
function required(raw, key2) {
|
|
2130
|
+
const value = raw[key2];
|
|
2131
|
+
if (value === void 0 || value === null)
|
|
2132
|
+
throw new Error(`${String(raw.action)} needs ${key2}`);
|
|
2133
|
+
return value;
|
|
2134
|
+
}
|
|
2135
|
+
function pair(raw, key2) {
|
|
2136
|
+
const value = required(raw, key2);
|
|
2137
|
+
return [toInt(value[0]), toInt(value[1])];
|
|
2138
|
+
}
|
|
2139
|
+
function point(raw) {
|
|
2140
|
+
if (raw.coordinate === void 0 || raw.coordinate === null) return {};
|
|
2141
|
+
const [x, y] = pair(raw, "coordinate");
|
|
2142
|
+
return { x, y };
|
|
2143
|
+
}
|
|
2144
|
+
function chord(raw) {
|
|
2145
|
+
return [...KeyChord.fromXdotool(String(required(raw, "text"))).keys];
|
|
2146
|
+
}
|
|
2147
|
+
function click(button, count) {
|
|
2148
|
+
return (raw) => new ComputerAction("click", {
|
|
2149
|
+
...point(raw),
|
|
2150
|
+
button,
|
|
2151
|
+
count,
|
|
2152
|
+
modifiers: modifierChord(raw.text)
|
|
2153
|
+
});
|
|
2154
|
+
}
|
|
2155
|
+
var SCROLL_STEP_PX, NOT_EXECUTED, MAX_ERROR2, SCROLL_DIRECTIONS, MEMBERS, AnthropicComputer, AnthropicComputer20251124;
|
|
2156
|
+
var init_anthropic = __esm({
|
|
2157
|
+
"src/worlds/nativeComputer/anthropic.ts"() {
|
|
2158
|
+
"use strict";
|
|
2159
|
+
init_actions();
|
|
2160
|
+
init_base();
|
|
2161
|
+
init_keys();
|
|
2162
|
+
SCROLL_STEP_PX = 100;
|
|
2163
|
+
NOT_EXECUTED = "Not executed: an earlier computer action in this turn failed.";
|
|
2164
|
+
MAX_ERROR2 = 1e3;
|
|
2165
|
+
SCROLL_DIRECTIONS = {
|
|
2166
|
+
up: [0, -1],
|
|
2167
|
+
down: [0, 1],
|
|
2168
|
+
left: [-1, 0],
|
|
2169
|
+
right: [1, 0]
|
|
2170
|
+
};
|
|
2171
|
+
MEMBERS = {
|
|
2172
|
+
screenshot: () => new ComputerAction("screenshot"),
|
|
2173
|
+
zoom: (raw) => new ComputerAction("zoom", {
|
|
2174
|
+
region: required(raw, "region").map(toInt)
|
|
2175
|
+
}),
|
|
2176
|
+
left_click: click("left", 1),
|
|
2177
|
+
right_click: click("right", 1),
|
|
2178
|
+
middle_click: click("middle", 1),
|
|
2179
|
+
double_click: click("left", 2),
|
|
2180
|
+
triple_click: click("left", 3),
|
|
2181
|
+
left_click_drag: (raw) => new ComputerAction("drag", {
|
|
2182
|
+
path: [pair(raw, "start_coordinate"), pair(raw, "coordinate")],
|
|
2183
|
+
modifiers: modifierChord(raw.text)
|
|
2184
|
+
}),
|
|
2185
|
+
mouse_move: (raw) => {
|
|
2186
|
+
const [x, y] = pair(raw, "coordinate");
|
|
2187
|
+
return new ComputerAction("move", { x, y });
|
|
2188
|
+
},
|
|
2189
|
+
left_mouse_down: () => new ComputerAction("mouse_down", { button: "left" }),
|
|
2190
|
+
left_mouse_up: () => new ComputerAction("mouse_up", { button: "left" }),
|
|
2191
|
+
cursor_position: () => new ComputerAction("cursor_position"),
|
|
2192
|
+
scroll: (raw) => {
|
|
2193
|
+
const direction = String(raw.scroll_direction ?? "down");
|
|
2194
|
+
if (!Object.hasOwn(SCROLL_DIRECTIONS, direction))
|
|
2195
|
+
throw new Error(
|
|
2196
|
+
`scroll_direction must be one of ${Object.keys(SCROLL_DIRECTIONS).join(", ")}`
|
|
2197
|
+
);
|
|
2198
|
+
const [dx, dy] = SCROLL_DIRECTIONS[direction];
|
|
2199
|
+
const amount = toInt(raw.scroll_amount ?? 1) * SCROLL_STEP_PX;
|
|
2200
|
+
return new ComputerAction("scroll", {
|
|
2201
|
+
...point(raw),
|
|
2202
|
+
dx: dx * amount,
|
|
2203
|
+
dy: dy * amount,
|
|
2204
|
+
modifiers: modifierChord(raw.text)
|
|
2205
|
+
});
|
|
2206
|
+
},
|
|
2207
|
+
type: (raw) => new ComputerAction("type", { text: String(required(raw, "text")) }),
|
|
2208
|
+
key: (raw) => new ComputerAction("key", {
|
|
2209
|
+
keys: chord(raw),
|
|
2210
|
+
repeat: toInt(raw.repeat ?? 1)
|
|
2211
|
+
}),
|
|
2212
|
+
hold_key: (raw) => new ComputerAction("hold_key", {
|
|
2213
|
+
keys: chord(raw),
|
|
2214
|
+
seconds: toNumber(required(raw, "duration"))
|
|
2215
|
+
}),
|
|
2216
|
+
wait: (raw) => new ComputerAction("wait", { seconds: toNumber(raw.duration ?? 1) })
|
|
2217
|
+
};
|
|
2218
|
+
AnthropicComputer = class _AnthropicComputer extends NativeComputer {
|
|
2219
|
+
static TOOL_TYPE = "computer_toolset_20260801";
|
|
2220
|
+
static TOOLSET = "computer";
|
|
2221
|
+
static BETA = null;
|
|
2222
|
+
static MAX_LONG_EDGE = 2576;
|
|
2223
|
+
static MAX_VISUAL_TOKENS = 4784;
|
|
2224
|
+
static PATCH_PX = 28;
|
|
2225
|
+
static fits(width, height) {
|
|
2226
|
+
const tokens = Math.ceil(width / this.PATCH_PX) * Math.ceil(height / this.PATCH_PX);
|
|
2227
|
+
return Math.max(width, height) <= this.MAX_LONG_EDGE && tokens <= this.MAX_VISUAL_TOKENS;
|
|
2228
|
+
}
|
|
2229
|
+
tool() {
|
|
2230
|
+
return { type: _AnthropicComputer.TOOL_TYPE };
|
|
2231
|
+
}
|
|
2232
|
+
/** Whether a content block is a call to this computer. */
|
|
2233
|
+
owns(block) {
|
|
2234
|
+
return readField(block, "type") === "tool_use" && readField(block, "toolset_name") === _AnthropicComputer.TOOLSET;
|
|
2235
|
+
}
|
|
2236
|
+
member(block) {
|
|
2237
|
+
return [
|
|
2238
|
+
String(readField(block, "name")),
|
|
2239
|
+
{ ...readField(block, "input") ?? {} }
|
|
2240
|
+
];
|
|
2241
|
+
}
|
|
2242
|
+
parse(raw) {
|
|
2243
|
+
const name = String(readField(raw, "action"));
|
|
2244
|
+
const parser = Object.hasOwn(MEMBERS, name) ? MEMBERS[name] : void 0;
|
|
2245
|
+
if (!parser) throw new Error(`unknown computer action: ${name}`);
|
|
2246
|
+
return parser(raw);
|
|
2247
|
+
}
|
|
2248
|
+
/** Run every computer `tool_use` in a response's content, in order, and
|
|
2249
|
+
* return one `tool_result` per block. Other blocks are skipped. */
|
|
2250
|
+
async execute(content) {
|
|
2251
|
+
const results = [];
|
|
2252
|
+
let failed = false;
|
|
2253
|
+
for (const block of content) {
|
|
2254
|
+
if (!this.owns(block)) continue;
|
|
2255
|
+
if (failed) {
|
|
2256
|
+
results.push(this.envelope(block, NOT_EXECUTED, true));
|
|
2257
|
+
continue;
|
|
2258
|
+
}
|
|
2259
|
+
const [result, blockFailed] = await this.runBlock(block);
|
|
2260
|
+
results.push(result);
|
|
2261
|
+
failed = blockFailed;
|
|
2262
|
+
}
|
|
2263
|
+
return results;
|
|
2264
|
+
}
|
|
2265
|
+
/** The content an `ActionResult` goes back to the model as. */
|
|
2266
|
+
static content(result) {
|
|
2267
|
+
if (result.image)
|
|
2268
|
+
return [
|
|
2269
|
+
{
|
|
2270
|
+
type: "image",
|
|
2271
|
+
source: {
|
|
2272
|
+
type: "base64",
|
|
2273
|
+
media_type: "image/png",
|
|
2274
|
+
data: result.image.toString("base64")
|
|
2275
|
+
}
|
|
2276
|
+
}
|
|
2277
|
+
];
|
|
2278
|
+
return [{ type: "text", text: result.text ?? "OK" }];
|
|
2279
|
+
}
|
|
2280
|
+
/** For `anthropic.tools.computerToolset_20260801({ ...computer.aiSdk() })`
|
|
2281
|
+
* (or `computer_20251124` with the legacy kind): `execute` runs one action
|
|
2282
|
+
* and returns `{ type: "image", data }` or text; `toModelOutput` turns that
|
|
2283
|
+
* into the tool result. Calls run one at a time, and once a call fails the
|
|
2284
|
+
* rest of that step's calls answer as not executed. */
|
|
2285
|
+
aiSdk() {
|
|
2286
|
+
let failedStep;
|
|
2287
|
+
const execute = (input, options) => this.serial(async () => {
|
|
2288
|
+
const step = options?.messages?.length;
|
|
2289
|
+
if (step !== void 0 && step === failedStep)
|
|
2290
|
+
throw new Error(NOT_EXECUTED);
|
|
2291
|
+
try {
|
|
2292
|
+
return _AnthropicComputer.aiSdkOutput(await this.executeAction(input));
|
|
2293
|
+
} catch (error) {
|
|
2294
|
+
failedStep = step;
|
|
2295
|
+
throw error instanceof Error ? new Error(this.browser.scrub(error.message)) : error;
|
|
2296
|
+
}
|
|
2297
|
+
});
|
|
2298
|
+
return {
|
|
2299
|
+
execute,
|
|
2300
|
+
toModelOutput: ({ output }) => _AnthropicComputer.aiSdkModelOutput(output)
|
|
2301
|
+
};
|
|
2302
|
+
}
|
|
2303
|
+
static aiSdkOutput(result) {
|
|
2304
|
+
if (result.image)
|
|
2305
|
+
return { type: "image", data: result.image.toString("base64") };
|
|
2306
|
+
return result.text ?? "OK";
|
|
2307
|
+
}
|
|
2308
|
+
/** `image-data` is what AI SDK 6's Anthropic provider turns into an image
|
|
2309
|
+
* block; AI SDK 7 still accepts it (and converts it to a `file` part). */
|
|
2310
|
+
static aiSdkModelOutput(output) {
|
|
2311
|
+
if (typeof output === "string") return { type: "text", value: output };
|
|
2312
|
+
return {
|
|
2313
|
+
type: "content",
|
|
2314
|
+
value: [
|
|
2315
|
+
{ type: "image-data", data: output.data, mediaType: "image/png" }
|
|
2316
|
+
]
|
|
2317
|
+
};
|
|
2318
|
+
}
|
|
2319
|
+
envelope(block, content, isError = false) {
|
|
2320
|
+
return {
|
|
2321
|
+
type: "tool_result",
|
|
2322
|
+
tool_use_id: String(readField(block, "id")),
|
|
2323
|
+
toolset_name: _AnthropicComputer.TOOLSET,
|
|
2324
|
+
content,
|
|
2325
|
+
...isError ? { is_error: true } : {}
|
|
2326
|
+
};
|
|
2327
|
+
}
|
|
2328
|
+
async runBlock(block) {
|
|
2329
|
+
const [name, payload] = this.member(block);
|
|
2330
|
+
try {
|
|
2331
|
+
const result = await this.executeAction({ ...payload, action: name });
|
|
2332
|
+
return [this.envelope(block, _AnthropicComputer.content(result)), false];
|
|
2333
|
+
} catch (error) {
|
|
2334
|
+
const detail = error instanceof Error ? `${error.name}: ${error.message}` : String(error);
|
|
2335
|
+
return [
|
|
2336
|
+
this.envelope(
|
|
2337
|
+
block,
|
|
2338
|
+
this.browser.scrub(`Error: ${detail}`).slice(0, MAX_ERROR2),
|
|
2339
|
+
true
|
|
2340
|
+
),
|
|
2341
|
+
true
|
|
2342
|
+
];
|
|
2343
|
+
}
|
|
2344
|
+
}
|
|
2345
|
+
};
|
|
2346
|
+
AnthropicComputer20251124 = class _AnthropicComputer20251124 extends AnthropicComputer {
|
|
2347
|
+
static TOOL_TYPE = "computer_20251124";
|
|
2348
|
+
static BETA = "computer-use-2025-11-24";
|
|
2349
|
+
static MAX_LONG_EDGE = 1568;
|
|
2350
|
+
static MAX_PIXELS = 115e4;
|
|
2351
|
+
static fits(width, height) {
|
|
2352
|
+
return Math.max(width, height) <= this.MAX_LONG_EDGE && width * height <= this.MAX_PIXELS;
|
|
2353
|
+
}
|
|
2354
|
+
tool() {
|
|
2355
|
+
return {
|
|
2356
|
+
type: _AnthropicComputer20251124.TOOL_TYPE,
|
|
2357
|
+
name: AnthropicComputer.TOOLSET,
|
|
2358
|
+
display_width_px: this.display.width,
|
|
2359
|
+
display_height_px: this.display.height,
|
|
2360
|
+
enable_zoom: true
|
|
2361
|
+
};
|
|
2362
|
+
}
|
|
2363
|
+
owns(block) {
|
|
2364
|
+
return readField(block, "type") === "tool_use" && readField(block, "name") === AnthropicComputer.TOOLSET;
|
|
2365
|
+
}
|
|
2366
|
+
member(block) {
|
|
2367
|
+
const { action, ...payload } = readField(block, "input") ?? {};
|
|
2368
|
+
return [String(action ?? ""), payload];
|
|
2369
|
+
}
|
|
2370
|
+
envelope(block, content, isError = false) {
|
|
2371
|
+
const { toolset_name: _dropped, ...rest } = super.envelope(
|
|
2372
|
+
block,
|
|
2373
|
+
content,
|
|
2374
|
+
isError
|
|
2375
|
+
);
|
|
2376
|
+
return rest;
|
|
2377
|
+
}
|
|
2378
|
+
};
|
|
2379
|
+
NativeComputer.register("anthropic", AnthropicComputer);
|
|
2380
|
+
NativeComputer.register(
|
|
2381
|
+
"anthropic-computer-20251124",
|
|
2382
|
+
AnthropicComputer20251124
|
|
2383
|
+
);
|
|
2384
|
+
}
|
|
2385
|
+
});
|
|
2386
|
+
|
|
2387
|
+
// src/worlds/nativeComputer/openai.ts
|
|
2388
|
+
function safetyCheck(raw) {
|
|
2389
|
+
const check = { id: String(readField(raw, "id") ?? "") };
|
|
2390
|
+
const code = readField(raw, "code");
|
|
2391
|
+
const message = readField(raw, "message");
|
|
2392
|
+
if (code !== void 0) check.code = String(code);
|
|
2393
|
+
if (message !== void 0) check.message = String(message);
|
|
2394
|
+
return check;
|
|
2395
|
+
}
|
|
2396
|
+
function dataUrl(png) {
|
|
2397
|
+
return `data:image/png;base64,${png.toString("base64")}`;
|
|
2398
|
+
}
|
|
2399
|
+
function xy(raw) {
|
|
2400
|
+
return {
|
|
2401
|
+
x: toInt(readField(raw, "x") ?? 0),
|
|
2402
|
+
y: toInt(readField(raw, "y") ?? 0)
|
|
2403
|
+
};
|
|
2404
|
+
}
|
|
2405
|
+
function held(raw) {
|
|
2406
|
+
return modifierKeys(readField(raw, "keys"));
|
|
2407
|
+
}
|
|
2408
|
+
var WAIT_SECONDS, BUTTONS, HISTORY_BUTTONS, PendingSafetyChecks, ACTIONS, OpenAIComputer, OpenAIPreviewComputer;
|
|
2409
|
+
var init_openai = __esm({
|
|
2410
|
+
"src/worlds/nativeComputer/openai.ts"() {
|
|
2411
|
+
"use strict";
|
|
2412
|
+
init_actions();
|
|
2413
|
+
init_base();
|
|
2414
|
+
init_keys();
|
|
2415
|
+
WAIT_SECONDS = 1;
|
|
2416
|
+
BUTTONS = {
|
|
2417
|
+
left: "left",
|
|
2418
|
+
right: "right",
|
|
2419
|
+
wheel: "middle",
|
|
2420
|
+
middle: "middle"
|
|
2421
|
+
};
|
|
2422
|
+
HISTORY_BUTTONS = /* @__PURE__ */ new Set(["back", "forward"]);
|
|
2423
|
+
PendingSafetyChecks = class extends Error {
|
|
2424
|
+
constructor(callId, checks) {
|
|
2425
|
+
const listed = checks.map((c) => `${c.code ?? "check"}: ${c.message ?? ""}`.trim()).join("; ");
|
|
2426
|
+
super(
|
|
2427
|
+
`computer_call ${callId} needs ${checks.length} safety check(s) acknowledged: ${listed}`
|
|
2428
|
+
);
|
|
2429
|
+
this.callId = callId;
|
|
2430
|
+
this.checks = checks;
|
|
2431
|
+
this.name = "PendingSafetyChecks";
|
|
2432
|
+
}
|
|
2433
|
+
callId;
|
|
2434
|
+
checks;
|
|
2435
|
+
};
|
|
2436
|
+
ACTIONS = {
|
|
2437
|
+
click: (raw) => {
|
|
2438
|
+
const button = String(readField(raw, "button") ?? "left");
|
|
2439
|
+
if (HISTORY_BUTTONS.has(button))
|
|
2440
|
+
return new ComputerAction("history", {
|
|
2441
|
+
direction: button
|
|
2442
|
+
});
|
|
2443
|
+
if (!Object.hasOwn(BUTTONS, button))
|
|
2444
|
+
throw new Error(`unknown mouse button: ${button}`);
|
|
2445
|
+
return new ComputerAction("click", {
|
|
2446
|
+
...xy(raw),
|
|
2447
|
+
button: BUTTONS[button],
|
|
2448
|
+
count: 1,
|
|
2449
|
+
modifiers: held(raw)
|
|
2450
|
+
});
|
|
2451
|
+
},
|
|
2452
|
+
double_click: (raw) => new ComputerAction("click", {
|
|
2453
|
+
...xy(raw),
|
|
2454
|
+
button: "left",
|
|
2455
|
+
count: 2,
|
|
2456
|
+
modifiers: held(raw)
|
|
2457
|
+
}),
|
|
2458
|
+
drag: (raw) => new ComputerAction("drag", {
|
|
2459
|
+
path: (readField(raw, "path") ?? []).map(
|
|
2460
|
+
(p) => [toInt(readField(p, "x")), toInt(readField(p, "y"))]
|
|
2461
|
+
),
|
|
2462
|
+
modifiers: held(raw)
|
|
2463
|
+
}),
|
|
2464
|
+
keypress: (raw) => new ComputerAction("key", {
|
|
2465
|
+
keys: [
|
|
2466
|
+
...KeyChord.fromKeys(readField(raw, "keys") ?? []).keys
|
|
2467
|
+
],
|
|
2468
|
+
repeat: 1
|
|
2469
|
+
}),
|
|
2470
|
+
move: (raw) => new ComputerAction("move", { ...xy(raw), modifiers: held(raw) }),
|
|
2471
|
+
scroll: (raw) => new ComputerAction("scroll", {
|
|
2472
|
+
...xy(raw),
|
|
2473
|
+
dx: toInt(readField(raw, "scroll_x", "scrollX") ?? 0),
|
|
2474
|
+
dy: toInt(readField(raw, "scroll_y", "scrollY") ?? 0),
|
|
2475
|
+
modifiers: held(raw)
|
|
2476
|
+
}),
|
|
2477
|
+
type: (raw) => new ComputerAction("type", { text: String(readField(raw, "text") ?? "") }),
|
|
2478
|
+
wait: () => new ComputerAction("wait", { seconds: WAIT_SECONDS }),
|
|
2479
|
+
screenshot: () => new ComputerAction("screenshot")
|
|
2480
|
+
};
|
|
2481
|
+
OpenAIComputer = class _OpenAIComputer extends NativeComputer {
|
|
2482
|
+
tool() {
|
|
2483
|
+
return { type: "computer" };
|
|
2484
|
+
}
|
|
2485
|
+
owns(item) {
|
|
2486
|
+
return readField(item, "type") === "computer_call";
|
|
2487
|
+
}
|
|
2488
|
+
parse(raw) {
|
|
2489
|
+
const kind = String(readField(raw, "type"));
|
|
2490
|
+
const parser = Object.hasOwn(ACTIONS, kind) ? ACTIONS[kind] : void 0;
|
|
2491
|
+
if (!parser) throw new Error(`unknown computer action: ${kind}`);
|
|
2492
|
+
return parser(raw);
|
|
2493
|
+
}
|
|
2494
|
+
static actionsOf(call) {
|
|
2495
|
+
const batch = readField(call, "actions");
|
|
2496
|
+
if (Array.isArray(batch)) return batch;
|
|
2497
|
+
const single = readField(call, "action");
|
|
2498
|
+
return single === void 0 ? [] : [single];
|
|
2499
|
+
}
|
|
2500
|
+
/** Run a `computer_call`'s actions and return its `computer_call_output`.
|
|
2501
|
+
* Throws `PendingSafetyChecks` (before anything runs) while a check the
|
|
2502
|
+
* model raised is not in `acknowledged`. */
|
|
2503
|
+
async execute(call, acknowledged = []) {
|
|
2504
|
+
const callId = String(readField(call, "call_id", "callId"));
|
|
2505
|
+
const checks = (readField(
|
|
2506
|
+
call,
|
|
2507
|
+
"pending_safety_checks",
|
|
2508
|
+
"pendingSafetyChecks"
|
|
2509
|
+
) ?? []).map(safetyCheck);
|
|
2510
|
+
const png = await this.runCall(
|
|
2511
|
+
callId,
|
|
2512
|
+
_OpenAIComputer.actionsOf(call),
|
|
2513
|
+
checks,
|
|
2514
|
+
acknowledged
|
|
2515
|
+
);
|
|
2516
|
+
return {
|
|
2517
|
+
type: "computer_call_output",
|
|
2518
|
+
call_id: callId,
|
|
2519
|
+
output: {
|
|
2520
|
+
type: "computer_screenshot",
|
|
2521
|
+
image_url: dataUrl(png),
|
|
2522
|
+
detail: "original"
|
|
2523
|
+
},
|
|
2524
|
+
...checks.length > 0 ? { acknowledged_safety_checks: checks } : {}
|
|
2525
|
+
};
|
|
2526
|
+
}
|
|
2527
|
+
/** For `openai.tools.computer({ ...computer.aiSdk() })`: `execute` runs a
|
|
2528
|
+
* call's `actions` and returns the screenshot output. A call with pending
|
|
2529
|
+
* safety checks asks for approval first (`needsApproval`), so the AI SDK's
|
|
2530
|
+
* approval flow puts them in front of a person; once approved, `execute`
|
|
2531
|
+
* acknowledges them. */
|
|
2532
|
+
aiSdk() {
|
|
2533
|
+
return {
|
|
2534
|
+
needsApproval: (input) => (input.pendingSafetyChecks ?? []).length > 0,
|
|
2535
|
+
execute: (input) => this.serial(async () => {
|
|
2536
|
+
const checks = (input.pendingSafetyChecks ?? []).map(safetyCheck);
|
|
2537
|
+
const png = await this.runCall(
|
|
2538
|
+
"ai-sdk",
|
|
2539
|
+
input.actions ?? [],
|
|
2540
|
+
checks,
|
|
2541
|
+
checks
|
|
2542
|
+
);
|
|
2543
|
+
return {
|
|
2544
|
+
output: { type: "computer_screenshot", imageUrl: dataUrl(png) },
|
|
2545
|
+
...checks.length > 0 ? { acknowledgedSafetyChecks: checks } : {}
|
|
2546
|
+
};
|
|
2547
|
+
})
|
|
2548
|
+
};
|
|
2549
|
+
}
|
|
2550
|
+
/** The batch's actions, run after the safety checks clear; the screen after them. */
|
|
2551
|
+
async runCall(callId, rawActions, checks, acknowledged) {
|
|
2552
|
+
const cleared = new Set(acknowledged.map((c) => safetyCheck(c).id));
|
|
2553
|
+
const waiting = checks.filter((c) => !c.id || !cleared.has(c.id));
|
|
2554
|
+
if (waiting.length > 0) throw new PendingSafetyChecks(callId, waiting);
|
|
2555
|
+
const actions = rawActions.map((raw) => this.parse(raw));
|
|
2556
|
+
const results = await this.performAll(actions);
|
|
2557
|
+
const last = actions.at(-1);
|
|
2558
|
+
if (last?.name === "screenshot")
|
|
2559
|
+
return results.at(-1)?.image ?? Buffer.alloc(0);
|
|
2560
|
+
return this.screenshot();
|
|
2561
|
+
}
|
|
2562
|
+
};
|
|
2563
|
+
OpenAIPreviewComputer = class extends OpenAIComputer {
|
|
2564
|
+
tool() {
|
|
2565
|
+
return {
|
|
2566
|
+
type: "computer_use_preview",
|
|
2567
|
+
display_width: this.display.width,
|
|
2568
|
+
display_height: this.display.height,
|
|
2569
|
+
environment: "browser"
|
|
2570
|
+
};
|
|
2571
|
+
}
|
|
2572
|
+
};
|
|
2573
|
+
NativeComputer.register("openai", OpenAIComputer);
|
|
2574
|
+
NativeComputer.register("openai-preview", OpenAIPreviewComputer);
|
|
2575
|
+
}
|
|
2576
|
+
});
|
|
2577
|
+
|
|
2578
|
+
// src/worlds/nativeComputer/index.ts
|
|
2579
|
+
var init_nativeComputer = __esm({
|
|
2580
|
+
"src/worlds/nativeComputer/index.ts"() {
|
|
2581
|
+
"use strict";
|
|
2582
|
+
init_actions();
|
|
2583
|
+
init_base();
|
|
2584
|
+
init_display();
|
|
2585
|
+
init_keys();
|
|
2586
|
+
init_screen();
|
|
2587
|
+
init_trace();
|
|
2588
|
+
init_anthropic();
|
|
2589
|
+
init_openai();
|
|
2590
|
+
}
|
|
2591
|
+
});
|
|
2592
|
+
|
|
1217
2593
|
// src/worlds/sessionContract.ts
|
|
1218
2594
|
function serializeCallBody(body) {
|
|
1219
2595
|
const text2 = JSON.stringify(body);
|
|
@@ -1267,6 +2643,75 @@ var init_sessionContract = __esm({
|
|
|
1267
2643
|
}
|
|
1268
2644
|
});
|
|
1269
2645
|
|
|
2646
|
+
// src/tracing/session.ts
|
|
2647
|
+
var session_exports = {};
|
|
2648
|
+
__export(session_exports, {
|
|
2649
|
+
SESSION_ID_ATTRIBUTE: () => SESSION_ID_ATTRIBUTE,
|
|
2650
|
+
SessionSpanProcessor: () => SessionSpanProcessor,
|
|
2651
|
+
WORLD_SESSION_ID_ATTRIBUTE: () => WORLD_SESSION_ID_ATTRIBUTE,
|
|
2652
|
+
getAmbientSessionId: () => getAmbientSessionId,
|
|
2653
|
+
getCurrentWorldSessionId: () => getCurrentWorldSessionId,
|
|
2654
|
+
withSession: () => withSession,
|
|
2655
|
+
withWorldSession: () => withWorldSession
|
|
2656
|
+
});
|
|
2657
|
+
function getAmbientSessionId() {
|
|
2658
|
+
return currentSessionStorage.getStore();
|
|
2659
|
+
}
|
|
2660
|
+
function getCurrentWorldSessionId() {
|
|
2661
|
+
return currentWorldSessionStorage.getStore();
|
|
2662
|
+
}
|
|
2663
|
+
function runIn(storage, value, fn) {
|
|
2664
|
+
return new Promise((resolve11, reject) => {
|
|
2665
|
+
storage.run(value, () => {
|
|
2666
|
+
Promise.resolve().then(fn).then(resolve11, reject);
|
|
2667
|
+
});
|
|
2668
|
+
});
|
|
2669
|
+
}
|
|
2670
|
+
function withSession(sessionId, fn) {
|
|
2671
|
+
return runIn(currentSessionStorage, sessionId, fn);
|
|
2672
|
+
}
|
|
2673
|
+
function withWorldSession(worldSessionId, fn) {
|
|
2674
|
+
return runIn(
|
|
2675
|
+
currentWorldSessionStorage,
|
|
2676
|
+
worldSessionId,
|
|
2677
|
+
() => withSession(worldSessionId, fn)
|
|
2678
|
+
);
|
|
2679
|
+
}
|
|
2680
|
+
var import_async_hooks2, SESSION_ID_ATTRIBUTE, WORLD_SESSION_ID_ATTRIBUTE, processStorage, currentSessionStorage, currentWorldSessionStorage, SessionSpanProcessor;
|
|
2681
|
+
var init_session = __esm({
|
|
2682
|
+
"src/tracing/session.ts"() {
|
|
2683
|
+
"use strict";
|
|
2684
|
+
import_async_hooks2 = require("async_hooks");
|
|
2685
|
+
SESSION_ID_ATTRIBUTE = "gateway.session.id";
|
|
2686
|
+
WORLD_SESSION_ID_ATTRIBUTE = "gateway.trace.metadata.world_session_id";
|
|
2687
|
+
processStorage = (name) => {
|
|
2688
|
+
const key2 = /* @__PURE__ */ Symbol.for(`@withgateway/sdk/${name}`);
|
|
2689
|
+
const slots = globalThis;
|
|
2690
|
+
slots[key2] ??= new import_async_hooks2.AsyncLocalStorage();
|
|
2691
|
+
return slots[key2];
|
|
2692
|
+
};
|
|
2693
|
+
currentSessionStorage = processStorage("session-storage");
|
|
2694
|
+
currentWorldSessionStorage = processStorage("world-session-storage");
|
|
2695
|
+
SessionSpanProcessor = class {
|
|
2696
|
+
onStart(span, _parentContext) {
|
|
2697
|
+
const worldSessionId = getCurrentWorldSessionId();
|
|
2698
|
+
if (worldSessionId)
|
|
2699
|
+
span.setAttribute(WORLD_SESSION_ID_ATTRIBUTE, worldSessionId);
|
|
2700
|
+
const sessionId = getAmbientSessionId();
|
|
2701
|
+
if (!sessionId || span.attributes?.[SESSION_ID_ATTRIBUTE] !== void 0)
|
|
2702
|
+
return;
|
|
2703
|
+
span.setAttribute(SESSION_ID_ATTRIBUTE, sessionId);
|
|
2704
|
+
}
|
|
2705
|
+
onEnd(_span) {
|
|
2706
|
+
}
|
|
2707
|
+
async shutdown() {
|
|
2708
|
+
}
|
|
2709
|
+
async forceFlush() {
|
|
2710
|
+
}
|
|
2711
|
+
};
|
|
2712
|
+
}
|
|
2713
|
+
});
|
|
2714
|
+
|
|
1270
2715
|
// src/worlds/taskRef.ts
|
|
1271
2716
|
var isTaskIdRef, isTaskSpec, taskLabel, assertTaskRef;
|
|
1272
2717
|
var init_taskRef = __esm({
|
|
@@ -1291,8 +2736,8 @@ var init_taskRef = __esm({
|
|
|
1291
2736
|
});
|
|
1292
2737
|
|
|
1293
2738
|
// src/worlds/session.ts
|
|
1294
|
-
var
|
|
1295
|
-
__export(
|
|
2739
|
+
var session_exports2 = {};
|
|
2740
|
+
__export(session_exports2, {
|
|
1296
2741
|
WorldSession: () => WorldSession,
|
|
1297
2742
|
WorldSessionCallError: () => WorldSessionCallError,
|
|
1298
2743
|
WorldSessionTimeout: () => WorldSessionTimeout,
|
|
@@ -1345,7 +2790,7 @@ function schemaFromSignature(spec) {
|
|
|
1345
2790
|
};
|
|
1346
2791
|
const inside = /\(([\s\S]*)\)\s*$/.exec(spec.signature.trim())?.[1] ?? "";
|
|
1347
2792
|
const properties = {};
|
|
1348
|
-
const
|
|
2793
|
+
const required2 = [];
|
|
1349
2794
|
const params = [];
|
|
1350
2795
|
let depth = 0;
|
|
1351
2796
|
let current = "";
|
|
@@ -1366,7 +2811,7 @@ function schemaFromSignature(spec) {
|
|
|
1366
2811
|
if (!name) continue;
|
|
1367
2812
|
if (eq === -1) {
|
|
1368
2813
|
properties[name] = { type: "string" };
|
|
1369
|
-
|
|
2814
|
+
required2.push(name);
|
|
1370
2815
|
continue;
|
|
1371
2816
|
}
|
|
1372
2817
|
const value = param.slice(eq + 1).trim();
|
|
@@ -1380,7 +2825,7 @@ function schemaFromSignature(spec) {
|
|
|
1380
2825
|
function: {
|
|
1381
2826
|
name: modelToolName(spec.name),
|
|
1382
2827
|
description: spec.doc ?? spec.name,
|
|
1383
|
-
parameters: { type: "object", properties, required }
|
|
2828
|
+
parameters: { type: "object", properties, required: required2 }
|
|
1384
2829
|
}
|
|
1385
2830
|
};
|
|
1386
2831
|
}
|
|
@@ -1449,13 +2894,16 @@ async function runSessions(opts) {
|
|
|
1449
2894
|
task = taskLabel(taskRef, session.taskInfo);
|
|
1450
2895
|
await session.ready();
|
|
1451
2896
|
const toolkit = await session.toolkit();
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
2897
|
+
const live = session;
|
|
2898
|
+
await live.withTraceContext(
|
|
2899
|
+
() => opts.agent({
|
|
2900
|
+
session: live,
|
|
2901
|
+
toolkit,
|
|
2902
|
+
instruction: live.instruction ?? (isTaskSpec(taskRef) ? taskRef.instruction : task),
|
|
2903
|
+
task,
|
|
2904
|
+
taskRef
|
|
2905
|
+
})
|
|
2906
|
+
);
|
|
1459
2907
|
const graded = await session.grade();
|
|
1460
2908
|
const result = {
|
|
1461
2909
|
task,
|
|
@@ -1492,14 +2940,16 @@ async function runSessions(opts) {
|
|
|
1492
2940
|
passed: failed === 0 && (opts.failUnder === void 0 || mean >= opts.failUnder)
|
|
1493
2941
|
};
|
|
1494
2942
|
}
|
|
1495
|
-
var
|
|
1496
|
-
var
|
|
2943
|
+
var import_node_crypto2, READY_TIMEOUT_MS, READY_POLL_MS, CALL_TIMEOUT_MS, CALL_POLL_MS, JUDGED_GRADE_TIMEOUT_MS, JUDGED_GRADE_POLL_MS, EXPORT_PAGE, sleep2, modelToolName, WorldSessionTimeout, WorldSessionCallError, WorldSession, OPEN_SESSION_OPTION_KEYS, isOpenSessionOptions;
|
|
2944
|
+
var init_session2 = __esm({
|
|
1497
2945
|
"src/worlds/session.ts"() {
|
|
1498
2946
|
"use strict";
|
|
1499
|
-
|
|
2947
|
+
import_node_crypto2 = require("crypto");
|
|
1500
2948
|
init_worlds();
|
|
1501
2949
|
init_browser();
|
|
2950
|
+
init_nativeComputer();
|
|
1502
2951
|
init_sessionContract();
|
|
2952
|
+
init_session();
|
|
1503
2953
|
init_taskRef();
|
|
1504
2954
|
init_taskRef();
|
|
1505
2955
|
READY_TIMEOUT_MS = 10 * 6e4;
|
|
@@ -1633,7 +3083,7 @@ var init_session = __esm({
|
|
|
1633
3083
|
/** The reporter `browser()` uses; exposed for a page you drive yourself. */
|
|
1634
3084
|
browserRecorder(agentId) {
|
|
1635
3085
|
const path16 = `/api/public/world-sessions/${encodeURIComponent(this.sessionId)}/browser-events`;
|
|
1636
|
-
const id = agentId ?? process.env.GATEWAY_AGENT_ID ?? `agent-${(0,
|
|
3086
|
+
const id = agentId ?? process.env.GATEWAY_AGENT_ID ?? `agent-${(0, import_node_crypto2.randomUUID)().replace(/-/g, "").slice(0, 8)}`;
|
|
1637
3087
|
return new BrowserActionRecorder(
|
|
1638
3088
|
async (events) => {
|
|
1639
3089
|
await apiRequest(this.options, "POST", path16, { events });
|
|
@@ -1653,6 +3103,12 @@ var init_session = __esm({
|
|
|
1653
3103
|
computerUseTools(browser) {
|
|
1654
3104
|
return computerUseToolkit(browser);
|
|
1655
3105
|
}
|
|
3106
|
+
/** The browser as a provider's own pixel-based computer-use tool: `anthropic`
|
|
3107
|
+
* (`computer_toolset_20260801`), `openai` (Responses `computer`),
|
|
3108
|
+
* `anthropic-computer-20251124` or `openai-preview`. See `nativeComputer/`. */
|
|
3109
|
+
nativeComputer(browser, provider = "anthropic", options = {}) {
|
|
3110
|
+
return NativeComputer.forProvider(provider, browser, options);
|
|
3111
|
+
}
|
|
1656
3112
|
/** The session's latest platform state (one request, no waiting). */
|
|
1657
3113
|
async status() {
|
|
1658
3114
|
const fresh = await apiRequest(
|
|
@@ -1887,6 +3343,21 @@ var init_session = __esm({
|
|
|
1887
3343
|
{ keepWarm: opts.keepWarm ?? false }
|
|
1888
3344
|
);
|
|
1889
3345
|
}
|
|
3346
|
+
/**
|
|
3347
|
+
* Run `fn` as work inside this session: spans it records take `sessionId`
|
|
3348
|
+
* as their session id and carry `world_session_id` trace metadata, so the
|
|
3349
|
+
* agent's traces land in the same session as the platform's traces of this
|
|
3350
|
+
* session's tool calls. A `withSession()` block inside still wins for the
|
|
3351
|
+
* session id. No effect before `tracing.init()`. `runSessions` wraps each
|
|
3352
|
+
* agent call in it.
|
|
3353
|
+
*
|
|
3354
|
+
* ```typescript
|
|
3355
|
+
* await session.withTraceContext(() => myAgent(toolkit, session.instruction));
|
|
3356
|
+
* ```
|
|
3357
|
+
*/
|
|
3358
|
+
withTraceContext(fn) {
|
|
3359
|
+
return withWorldSession(this.sessionId, fn);
|
|
3360
|
+
}
|
|
1890
3361
|
};
|
|
1891
3362
|
OPEN_SESSION_OPTION_KEYS = /* @__PURE__ */ new Set([
|
|
1892
3363
|
"task",
|
|
@@ -2036,7 +3507,11 @@ function fromResponse(answer, options) {
|
|
|
2036
3507
|
const worlds = {};
|
|
2037
3508
|
for (const [alias, state2] of Object.entries(answer.sessions)) {
|
|
2038
3509
|
sessions2[alias] = new WorldSession(state2.sessionId, state2, options);
|
|
2039
|
-
worlds[alias] = {
|
|
3510
|
+
worlds[alias] = {
|
|
3511
|
+
slug: state2.slug,
|
|
3512
|
+
ref: state2.ref,
|
|
3513
|
+
private: state2.private ?? null
|
|
3514
|
+
};
|
|
2040
3515
|
}
|
|
2041
3516
|
return new TaskSessions(
|
|
2042
3517
|
answer.taskId,
|
|
@@ -2110,6 +3585,7 @@ async function attachTask(taskId, options = {}) {
|
|
|
2110
3585
|
{
|
|
2111
3586
|
slug: row.slug ?? "",
|
|
2112
3587
|
ref: null,
|
|
3588
|
+
private: null,
|
|
2113
3589
|
versionId: row.versionId,
|
|
2114
3590
|
sessionId: row.sessionId,
|
|
2115
3591
|
ready: row.ready,
|
|
@@ -2139,7 +3615,7 @@ async function attachManifest(manifest, options = {}) {
|
|
|
2139
3615
|
Object.fromEntries(
|
|
2140
3616
|
Object.entries(manifest.sessions).map(([alias, entry]) => [
|
|
2141
3617
|
alias,
|
|
2142
|
-
{ slug: entry.slug, ref: entry.ref }
|
|
3618
|
+
{ slug: entry.slug, ref: entry.ref, private: entry.private ?? null }
|
|
2143
3619
|
])
|
|
2144
3620
|
)
|
|
2145
3621
|
);
|
|
@@ -2153,12 +3629,13 @@ var init_taskSessions = __esm({
|
|
|
2153
3629
|
"use strict";
|
|
2154
3630
|
init_worlds();
|
|
2155
3631
|
init_browser();
|
|
2156
|
-
|
|
3632
|
+
init_session2();
|
|
2157
3633
|
TASK_SESSIONS = "/api/public/world-task-sessions";
|
|
2158
3634
|
VERIFIER_REWARD_PREFIX = "x.";
|
|
2159
3635
|
manifestSession = (s, state2, world) => ({
|
|
2160
3636
|
slug: world.slug,
|
|
2161
3637
|
ref: world.ref,
|
|
3638
|
+
private: world.private,
|
|
2162
3639
|
versionId: state2.versionId,
|
|
2163
3640
|
sessionId: state2.sessionId,
|
|
2164
3641
|
ready: state2.ready,
|
|
@@ -2193,10 +3670,10 @@ var init_taskSessions = __esm({
|
|
|
2193
3670
|
sessions;
|
|
2194
3671
|
worlds;
|
|
2195
3672
|
hash;
|
|
2196
|
-
/** This alias's
|
|
2197
|
-
*
|
|
3673
|
+
/** This alias's world as recorded at open/attach — what a `TaskRun`
|
|
3674
|
+
* filing needs to name, without exposing the whole map. */
|
|
2198
3675
|
worldRef(alias) {
|
|
2199
|
-
return this.worlds[alias] ?? { slug: "", ref: null };
|
|
3676
|
+
return this.worlds[alias] ?? { slug: "", ref: null, private: null };
|
|
2200
3677
|
}
|
|
2201
3678
|
/** The aliases, in the spec's order. */
|
|
2202
3679
|
get aliases() {
|
|
@@ -2399,15 +3876,15 @@ function debugLog(message, ...args) {
|
|
|
2399
3876
|
console.debug(`[gatewaysdk.tracing] ${message}`, ...args);
|
|
2400
3877
|
}
|
|
2401
3878
|
}
|
|
2402
|
-
var
|
|
3879
|
+
var import_async_hooks3, import_api2, USER_ID_ATTRIBUTE, currentUserStorage, IdentitySpanProcessor;
|
|
2403
3880
|
var init_identity = __esm({
|
|
2404
3881
|
"src/tracing/identity.ts"() {
|
|
2405
3882
|
"use strict";
|
|
2406
|
-
|
|
3883
|
+
import_async_hooks3 = require("async_hooks");
|
|
2407
3884
|
import_api2 = require("@opentelemetry/api");
|
|
2408
3885
|
init_users();
|
|
2409
3886
|
USER_ID_ATTRIBUTE = "gateway.user.id";
|
|
2410
|
-
currentUserStorage = new
|
|
3887
|
+
currentUserStorage = new import_async_hooks3.AsyncLocalStorage();
|
|
2411
3888
|
IdentitySpanProcessor = class {
|
|
2412
3889
|
onStart(span, _parentContext) {
|
|
2413
3890
|
const userId = resolveUserId();
|
|
@@ -2425,43 +3902,224 @@ var init_identity = __esm({
|
|
|
2425
3902
|
}
|
|
2426
3903
|
});
|
|
2427
3904
|
|
|
2428
|
-
// src/tracing/
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
}
|
|
2436
|
-
|
|
2437
|
-
return
|
|
3905
|
+
// src/tracing/secrets.ts
|
|
3906
|
+
function jsonOrUndefined(text2) {
|
|
3907
|
+
let parsed;
|
|
3908
|
+
try {
|
|
3909
|
+
parsed = JSON.parse(text2);
|
|
3910
|
+
} catch {
|
|
3911
|
+
return void 0;
|
|
3912
|
+
}
|
|
3913
|
+
if (typeof parsed === "string") return parsed;
|
|
3914
|
+
return parsed !== null && typeof parsed === "object" ? parsed : void 0;
|
|
2438
3915
|
}
|
|
2439
|
-
function
|
|
2440
|
-
return
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
3916
|
+
function encodings(value) {
|
|
3917
|
+
return [value, percentEncoded(value), JSON.stringify(value).slice(1, -1)];
|
|
3918
|
+
}
|
|
3919
|
+
function percentEncoded(value) {
|
|
3920
|
+
try {
|
|
3921
|
+
return encodeURIComponent(value);
|
|
3922
|
+
} catch {
|
|
3923
|
+
return value;
|
|
3924
|
+
}
|
|
3925
|
+
}
|
|
3926
|
+
function union(sets) {
|
|
3927
|
+
return new Set(sets.flatMap((set) => [...set]));
|
|
3928
|
+
}
|
|
3929
|
+
function leaves(value) {
|
|
3930
|
+
if (typeof value === "string") {
|
|
3931
|
+
return [...value].length >= MIN_SECRET_LENGTH ? /* @__PURE__ */ new Set([value]) : /* @__PURE__ */ new Set();
|
|
3932
|
+
}
|
|
3933
|
+
if (Array.isArray(value)) return union(value.map(leaves));
|
|
3934
|
+
if (value === null || typeof value !== "object") return /* @__PURE__ */ new Set();
|
|
3935
|
+
return union(Object.values(value).map(leaves));
|
|
3936
|
+
}
|
|
3937
|
+
function sameAttributes(before, after) {
|
|
3938
|
+
const keys = Object.keys(before);
|
|
3939
|
+
if (keys.length !== Object.keys(after).length) return false;
|
|
3940
|
+
return keys.every(
|
|
3941
|
+
(key2) => before[key2] === after[key2] || sameArray(before[key2], after[key2])
|
|
3942
|
+
);
|
|
3943
|
+
}
|
|
3944
|
+
function sameArray(before, after) {
|
|
3945
|
+
if (!Array.isArray(before) || !Array.isArray(after)) return false;
|
|
3946
|
+
return before.length === after.length && before.every((item, i) => item === after[i]);
|
|
3947
|
+
}
|
|
3948
|
+
function scrubbedRead(reads, property) {
|
|
3949
|
+
return typeof property === "string" && property in reads ? reads[property] : void 0;
|
|
3950
|
+
}
|
|
3951
|
+
function viewOf(span, reads) {
|
|
3952
|
+
const view = new Proxy(span, {
|
|
3953
|
+
get(target, property) {
|
|
3954
|
+
const read = scrubbedRead(reads, property);
|
|
3955
|
+
if (read) return read();
|
|
3956
|
+
const value = Reflect.get(target, property, target);
|
|
3957
|
+
if (typeof value !== "function") return value;
|
|
3958
|
+
return (...args) => {
|
|
3959
|
+
const result = value.apply(target, args);
|
|
3960
|
+
return result === target ? view : result;
|
|
3961
|
+
};
|
|
3962
|
+
},
|
|
3963
|
+
getOwnPropertyDescriptor(target, property) {
|
|
3964
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(target, property);
|
|
3965
|
+
const read = scrubbedRead(reads, property);
|
|
3966
|
+
if (!read || !descriptor || !("value" in descriptor)) return descriptor;
|
|
3967
|
+
return { ...descriptor, value: read() };
|
|
3968
|
+
}
|
|
2444
3969
|
});
|
|
3970
|
+
return view;
|
|
2445
3971
|
}
|
|
2446
|
-
var
|
|
2447
|
-
var
|
|
2448
|
-
"src/tracing/
|
|
3972
|
+
var SECRET_KEYS, REDACTED2, MIN_SECRET_LENGTH, SpanSecrets, SPAN_SECRETS, SecretRedactingSpanProcessor;
|
|
3973
|
+
var init_secrets = __esm({
|
|
3974
|
+
"src/tracing/secrets.ts"() {
|
|
2449
3975
|
"use strict";
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
3976
|
+
SECRET_KEYS = /* @__PURE__ */ new Set([
|
|
3977
|
+
"authorization_token",
|
|
3978
|
+
"authorizationToken"
|
|
3979
|
+
]);
|
|
3980
|
+
REDACTED2 = "[redacted: holds a credential]";
|
|
3981
|
+
MIN_SECRET_LENGTH = 8;
|
|
3982
|
+
SpanSecrets = class {
|
|
3983
|
+
constructor(keys = SECRET_KEYS) {
|
|
3984
|
+
this.keys = keys;
|
|
3985
|
+
}
|
|
3986
|
+
keys;
|
|
3987
|
+
isSecret(key2) {
|
|
3988
|
+
return this.keys.has(key2);
|
|
3989
|
+
}
|
|
3990
|
+
drops(attribute) {
|
|
3991
|
+
return this.mentions(attribute);
|
|
3992
|
+
}
|
|
3993
|
+
strip(value) {
|
|
3994
|
+
if (typeof value === "string") return this.stripNested(value);
|
|
3995
|
+
if (Array.isArray(value)) return value.map((item) => this.strip(item));
|
|
3996
|
+
if (value === null || typeof value !== "object") return value;
|
|
3997
|
+
return Object.fromEntries(
|
|
3998
|
+
Object.entries(value).filter(([key2]) => !this.isSecret(key2)).map(([key2, item]) => [key2, this.strip(item)])
|
|
3999
|
+
);
|
|
4000
|
+
}
|
|
4001
|
+
scrubAttribute(value) {
|
|
4002
|
+
try {
|
|
4003
|
+
return this.scrubbedValue(value);
|
|
4004
|
+
} catch {
|
|
4005
|
+
return Array.isArray(value) ? [REDACTED2] : REDACTED2;
|
|
2458
4006
|
}
|
|
2459
4007
|
}
|
|
2460
|
-
|
|
4008
|
+
scrubbedValue(value) {
|
|
4009
|
+
if (typeof value === "string") return this.scrubbedText(value);
|
|
4010
|
+
if (!Array.isArray(value)) return value;
|
|
4011
|
+
const results = value.map(
|
|
4012
|
+
(item) => typeof item === "string" ? this.cleaned(item) : { text: item, removed: /* @__PURE__ */ new Set() }
|
|
4013
|
+
);
|
|
4014
|
+
const removed = new Set(results.flatMap((r) => [...r.removed]));
|
|
4015
|
+
const scrubbed = results.map((r) => r.text);
|
|
4016
|
+
const withheld = scrubbed.some(
|
|
4017
|
+
(item) => typeof item === "string" && this.carries(item, removed)
|
|
4018
|
+
);
|
|
4019
|
+
return withheld ? [REDACTED2] : scrubbed;
|
|
2461
4020
|
}
|
|
2462
|
-
|
|
4021
|
+
scrubAttributes(attributes) {
|
|
4022
|
+
return Object.fromEntries(
|
|
4023
|
+
Object.entries(attributes).filter(([key2]) => !this.drops(key2)).map(([key2, value]) => [key2, this.scrubAttribute(value)])
|
|
4024
|
+
);
|
|
2463
4025
|
}
|
|
2464
|
-
|
|
4026
|
+
mentions(text2) {
|
|
4027
|
+
return [...this.keys].some((key2) => text2.includes(key2));
|
|
4028
|
+
}
|
|
4029
|
+
scrubbedText(text2) {
|
|
4030
|
+
const { text: cleaned, removed } = this.cleaned(text2);
|
|
4031
|
+
return this.carries(cleaned, removed) ? REDACTED2 : cleaned;
|
|
4032
|
+
}
|
|
4033
|
+
cleaned(text2) {
|
|
4034
|
+
if (!this.mentions(text2)) return { text: text2, removed: /* @__PURE__ */ new Set() };
|
|
4035
|
+
const parsed = jsonOrUndefined(text2);
|
|
4036
|
+
if (parsed === void 0) return { text: REDACTED2, removed: /* @__PURE__ */ new Set() };
|
|
4037
|
+
return {
|
|
4038
|
+
text: JSON.stringify(this.strip(parsed)),
|
|
4039
|
+
removed: this.removed(parsed)
|
|
4040
|
+
};
|
|
4041
|
+
}
|
|
4042
|
+
carries(text2, removed) {
|
|
4043
|
+
if (text2 === REDACTED2 || this.mentions(text2)) return true;
|
|
4044
|
+
return [...removed].some(
|
|
4045
|
+
(value) => encodings(value).some((form) => text2.includes(form))
|
|
4046
|
+
);
|
|
4047
|
+
}
|
|
4048
|
+
removed(value) {
|
|
4049
|
+
if (typeof value === "string") {
|
|
4050
|
+
const nested = this.mentions(value) ? jsonOrUndefined(value) : void 0;
|
|
4051
|
+
return nested === void 0 ? /* @__PURE__ */ new Set() : this.removed(nested);
|
|
4052
|
+
}
|
|
4053
|
+
if (Array.isArray(value)) return union(value.map((v) => this.removed(v)));
|
|
4054
|
+
if (value === null || typeof value !== "object") return /* @__PURE__ */ new Set();
|
|
4055
|
+
return union(
|
|
4056
|
+
Object.entries(value).map(
|
|
4057
|
+
([key2, item]) => this.isSecret(key2) ? leaves(item) : this.removed(item)
|
|
4058
|
+
)
|
|
4059
|
+
);
|
|
4060
|
+
}
|
|
4061
|
+
stripNested(text2) {
|
|
4062
|
+
if (!this.mentions(text2)) return text2;
|
|
4063
|
+
const parsed = jsonOrUndefined(text2);
|
|
4064
|
+
if (parsed === void 0) return text2;
|
|
4065
|
+
return JSON.stringify(this.strip(parsed));
|
|
4066
|
+
}
|
|
4067
|
+
};
|
|
4068
|
+
SPAN_SECRETS = new SpanSecrets();
|
|
4069
|
+
SecretRedactingSpanProcessor = class {
|
|
4070
|
+
constructor(inner, secrets = SPAN_SECRETS) {
|
|
4071
|
+
this.inner = inner;
|
|
4072
|
+
this.secrets = secrets;
|
|
4073
|
+
}
|
|
4074
|
+
inner;
|
|
4075
|
+
secrets;
|
|
4076
|
+
views = /* @__PURE__ */ new WeakMap();
|
|
4077
|
+
onStart(span, parentContext) {
|
|
4078
|
+
this.inner.onStart(this.viewFor(span), parentContext);
|
|
4079
|
+
}
|
|
4080
|
+
onEnd(span) {
|
|
4081
|
+
const view = this.viewFor(span);
|
|
4082
|
+
try {
|
|
4083
|
+
void [view.attributes, view.events, view.status];
|
|
4084
|
+
} catch (error) {
|
|
4085
|
+
console.warn(
|
|
4086
|
+
`[gatewaysdk.tracing] Dropped span "${span.name}": could not redact it: ${error?.name}`
|
|
4087
|
+
);
|
|
4088
|
+
return;
|
|
4089
|
+
}
|
|
4090
|
+
this.inner.onEnd(view);
|
|
4091
|
+
}
|
|
4092
|
+
viewFor(span) {
|
|
4093
|
+
const known = this.views.get(span);
|
|
4094
|
+
if (known) return known;
|
|
4095
|
+
const view = viewOf(span, {
|
|
4096
|
+
attributes: () => this.scrubbedAttributes(span.attributes),
|
|
4097
|
+
events: () => span.events.map((event) => this.scrubbedEvent(event)),
|
|
4098
|
+
status: () => this.scrubbedStatus(span.status)
|
|
4099
|
+
});
|
|
4100
|
+
this.views.set(span, view);
|
|
4101
|
+
return view;
|
|
4102
|
+
}
|
|
4103
|
+
forceFlush() {
|
|
4104
|
+
return this.inner.forceFlush();
|
|
4105
|
+
}
|
|
4106
|
+
shutdown() {
|
|
4107
|
+
return this.inner.shutdown();
|
|
4108
|
+
}
|
|
4109
|
+
scrubbedAttributes(attributes) {
|
|
4110
|
+
const clean = this.secrets.scrubAttributes(attributes);
|
|
4111
|
+
return sameAttributes(attributes, clean) ? attributes : clean;
|
|
4112
|
+
}
|
|
4113
|
+
scrubbedStatus(status) {
|
|
4114
|
+
if (!status.message) return status;
|
|
4115
|
+
const message = this.secrets.scrubAttribute(status.message);
|
|
4116
|
+
return message === status.message ? status : { ...status, message };
|
|
4117
|
+
}
|
|
4118
|
+
scrubbedEvent(event) {
|
|
4119
|
+
if (!event.attributes) return event;
|
|
4120
|
+
const attributes = this.scrubbedAttributes(event.attributes);
|
|
4121
|
+
if (attributes === event.attributes) return event;
|
|
4122
|
+
return { ...event, attributes };
|
|
2465
4123
|
}
|
|
2466
4124
|
};
|
|
2467
4125
|
}
|
|
@@ -2472,7 +4130,7 @@ var require_package = __commonJS({
|
|
|
2472
4130
|
"package.json"(exports2, module2) {
|
|
2473
4131
|
module2.exports = {
|
|
2474
4132
|
name: "@withgateway/sdk",
|
|
2475
|
-
version: "0.
|
|
4133
|
+
version: "0.3.0",
|
|
2476
4134
|
description: "Gateway SDK for TypeScript - A/B experiments, tracing, and observability",
|
|
2477
4135
|
main: "./dist/index.js",
|
|
2478
4136
|
module: "./dist/index.mjs",
|
|
@@ -2683,7 +4341,7 @@ function canonicalJson(value) {
|
|
|
2683
4341
|
return `{${entries.map(([k, v]) => `${JSON.stringify(k)}:${canonicalJson(v)}`).join(",")}}`;
|
|
2684
4342
|
}
|
|
2685
4343
|
function sha256(text2) {
|
|
2686
|
-
return `sha256:${(0,
|
|
4344
|
+
return `sha256:${(0, import_node_crypto3.createHash)("sha256").update(text2).digest("hex")}`;
|
|
2687
4345
|
}
|
|
2688
4346
|
function captureSource() {
|
|
2689
4347
|
const stack = new Error().stack?.split("\n") ?? [];
|
|
@@ -2943,11 +4601,11 @@ async function registerBuild(params) {
|
|
|
2943
4601
|
);
|
|
2944
4602
|
}
|
|
2945
4603
|
}
|
|
2946
|
-
var
|
|
4604
|
+
var import_node_crypto3, registeredTools, registeredPrompts, registeredSkills, registeredArtifacts, activeBuilds, reRegisterTimer, RE_REGISTER_DEBOUNCE_MS;
|
|
2947
4605
|
var init_build = __esm({
|
|
2948
4606
|
"src/build/index.ts"() {
|
|
2949
4607
|
"use strict";
|
|
2950
|
-
|
|
4608
|
+
import_node_crypto3 = require("crypto");
|
|
2951
4609
|
registeredTools = /* @__PURE__ */ new Map();
|
|
2952
4610
|
registeredPrompts = /* @__PURE__ */ new Map();
|
|
2953
4611
|
registeredSkills = /* @__PURE__ */ new Map();
|
|
@@ -3079,7 +4737,7 @@ function buildProvider(config, logFn) {
|
|
|
3079
4737
|
const spanProcessors = [];
|
|
3080
4738
|
if (config.customSpanProcessors) {
|
|
3081
4739
|
for (const sp of config.customSpanProcessors) {
|
|
3082
|
-
spanProcessors.push(sp);
|
|
4740
|
+
spanProcessors.push(new SecretRedactingSpanProcessor(sp));
|
|
3083
4741
|
logFn(
|
|
3084
4742
|
"Added custom span processor: %s",
|
|
3085
4743
|
sp.constructor?.name ?? "unknown"
|
|
@@ -3098,7 +4756,11 @@ function buildProvider(config, logFn) {
|
|
|
3098
4756
|
if (config.batch?.maxExportBatchSize) {
|
|
3099
4757
|
batchConfig.maxExportBatchSize = config.batch.maxExportBatchSize;
|
|
3100
4758
|
}
|
|
3101
|
-
spanProcessors.push(
|
|
4759
|
+
spanProcessors.push(
|
|
4760
|
+
new SecretRedactingSpanProcessor(
|
|
4761
|
+
new BatchSpanProcessor(exporter, batchConfig)
|
|
4762
|
+
)
|
|
4763
|
+
);
|
|
3102
4764
|
let provider = new NodeTracerProvider({
|
|
3103
4765
|
resource: createResource(resourceAttrs)
|
|
3104
4766
|
});
|
|
@@ -3236,7 +4898,8 @@ var init_init = __esm({
|
|
|
3236
4898
|
"src/tracing/init.ts"() {
|
|
3237
4899
|
"use strict";
|
|
3238
4900
|
init_identity();
|
|
3239
|
-
|
|
4901
|
+
init_secrets();
|
|
4902
|
+
init_session();
|
|
3240
4903
|
init_scores();
|
|
3241
4904
|
init_build();
|
|
3242
4905
|
ENV_VARS = {
|
|
@@ -3351,7 +5014,7 @@ function reportFromResult(result) {
|
|
|
3351
5014
|
return { report, extra };
|
|
3352
5015
|
}
|
|
3353
5016
|
async function runTask(ref, agent, opts) {
|
|
3354
|
-
const runId = `wtr-${(0,
|
|
5017
|
+
const runId = `wtr-${(0, import_node_crypto4.randomBytes)(6).toString("hex")}`;
|
|
3355
5018
|
const outDir = opts.outDir ?? "runs";
|
|
3356
5019
|
const runDir = path.join(outDir, runId);
|
|
3357
5020
|
fs.mkdirSync(runDir, { recursive: true });
|
|
@@ -3389,7 +5052,7 @@ async function runTask(ref, agent, opts) {
|
|
|
3389
5052
|
let extra = {};
|
|
3390
5053
|
try {
|
|
3391
5054
|
const invoke = () => agent(taskRun);
|
|
3392
|
-
const result = traced ? await (await Promise.resolve().then(() => (
|
|
5055
|
+
const result = traced ? await (await Promise.resolve().then(() => (init_session(), session_exports))).withSession(runId, invoke) : await invoke();
|
|
3393
5056
|
({ report, extra } = reportFromResult(result));
|
|
3394
5057
|
} catch (error) {
|
|
3395
5058
|
const message = (error instanceof Error ? error.message : String(error)) || "Unknown error";
|
|
@@ -3456,16 +5119,16 @@ async function runTask(ref, agent, opts) {
|
|
|
3456
5119
|
}
|
|
3457
5120
|
}
|
|
3458
5121
|
}
|
|
3459
|
-
var
|
|
5122
|
+
var import_node_crypto4, fs, path, TaskRun, describeValue, RESULT_CONTRACT;
|
|
3460
5123
|
var init_taskRun = __esm({
|
|
3461
5124
|
"src/worlds/taskRun.ts"() {
|
|
3462
5125
|
"use strict";
|
|
3463
|
-
|
|
5126
|
+
import_node_crypto4 = require("crypto");
|
|
3464
5127
|
fs = __toESM(require("fs"));
|
|
3465
5128
|
path = __toESM(require("path"));
|
|
3466
5129
|
init_browser();
|
|
3467
5130
|
init_evals();
|
|
3468
|
-
|
|
5131
|
+
init_session2();
|
|
3469
5132
|
init_taskSessions();
|
|
3470
5133
|
TaskRun = class {
|
|
3471
5134
|
constructor(runId, instruction, model, sessions2, manifest) {
|
|
@@ -3774,11 +5437,11 @@ var init_checkoutTarget = __esm({
|
|
|
3774
5437
|
});
|
|
3775
5438
|
|
|
3776
5439
|
// src/worlds/worldDir.ts
|
|
3777
|
-
var
|
|
5440
|
+
var import_node_crypto5, fs3, path3, WORLD_MANIFEST, API_BUNDLE_MANIFEST, BUNDLED_WORLD_PREFIX, CONNECTOR_SPEC, PYPROJECT, BENCHMARK_CONFIG, WORLD_SCHEMA_MARKERS, WORLD_ROOT_MARKERS, BROAD_ROOT_MARKERS, SKIPPED_DIRS, V1_DEP, V1_IMPORT, V1_TASKSET, HARBOR_TASK, skippedDir, byCodePoint, WorldDir;
|
|
3778
5441
|
var init_worldDir = __esm({
|
|
3779
5442
|
"src/worlds/worldDir.ts"() {
|
|
3780
5443
|
"use strict";
|
|
3781
|
-
|
|
5444
|
+
import_node_crypto5 = require("crypto");
|
|
3782
5445
|
fs3 = __toESM(require("fs"));
|
|
3783
5446
|
path3 = __toESM(require("path"));
|
|
3784
5447
|
WORLD_MANIFEST = "gateway-env.toml";
|
|
@@ -3884,7 +5547,7 @@ var init_worldDir = __esm({
|
|
|
3884
5547
|
* sorted order: the version's identity, byte-compatible with
|
|
3885
5548
|
* `_archive.compute_content_hash` and Prime Intellect. */
|
|
3886
5549
|
get contentHash() {
|
|
3887
|
-
const hasher = (0,
|
|
5550
|
+
const hasher = (0, import_node_crypto5.createHash)("sha256");
|
|
3888
5551
|
for (const rel of this.archivePaths) {
|
|
3889
5552
|
hasher.update(Buffer.from(`file:${rel}`, "utf-8"));
|
|
3890
5553
|
hasher.update(fs3.readFileSync(path3.join(this.dir, rel)));
|
|
@@ -4188,7 +5851,7 @@ function writeLocalMeta(dir, meta) {
|
|
|
4188
5851
|
function snapshotTreeHashes(dir) {
|
|
4189
5852
|
const out = {};
|
|
4190
5853
|
for (const relPath of collectArchiveRelPaths(dir)) {
|
|
4191
|
-
out[relPath] = (0,
|
|
5854
|
+
out[relPath] = (0, import_node_crypto6.createHash)("sha256").update(fs5.readFileSync(path5.join(dir, relPath))).digest("hex");
|
|
4192
5855
|
}
|
|
4193
5856
|
return out;
|
|
4194
5857
|
}
|
|
@@ -4234,7 +5897,7 @@ function buildFileManifest(dir) {
|
|
|
4234
5897
|
path: relPath,
|
|
4235
5898
|
isDirectory: false,
|
|
4236
5899
|
size: payload.length,
|
|
4237
|
-
sha256: (0,
|
|
5900
|
+
sha256: (0, import_node_crypto6.createHash)("sha256").update(payload).digest("hex")
|
|
4238
5901
|
};
|
|
4239
5902
|
});
|
|
4240
5903
|
}
|
|
@@ -4433,11 +6096,11 @@ async function createRef(slug, name, kind, versionId, options = {}) {
|
|
|
4433
6096
|
...versionId ? { versionId } : {}
|
|
4434
6097
|
});
|
|
4435
6098
|
}
|
|
4436
|
-
var
|
|
6099
|
+
var import_node_crypto6, import_node_zlib2, fs5, path5, DEFAULT_BRANCH, META_RELPATH, FILE_MODE, MINTED_SUFFIX, PushSlugConflict, sha256b64, DetachedPushError;
|
|
4437
6100
|
var init_hub = __esm({
|
|
4438
6101
|
"src/worlds/hub.ts"() {
|
|
4439
6102
|
"use strict";
|
|
4440
|
-
|
|
6103
|
+
import_node_crypto6 = require("crypto");
|
|
4441
6104
|
import_node_zlib2 = require("zlib");
|
|
4442
6105
|
fs5 = __toESM(require("fs"));
|
|
4443
6106
|
path5 = __toESM(require("path"));
|
|
@@ -4463,7 +6126,7 @@ var init_hub = __esm({
|
|
|
4463
6126
|
tracked;
|
|
4464
6127
|
declared;
|
|
4465
6128
|
};
|
|
4466
|
-
sha256b64 = (data) => (0,
|
|
6129
|
+
sha256b64 = (data) => (0, import_node_crypto6.createHash)("sha256").update(data).digest("base64");
|
|
4467
6130
|
DetachedPushError = class extends Error {
|
|
4468
6131
|
constructor(dir, tag) {
|
|
4469
6132
|
super(
|
|
@@ -4664,6 +6327,34 @@ function parseSlugRef(slugRef) {
|
|
|
4664
6327
|
if (at === -1) return { slug: slugRef };
|
|
4665
6328
|
return { slug: slugRef.slice(0, at), ref: slugRef.slice(at + 1) };
|
|
4666
6329
|
}
|
|
6330
|
+
function rebaseConflicts(error) {
|
|
6331
|
+
if (!(error instanceof ApiError) || error.status !== 409) return null;
|
|
6332
|
+
let body;
|
|
6333
|
+
try {
|
|
6334
|
+
body = JSON.parse(error.text);
|
|
6335
|
+
} catch {
|
|
6336
|
+
return null;
|
|
6337
|
+
}
|
|
6338
|
+
const conflicts = body?.conflicts;
|
|
6339
|
+
if (!Array.isArray(conflicts)) return null;
|
|
6340
|
+
return conflicts.filter(isConflictPath).map(({ path: path16, reason }) => ({ path: path16, reason }));
|
|
6341
|
+
}
|
|
6342
|
+
function isConflictPath(value) {
|
|
6343
|
+
const entry = value;
|
|
6344
|
+
return typeof entry?.path === "string" && typeof entry.reason === "string";
|
|
6345
|
+
}
|
|
6346
|
+
function uncommittedPaths(error) {
|
|
6347
|
+
if (!(error instanceof ApiError) || error.status !== 409 || error.code !== "sandbox_uncommitted") return null;
|
|
6348
|
+
let body;
|
|
6349
|
+
try {
|
|
6350
|
+
body = JSON.parse(error.text);
|
|
6351
|
+
} catch {
|
|
6352
|
+
return null;
|
|
6353
|
+
}
|
|
6354
|
+
const uncommitted = body?.uncommitted;
|
|
6355
|
+
if (!Array.isArray(uncommitted)) return null;
|
|
6356
|
+
return uncommitted.filter((p) => typeof p === "string");
|
|
6357
|
+
}
|
|
4667
6358
|
function listQuery(filter) {
|
|
4668
6359
|
const params = new URLSearchParams();
|
|
4669
6360
|
if (filter.status) params.set("status", filter.status);
|
|
@@ -4672,18 +6363,25 @@ function listQuery(filter) {
|
|
|
4672
6363
|
const qs3 = params.toString();
|
|
4673
6364
|
return qs3 ? `?${qs3}` : "";
|
|
4674
6365
|
}
|
|
4675
|
-
var isSandboxImportPending, sid, WorldSandboxClient;
|
|
6366
|
+
var isSandboxImportPending, sid, SANDBOXES, SANDBOX_REQUEST_TIMEOUT_MS, WorldSandboxClient;
|
|
4676
6367
|
var init_sandbox = __esm({
|
|
4677
6368
|
"src/worlds/sandbox.ts"() {
|
|
4678
6369
|
"use strict";
|
|
4679
6370
|
init_worlds();
|
|
4680
6371
|
isSandboxImportPending = (answer) => !("versionId" in answer);
|
|
4681
6372
|
sid = encodeURIComponent;
|
|
6373
|
+
SANDBOXES = "/api/public/benchmark-containers/sandboxes";
|
|
6374
|
+
SANDBOX_REQUEST_TIMEOUT_MS = 66e4;
|
|
4682
6375
|
WorldSandboxClient = class {
|
|
4683
6376
|
constructor(options = {}) {
|
|
4684
6377
|
this.options = options;
|
|
4685
6378
|
}
|
|
4686
6379
|
options;
|
|
6380
|
+
request(method, path16, body) {
|
|
6381
|
+
return apiRequest(this.options, method, path16, body, {
|
|
6382
|
+
timeoutMs: SANDBOX_REQUEST_TIMEOUT_MS
|
|
6383
|
+
});
|
|
6384
|
+
}
|
|
4687
6385
|
/**
|
|
4688
6386
|
* `{ slug, ref? }` opens a READY version; `{ new, from }` opens a sandbox on
|
|
4689
6387
|
* a world that does not exist yet (409 `world_exists` if the slug is taken,
|
|
@@ -4691,42 +6389,39 @@ var init_sandbox = __esm({
|
|
|
4691
6389
|
* creates the world on `main`.
|
|
4692
6390
|
*/
|
|
4693
6391
|
open(target) {
|
|
4694
|
-
return
|
|
6392
|
+
return this.request("POST", `${SANDBOXES}`, target);
|
|
4695
6393
|
}
|
|
4696
6394
|
status(sandboxId) {
|
|
4697
|
-
return
|
|
6395
|
+
return this.request("GET", `${SANDBOXES}/${sid(sandboxId)}`);
|
|
4698
6396
|
}
|
|
4699
6397
|
/** The project's sandboxes, newest first — how an agent finds one it left open. */
|
|
4700
6398
|
async list(filter = {}) {
|
|
4701
|
-
const res = await
|
|
4702
|
-
this.options,
|
|
4703
|
-
"GET",
|
|
4704
|
-
`/api/public/benchmark-containers/sandboxes${listQuery(filter)}`
|
|
4705
|
-
);
|
|
6399
|
+
const res = await this.request("GET", `${SANDBOXES}${listQuery(filter)}`);
|
|
4706
6400
|
return res.sandboxes;
|
|
4707
6401
|
}
|
|
4708
6402
|
async read(sandboxId, filePath) {
|
|
4709
|
-
const res = await
|
|
4710
|
-
this.options,
|
|
6403
|
+
const res = await this.request(
|
|
4711
6404
|
"GET",
|
|
4712
|
-
|
|
6405
|
+
`${SANDBOXES}/${sid(sandboxId)}/file?path=${encodeURIComponent(filePath)}`
|
|
4713
6406
|
);
|
|
4714
6407
|
return { path: res.path, size: res.size, bytes: Buffer.from(res.contentBase64, "base64") };
|
|
4715
6408
|
}
|
|
4716
6409
|
write(sandboxId, filePath, bytes) {
|
|
4717
|
-
return
|
|
6410
|
+
return this.request("PUT", `${SANDBOXES}/${sid(sandboxId)}/file`, {
|
|
4718
6411
|
path: filePath,
|
|
4719
6412
|
contentBase64: bytes.toString("base64")
|
|
4720
6413
|
});
|
|
4721
6414
|
}
|
|
4722
6415
|
exec(sandboxId, input) {
|
|
4723
|
-
return
|
|
6416
|
+
return this.request("POST", `${SANDBOXES}/${sid(sandboxId)}/exec`, input);
|
|
4724
6417
|
}
|
|
4725
6418
|
check(sandboxId) {
|
|
4726
|
-
return
|
|
6419
|
+
return this.request("POST", `${SANDBOXES}/${sid(sandboxId)}/check`, {});
|
|
4727
6420
|
}
|
|
6421
|
+
/** With `rebase`, a moved base is replayed onto; a 409 then names the conflicting paths (`rebaseConflicts`). */
|
|
4728
6422
|
commit(sandboxId, input) {
|
|
4729
|
-
|
|
6423
|
+
const { rebase, ...rest } = input;
|
|
6424
|
+
return this.request("POST", `${SANDBOXES}/${sid(sandboxId)}/commit`, rebase ? { ...rest, rebase: true } : rest);
|
|
4730
6425
|
}
|
|
4731
6426
|
/**
|
|
4732
6427
|
* A rows file already in the sandbox tree into the PLATFORM world the
|
|
@@ -4735,10 +6430,11 @@ var init_sandbox = __esm({
|
|
|
4735
6430
|
* tree and never carries data.
|
|
4736
6431
|
*/
|
|
4737
6432
|
importData(sandboxId, input) {
|
|
4738
|
-
return
|
|
6433
|
+
return this.request("POST", `${SANDBOXES}/${sid(sandboxId)}/import`, input);
|
|
4739
6434
|
}
|
|
4740
|
-
|
|
4741
|
-
|
|
6435
|
+
/** Uncommitted work is a 409 (`uncommittedPaths`) unless `force` discards it. */
|
|
6436
|
+
close(sandboxId, opts = {}) {
|
|
6437
|
+
return this.request("DELETE", `${SANDBOXES}/${sid(sandboxId)}`, opts.force ? { force: true } : void 0);
|
|
4742
6438
|
}
|
|
4743
6439
|
};
|
|
4744
6440
|
}
|
|
@@ -5074,11 +6770,11 @@ function applyTransforms(value, chain) {
|
|
|
5074
6770
|
for (const step of steps) out = step(out);
|
|
5075
6771
|
return out;
|
|
5076
6772
|
}
|
|
5077
|
-
var
|
|
6773
|
+
var import_node_crypto7, WHITESPACE, WHITESPACE_EDGES, WHITESPACE_RUN, NOT_DIGIT, STRIP_PREFIX, trim, emailLocalPart, emailDomain, stripPrefix, hex, SIMPLE, TRANSFORMS, text;
|
|
5078
6774
|
var init_transforms = __esm({
|
|
5079
6775
|
"src/worlds/transforms.ts"() {
|
|
5080
6776
|
"use strict";
|
|
5081
|
-
|
|
6777
|
+
import_node_crypto7 = require("crypto");
|
|
5082
6778
|
init_json();
|
|
5083
6779
|
WHITESPACE = " \n\r\f\v";
|
|
5084
6780
|
WHITESPACE_EDGES = new RegExp(`^[${WHITESPACE}]+|[${WHITESPACE}]+$`, "g");
|
|
@@ -5095,7 +6791,7 @@ var init_transforms = __esm({
|
|
|
5095
6791
|
return at === -1 ? "" : value.slice(at + 1).toLowerCase();
|
|
5096
6792
|
};
|
|
5097
6793
|
stripPrefix = (prefix) => (value) => value.startsWith(prefix) ? value.slice(prefix.length) : value;
|
|
5098
|
-
hex = (algorithm, value) => (0,
|
|
6794
|
+
hex = (algorithm, value) => (0, import_node_crypto7.createHash)(algorithm).update(value, "utf8").digest("hex");
|
|
5099
6795
|
SIMPLE = {
|
|
5100
6796
|
lower: (value) => value.toLowerCase(),
|
|
5101
6797
|
upper: (value) => value.toUpperCase(),
|
|
@@ -5127,7 +6823,7 @@ function pyText(value) {
|
|
|
5127
6823
|
return pyFloatRepr(value);
|
|
5128
6824
|
}
|
|
5129
6825
|
function hashForm(slug, plaintext) {
|
|
5130
|
-
return "sha256:" + (0,
|
|
6826
|
+
return "sha256:" + (0, import_node_crypto8.createHash)("sha256").update(`${slug}:${pyText(plaintext)}`, "utf8").digest("hex");
|
|
5131
6827
|
}
|
|
5132
6828
|
function preserveForm(slug, plaintext) {
|
|
5133
6829
|
const kind = typeof plaintext === "string" ? "str" : isInt(plaintext) ? "int" : "float";
|
|
@@ -5136,12 +6832,12 @@ function preserveForm(slug, plaintext) {
|
|
|
5136
6832
|
}
|
|
5137
6833
|
function shapeText(slug, text2, kind) {
|
|
5138
6834
|
const seed = Buffer.from(`${slug}:${text2}`, "utf8");
|
|
5139
|
-
let digest = (0,
|
|
6835
|
+
let digest = (0, import_node_crypto8.createHash)("sha256").update(seed).digest();
|
|
5140
6836
|
let cursor = 0;
|
|
5141
6837
|
const out = [];
|
|
5142
6838
|
for (const char of text2) {
|
|
5143
6839
|
if (cursor === digest.length) {
|
|
5144
|
-
digest = (0,
|
|
6840
|
+
digest = (0, import_node_crypto8.createHash)("sha256").update(Buffer.concat([digest, seed])).digest();
|
|
5145
6841
|
cursor = 0;
|
|
5146
6842
|
}
|
|
5147
6843
|
const byte = digest[cursor];
|
|
@@ -5178,11 +6874,11 @@ function storedForms(world, field2, plaintext, transform) {
|
|
|
5178
6874
|
if (policy !== null) return [roundForm(plaintext, world.redact.round[field2])];
|
|
5179
6875
|
return [plaintext];
|
|
5180
6876
|
}
|
|
5181
|
-
var
|
|
6877
|
+
var import_node_crypto8, isInt;
|
|
5182
6878
|
var init_redaction = __esm({
|
|
5183
6879
|
"src/worlds/redaction.ts"() {
|
|
5184
6880
|
"use strict";
|
|
5185
|
-
|
|
6881
|
+
import_node_crypto8 = require("crypto");
|
|
5186
6882
|
init_json();
|
|
5187
6883
|
init_transforms();
|
|
5188
6884
|
isInt = (value) => typeof value === "number" && Number.isInteger(value);
|
|
@@ -5267,42 +6963,12 @@ var init_router = __esm({
|
|
|
5267
6963
|
});
|
|
5268
6964
|
|
|
5269
6965
|
// src/cli/config.ts
|
|
5270
|
-
function transportDetail(error, timeoutMs) {
|
|
5271
|
-
if (error instanceof Error && error.name === "AbortError") return `timed out after ${Math.round(timeoutMs / 1e3)}s`;
|
|
5272
|
-
const cause = error instanceof Error && error.cause instanceof Error ? error.cause : void 0;
|
|
5273
|
-
const code = cause && "code" in cause && typeof cause.code === "string" ? `${cause.code}: ` : "";
|
|
5274
|
-
const message = cause?.message ?? (error instanceof Error ? error.message : String(error));
|
|
5275
|
-
return `${code}${message}`;
|
|
5276
|
-
}
|
|
5277
6966
|
async function api(creds, method, route, body, init3 = {}) {
|
|
5278
|
-
const
|
|
5279
|
-
|
|
5280
|
-
|
|
5281
|
-
let res;
|
|
5282
|
-
try {
|
|
5283
|
-
res = await fetch(`${creds.host}${route}`, {
|
|
5284
|
-
method,
|
|
5285
|
-
headers: {
|
|
5286
|
-
"content-type": "application/json",
|
|
5287
|
-
accept: "application/json",
|
|
5288
|
-
authorization: "Basic " + Buffer.from(`${creds.publicKey}:${creds.secretKey}`).toString("base64")
|
|
5289
|
-
},
|
|
5290
|
-
...body === void 0 ? {} : { body: JSON.stringify(body) },
|
|
5291
|
-
signal: controller.signal
|
|
5292
|
-
});
|
|
5293
|
-
} catch (error) {
|
|
5294
|
-
clearTimeout(timer);
|
|
5295
|
-
throw new UnreachableError(creds.host, method, route, transportDetail(error, timeoutMs));
|
|
5296
|
-
}
|
|
5297
|
-
try {
|
|
5298
|
-
const text2 = await res.text();
|
|
5299
|
-
if (!res.ok) throw new ApiError(res.status, method, route, text2);
|
|
5300
|
-
return text2 ? JSON.parse(text2) : {};
|
|
5301
|
-
} finally {
|
|
5302
|
-
clearTimeout(timer);
|
|
5303
|
-
}
|
|
6967
|
+
const reply = await new PlatformTransport(creds).send(method, route, body, init3);
|
|
6968
|
+
if (!reply.ok) throw new ApiError2(reply.status, method, route, reply.text);
|
|
6969
|
+
return reply.text ? JSON.parse(reply.text) : {};
|
|
5304
6970
|
}
|
|
5305
|
-
var fs6, os, path6,
|
|
6971
|
+
var fs6, os, path6, ApiError2;
|
|
5306
6972
|
var init_config = __esm({
|
|
5307
6973
|
"src/cli/config.ts"() {
|
|
5308
6974
|
"use strict";
|
|
@@ -5311,7 +6977,8 @@ var init_config = __esm({
|
|
|
5311
6977
|
path6 = __toESM(require("path"));
|
|
5312
6978
|
init_router();
|
|
5313
6979
|
init_worlds();
|
|
5314
|
-
|
|
6980
|
+
init_transport();
|
|
6981
|
+
ApiError2 = class extends CliError {
|
|
5315
6982
|
constructor(status, method, route, text2) {
|
|
5316
6983
|
const body = parseErrorBody(text2);
|
|
5317
6984
|
super(`${method} ${route} -> ${status}: ${body.detail}`, 1);
|
|
@@ -5327,19 +6994,6 @@ var init_config = __esm({
|
|
|
5327
6994
|
text;
|
|
5328
6995
|
code;
|
|
5329
6996
|
};
|
|
5330
|
-
UnreachableError = class extends CliError {
|
|
5331
|
-
constructor(host, method, route, detail) {
|
|
5332
|
-
super(`${method} ${route}: no answer from ${host} (${detail}). Check the host and the network, then retry.`, 1);
|
|
5333
|
-
this.host = host;
|
|
5334
|
-
this.method = method;
|
|
5335
|
-
this.route = route;
|
|
5336
|
-
this.detail = detail;
|
|
5337
|
-
}
|
|
5338
|
-
host;
|
|
5339
|
-
method;
|
|
5340
|
-
route;
|
|
5341
|
-
detail;
|
|
5342
|
-
};
|
|
5343
6997
|
}
|
|
5344
6998
|
});
|
|
5345
6999
|
|
|
@@ -5518,7 +7172,7 @@ var init_local = __esm({
|
|
|
5518
7172
|
path7 = __toESM(require("path"));
|
|
5519
7173
|
init_router();
|
|
5520
7174
|
init_config();
|
|
5521
|
-
MIN_PYTHON = [3,
|
|
7175
|
+
MIN_PYTHON = [3, 12];
|
|
5522
7176
|
DIAGNOSTIC_TAIL = 600;
|
|
5523
7177
|
BRIDGE_BOOTSTRAP = `import sys,runpy,types,os
|
|
5524
7178
|
root=sys.argv[1]
|
|
@@ -5530,7 +7184,6 @@ runpy.run_module('gatewaysdk.environment.schema.platform',run_name='__main__')`;
|
|
|
5530
7184
|
PYTHON_CANDIDATES = [
|
|
5531
7185
|
"python3.13",
|
|
5532
7186
|
"python3.12",
|
|
5533
|
-
"python3.11",
|
|
5534
7187
|
"python3",
|
|
5535
7188
|
"python"
|
|
5536
7189
|
];
|
|
@@ -5640,47 +7293,33 @@ function runsLocally(request) {
|
|
|
5640
7293
|
async function runtime(creds, request, opts = {}) {
|
|
5641
7294
|
const local = localRuntime();
|
|
5642
7295
|
if (local && runsLocally(request)) {
|
|
5643
|
-
const
|
|
5644
|
-
const
|
|
5645
|
-
if (
|
|
5646
|
-
return
|
|
7296
|
+
const payload2 = await localBridge(request, local, opts);
|
|
7297
|
+
const detail2 = detailFrom(payload2);
|
|
7298
|
+
if (detail2) throw new BridgeRejected(detail2);
|
|
7299
|
+
return payload2;
|
|
5647
7300
|
}
|
|
5648
7301
|
if (!creds)
|
|
5649
7302
|
throw new CliError(
|
|
5650
7303
|
"This needs the schema runtime (the CLI bundles it) or platform credentials (`gateway auth login`). " + localRuntimeReason()
|
|
5651
7304
|
);
|
|
5652
|
-
const controller = new AbortController();
|
|
5653
|
-
const timer = setTimeout(() => controller.abort(), opts.timeoutMs ?? 18e4);
|
|
5654
7305
|
const route = "/api/public/worlds/runtime";
|
|
7306
|
+
const res = await new PlatformTransport(creds).send("POST", route, request, {
|
|
7307
|
+
timeoutMs: opts.timeoutMs ?? RUNTIME_TIMEOUT_MS
|
|
7308
|
+
});
|
|
7309
|
+
let payload = null;
|
|
5655
7310
|
try {
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
|
|
5659
|
-
"content-type": "application/json",
|
|
5660
|
-
accept: "application/json",
|
|
5661
|
-
authorization: "Basic " + Buffer.from(`${creds.publicKey}:${creds.secretKey}`).toString("base64")
|
|
5662
|
-
},
|
|
5663
|
-
body: JSON.stringify(request),
|
|
5664
|
-
signal: controller.signal
|
|
5665
|
-
});
|
|
5666
|
-
const text2 = await res.text();
|
|
5667
|
-
let payload = null;
|
|
5668
|
-
try {
|
|
5669
|
-
payload = text2 ? JSON.parse(text2) : {};
|
|
5670
|
-
} catch {
|
|
5671
|
-
payload = null;
|
|
5672
|
-
}
|
|
5673
|
-
const detail = detailFrom(payload);
|
|
5674
|
-
if (detail) throw new BridgeRejected(detail);
|
|
5675
|
-
if (!res.ok)
|
|
5676
|
-
throw new CliError(`POST ${route} (${request.command}) -> ${res.status}: ${text2.slice(0, 600)}`, 1);
|
|
5677
|
-
if (payload === null) throw new CliError(`POST ${route} (${request.command}) returned non-JSON`, 1);
|
|
5678
|
-
return payload;
|
|
5679
|
-
} finally {
|
|
5680
|
-
clearTimeout(timer);
|
|
7311
|
+
payload = res.text ? JSON.parse(res.text) : {};
|
|
7312
|
+
} catch {
|
|
7313
|
+
payload = null;
|
|
5681
7314
|
}
|
|
7315
|
+
const detail = detailFrom(payload);
|
|
7316
|
+
if (detail) throw new BridgeRejected(detail);
|
|
7317
|
+
if (!res.ok)
|
|
7318
|
+
throw new CliError(`POST ${route} (${request.command}) -> ${res.status}: ${res.text.slice(0, 600)}`, 1);
|
|
7319
|
+
if (payload === null) throw new CliError(`POST ${route} (${request.command}) returned non-JSON`, 1);
|
|
7320
|
+
return payload;
|
|
5682
7321
|
}
|
|
5683
|
-
var fs8, path8, MAX_WORLD_FILES, SKIP_DIRS, BUILD_OUTPUT, BridgeRejected, YAML_NAME;
|
|
7322
|
+
var fs8, path8, MAX_WORLD_FILES, RUNTIME_TIMEOUT_MS, SKIP_DIRS, BUILD_OUTPUT, BridgeRejected, YAML_NAME;
|
|
5684
7323
|
var init_client = __esm({
|
|
5685
7324
|
"src/cli/runtime/client.ts"() {
|
|
5686
7325
|
"use strict";
|
|
@@ -5688,7 +7327,9 @@ var init_client = __esm({
|
|
|
5688
7327
|
path8 = __toESM(require("path"));
|
|
5689
7328
|
init_router();
|
|
5690
7329
|
init_local();
|
|
7330
|
+
init_transport();
|
|
5691
7331
|
MAX_WORLD_FILES = 2e3;
|
|
7332
|
+
RUNTIME_TIMEOUT_MS = 18e4;
|
|
5692
7333
|
SKIP_DIRS = /* @__PURE__ */ new Set(["__pycache__", ".git", "node_modules", ".gateway"]);
|
|
5693
7334
|
BUILD_OUTPUT = /(^|\/)state\.(sqlite|json)$/;
|
|
5694
7335
|
BridgeRejected = class extends CliError {
|
|
@@ -6106,7 +7747,7 @@ function uploadHeadersFor(gz) {
|
|
|
6106
7747
|
return {
|
|
6107
7748
|
"content-type": "application/gzip",
|
|
6108
7749
|
"content-length": String(gz.length),
|
|
6109
|
-
"x-amz-checksum-sha256": (0,
|
|
7750
|
+
"x-amz-checksum-sha256": (0, import_node_crypto9.createHash)("sha256").update(gz).digest("base64")
|
|
6110
7751
|
};
|
|
6111
7752
|
}
|
|
6112
7753
|
async function forEachLimited(items, limit, fn) {
|
|
@@ -6152,11 +7793,11 @@ function phaseLine(status) {
|
|
|
6152
7793
|
const phase = status.progress?.phase;
|
|
6153
7794
|
return phase ? `${status.state} (${phase})` : status.state;
|
|
6154
7795
|
}
|
|
6155
|
-
var
|
|
7796
|
+
var import_node_crypto9, fs11, TERMINAL_STATES, sleepMs, WorldDataApi;
|
|
6156
7797
|
var init_batches = __esm({
|
|
6157
7798
|
"src/cli/platform/worldData/batches.ts"() {
|
|
6158
7799
|
"use strict";
|
|
6159
|
-
|
|
7800
|
+
import_node_crypto9 = require("crypto");
|
|
6160
7801
|
fs11 = __toESM(require("fs"));
|
|
6161
7802
|
init_config();
|
|
6162
7803
|
init_router();
|
|
@@ -6350,12 +7991,12 @@ function finishChunk(ordinal, raw, rows, entity, firstRow = 0) {
|
|
|
6350
7991
|
const gz = gzipDeterministic(raw, { name: chunkName(ordinal) });
|
|
6351
7992
|
return {
|
|
6352
7993
|
ordinal,
|
|
6353
|
-
digest: (0,
|
|
7994
|
+
digest: (0, import_node_crypto10.createHash)("sha256").update(gz).digest("hex"),
|
|
6354
7995
|
bytes: gz.length,
|
|
6355
7996
|
rows,
|
|
6356
7997
|
entity,
|
|
6357
7998
|
rawBytes: raw.length,
|
|
6358
|
-
contentSha256: (0,
|
|
7999
|
+
contentSha256: (0, import_node_crypto10.createHash)("sha256").update(raw).digest("hex"),
|
|
6359
8000
|
firstRow,
|
|
6360
8001
|
gz
|
|
6361
8002
|
};
|
|
@@ -6395,11 +8036,11 @@ function crc32(data) {
|
|
|
6395
8036
|
crc = table[(crc ^ data[i]) & 255] ^ crc >>> 8;
|
|
6396
8037
|
return (crc ^ 4294967295) >>> 0;
|
|
6397
8038
|
}
|
|
6398
|
-
var
|
|
8039
|
+
var import_node_crypto10, import_node_zlib3, DEFAULT_CHUNK_BYTES, GZIP_LEVEL, chunkName, table;
|
|
6399
8040
|
var init_chunker = __esm({
|
|
6400
8041
|
"src/cli/platform/worldData/chunker.ts"() {
|
|
6401
8042
|
"use strict";
|
|
6402
|
-
|
|
8043
|
+
import_node_crypto10 = require("crypto");
|
|
6403
8044
|
import_node_zlib3 = require("zlib");
|
|
6404
8045
|
init_json();
|
|
6405
8046
|
DEFAULT_CHUNK_BYTES = 64 * 1024 * 1024;
|
|
@@ -6694,7 +8335,7 @@ var init_ingest = __esm({
|
|
|
6694
8335
|
});
|
|
6695
8336
|
|
|
6696
8337
|
// src/worlds/editSessions.ts
|
|
6697
|
-
var WORLDS, WorldEditClient;
|
|
8338
|
+
var WORLDS, WorldEditClient, TASK_EDITS, TaskEditClient;
|
|
6698
8339
|
var init_editSessions = __esm({
|
|
6699
8340
|
"src/worlds/editSessions.ts"() {
|
|
6700
8341
|
"use strict";
|
|
@@ -6726,6 +8367,22 @@ var init_editSessions = __esm({
|
|
|
6726
8367
|
return apiRequest(this.options, "POST", `${WORLDS}/${encodeURIComponent(slug)}/edits/rollback`, input);
|
|
6727
8368
|
}
|
|
6728
8369
|
};
|
|
8370
|
+
TASK_EDITS = "/api/public/world-task-edits";
|
|
8371
|
+
TaskEditClient = class {
|
|
8372
|
+
constructor(options = {}) {
|
|
8373
|
+
this.options = options;
|
|
8374
|
+
}
|
|
8375
|
+
options;
|
|
8376
|
+
status(task) {
|
|
8377
|
+
return apiRequest(this.options, "POST", `${TASK_EDITS}/status`, { task });
|
|
8378
|
+
}
|
|
8379
|
+
close(task, input = {}) {
|
|
8380
|
+
return apiRequest(this.options, "POST", `${TASK_EDITS}/close`, { task, ...input });
|
|
8381
|
+
}
|
|
8382
|
+
rollback(task, input) {
|
|
8383
|
+
return apiRequest(this.options, "POST", `${TASK_EDITS}/rollback`, { task, ...input });
|
|
8384
|
+
}
|
|
8385
|
+
};
|
|
6729
8386
|
}
|
|
6730
8387
|
});
|
|
6731
8388
|
|
|
@@ -6821,7 +8478,11 @@ var init_dryRun = __esm({
|
|
|
6821
8478
|
// src/worlds/index.ts
|
|
6822
8479
|
var worlds_exports = {};
|
|
6823
8480
|
__export(worlds_exports, {
|
|
6824
|
-
|
|
8481
|
+
ACTION_NAMES: () => ACTION_NAMES,
|
|
8482
|
+
ActionTracer: () => ActionTracer,
|
|
8483
|
+
AnthropicComputer: () => AnthropicComputer,
|
|
8484
|
+
AnthropicComputer20251124: () => AnthropicComputer20251124,
|
|
8485
|
+
ApiError: () => ApiError,
|
|
6825
8486
|
BROWSER_GONE_PATTERNS: () => BROWSER_GONE_PATTERNS,
|
|
6826
8487
|
BROWSER_TIERS: () => BROWSER_TIERS,
|
|
6827
8488
|
BrowserActionRecorder: () => BrowserActionRecorder,
|
|
@@ -6832,11 +8493,13 @@ __export(worlds_exports, {
|
|
|
6832
8493
|
CALL_BODY_LIMIT_LABEL: () => CALL_BODY_LIMIT_LABEL,
|
|
6833
8494
|
COMPUTER_USE_SPECS: () => COMPUTER_USE_SPECS,
|
|
6834
8495
|
CheckoutProvenance: () => CheckoutProvenance,
|
|
8496
|
+
ComputerAction: () => ComputerAction,
|
|
6835
8497
|
DEFAULT_BRANCH: () => DEFAULT_BRANCH,
|
|
6836
8498
|
DEFAULT_VIEWPORT: () => DEFAULT_VIEWPORT,
|
|
6837
8499
|
DRY_RUN_AGENT: () => DRY_RUN_AGENT,
|
|
6838
8500
|
DRY_RUN_KIND: () => DRY_RUN_KIND,
|
|
6839
8501
|
DetachedPushError: () => DetachedPushError,
|
|
8502
|
+
Display: () => Display,
|
|
6840
8503
|
DryRunOutcome: () => DryRunOutcome,
|
|
6841
8504
|
EVENT_BATCH_SIZE: () => EVENT_BATCH_SIZE,
|
|
6842
8505
|
EVENT_FLUSH_INTERVAL_MS: () => EVENT_FLUSH_INTERVAL_MS,
|
|
@@ -6846,17 +8509,34 @@ __export(worlds_exports, {
|
|
|
6846
8509
|
GatewayEvalsClient: () => GatewayEvalsClient,
|
|
6847
8510
|
HostedDryRunClient: () => HostedDryRunClient,
|
|
6848
8511
|
IDLE_WARNING_MINUTES: () => IDLE_WARNING_MINUTES,
|
|
8512
|
+
KEY_NAMES: () => KEY_NAMES,
|
|
8513
|
+
KeyChord: () => KeyChord,
|
|
8514
|
+
NOT_EXECUTED: () => NOT_EXECUTED,
|
|
6849
8515
|
NO_GRADER_REASON: () => NO_GRADER_REASON,
|
|
8516
|
+
NativeComputer: () => NativeComputer,
|
|
8517
|
+
OpenAIComputer: () => OpenAIComputer,
|
|
8518
|
+
OpenAIPreviewComputer: () => OpenAIPreviewComputer,
|
|
8519
|
+
PLATFORM_TIMEOUT_DEFAULT_MS: () => PLATFORM_TIMEOUT_DEFAULT_MS,
|
|
8520
|
+
PLATFORM_TIMEOUT_ENV: () => PLATFORM_TIMEOUT_ENV,
|
|
8521
|
+
PendingSafetyChecks: () => PendingSafetyChecks,
|
|
8522
|
+
PlatformTransport: () => PlatformTransport,
|
|
6850
8523
|
PushSlugConflict: () => PushSlugConflict,
|
|
6851
8524
|
RECOVER_BUDGET_MS: () => RECOVER_BUDGET_MS,
|
|
8525
|
+
SANDBOX_REQUEST_TIMEOUT_MS: () => SANDBOX_REQUEST_TIMEOUT_MS,
|
|
8526
|
+
SECRET_KEY: () => SECRET_KEY,
|
|
6852
8527
|
SESSION_STATES: () => SESSION_STATES,
|
|
8528
|
+
SPAN_PREFIX: () => SPAN_PREFIX,
|
|
6853
8529
|
STATUS_WAIT_CAP_SECONDS: () => STATUS_WAIT_CAP_SECONDS,
|
|
6854
8530
|
STRIP_PREFIX: () => STRIP_PREFIX,
|
|
6855
8531
|
SURFACE_KINDS: () => SURFACE_KINDS,
|
|
8532
|
+
Screen: () => Screen,
|
|
6856
8533
|
SecretScrubber: () => SecretScrubber,
|
|
6857
8534
|
TRANSFORMS: () => TRANSFORMS,
|
|
8535
|
+
TaskEditClient: () => TaskEditClient,
|
|
6858
8536
|
TaskRun: () => TaskRun,
|
|
6859
8537
|
TaskSessions: () => TaskSessions,
|
|
8538
|
+
TransportCause: () => TransportCause,
|
|
8539
|
+
UnreachableError: () => UnreachableError,
|
|
6860
8540
|
VERIFIER_REWARD_PREFIX: () => VERIFIER_REWARD_PREFIX,
|
|
6861
8541
|
WHITESPACE: () => WHITESPACE,
|
|
6862
8542
|
WorldBrowser: () => WorldBrowser,
|
|
@@ -6924,6 +8604,8 @@ __export(worlds_exports, {
|
|
|
6924
8604
|
parseToolCallRecord: () => parseToolCallRecord,
|
|
6925
8605
|
parseTransform: () => parseTransform,
|
|
6926
8606
|
parseWorldTaskRefs: () => parseWorldTaskRefs,
|
|
8607
|
+
platformTimeoutMs: () => platformTimeoutMs,
|
|
8608
|
+
playwrightKey: () => playwrightKey,
|
|
6927
8609
|
preserveForm: () => preserveForm,
|
|
6928
8610
|
propose: () => propose,
|
|
6929
8611
|
pull: () => pull,
|
|
@@ -6933,8 +8615,10 @@ __export(worlds_exports, {
|
|
|
6933
8615
|
pyText: () => pyText,
|
|
6934
8616
|
queryRows: () => queryRows,
|
|
6935
8617
|
queryRowsSearch: () => queryRowsSearch,
|
|
8618
|
+
readField: () => readField,
|
|
6936
8619
|
readLocalMeta: () => readLocalMeta,
|
|
6937
8620
|
readToolCallRecords: () => readToolCallRecords,
|
|
8621
|
+
rebaseConflicts: () => rebaseConflicts,
|
|
6938
8622
|
redactActionArgs: () => redactActionArgs,
|
|
6939
8623
|
redactionOf: () => redactionOf,
|
|
6940
8624
|
releaseConnection: () => releaseConnection,
|
|
@@ -6957,6 +8641,7 @@ __export(worlds_exports, {
|
|
|
6957
8641
|
toolCallsFromObservations: () => toolCallsFromObservations,
|
|
6958
8642
|
uiEntryUrl: () => uiEntryUrl,
|
|
6959
8643
|
uiUrl: () => uiUrl,
|
|
8644
|
+
uncommittedPaths: () => uncommittedPaths,
|
|
6960
8645
|
updateTask: () => updateTask,
|
|
6961
8646
|
upsertRunConfig: () => upsertRunConfig,
|
|
6962
8647
|
validateTask: () => validateTask,
|
|
@@ -6995,19 +8680,10 @@ function parseErrorBody(text2, limit = 600) {
|
|
|
6995
8680
|
code: stableCode
|
|
6996
8681
|
};
|
|
6997
8682
|
}
|
|
6998
|
-
async function apiRequest(options, method, path16, body) {
|
|
6999
|
-
const
|
|
7000
|
-
|
|
7001
|
-
|
|
7002
|
-
headers: {
|
|
7003
|
-
"content-type": "application/json",
|
|
7004
|
-
authorization: "Basic " + Buffer.from(`${publicKey}:${secretKey}`).toString("base64")
|
|
7005
|
-
},
|
|
7006
|
-
...body === void 0 ? {} : { body: JSON.stringify(body) }
|
|
7007
|
-
});
|
|
7008
|
-
const text2 = await res.text();
|
|
7009
|
-
if (!res.ok) throw new ApiError2(res.status, method, path16, text2);
|
|
7010
|
-
return JSON.parse(text2);
|
|
8683
|
+
async function apiRequest(options, method, path16, body, init3 = {}) {
|
|
8684
|
+
const reply = await new PlatformTransport(resolveEnv(options)).send(method, path16, body, init3);
|
|
8685
|
+
if (!reply.ok) throw new ApiError(reply.status, method, path16, reply.text);
|
|
8686
|
+
return JSON.parse(reply.text);
|
|
7011
8687
|
}
|
|
7012
8688
|
async function setEnvSecret(slug, key2, value, options = {}) {
|
|
7013
8689
|
return apiRequest(
|
|
@@ -7183,11 +8859,13 @@ async function resolveWorld(slugRef, slug, ref, pin, options) {
|
|
|
7183
8859
|
}
|
|
7184
8860
|
return world;
|
|
7185
8861
|
}
|
|
7186
|
-
var
|
|
8862
|
+
var ApiError, WorldTask, WorldSet;
|
|
7187
8863
|
var init_worlds = __esm({
|
|
7188
8864
|
"src/worlds/index.ts"() {
|
|
7189
8865
|
"use strict";
|
|
7190
|
-
|
|
8866
|
+
init_transport();
|
|
8867
|
+
init_transport();
|
|
8868
|
+
init_session2();
|
|
7191
8869
|
init_sessionList();
|
|
7192
8870
|
init_sessionContract();
|
|
7193
8871
|
init_taskRef();
|
|
@@ -7199,6 +8877,7 @@ var init_worlds = __esm({
|
|
|
7199
8877
|
init_evals();
|
|
7200
8878
|
init_browser();
|
|
7201
8879
|
init_browserReconnect();
|
|
8880
|
+
init_nativeComputer();
|
|
7202
8881
|
init_hub();
|
|
7203
8882
|
init_validate();
|
|
7204
8883
|
init_describe();
|
|
@@ -7210,15 +8889,17 @@ var init_worlds = __esm({
|
|
|
7210
8889
|
init_sandbox();
|
|
7211
8890
|
init_editSessions();
|
|
7212
8891
|
init_dryRun();
|
|
7213
|
-
|
|
7214
|
-
constructor(status, method, path16,
|
|
7215
|
-
const parsed = parseErrorBody(
|
|
8892
|
+
ApiError = class extends Error {
|
|
8893
|
+
constructor(status, method, path16, text2) {
|
|
8894
|
+
const parsed = parseErrorBody(text2);
|
|
7216
8895
|
super(`${method} ${path16} -> ${status}: ${parsed.detail}`);
|
|
7217
8896
|
this.status = status;
|
|
8897
|
+
this.text = text2;
|
|
7218
8898
|
this.name = "ApiError";
|
|
7219
8899
|
this.code = parsed.code;
|
|
7220
8900
|
}
|
|
7221
8901
|
status;
|
|
8902
|
+
text;
|
|
7222
8903
|
code;
|
|
7223
8904
|
};
|
|
7224
8905
|
WorldTask = class {
|
|
@@ -7263,7 +8944,7 @@ var init_worlds = __esm({
|
|
|
7263
8944
|
* worlds/session.ts.
|
|
7264
8945
|
*/
|
|
7265
8946
|
async open(task, opts = {}) {
|
|
7266
|
-
const { openSession: openSession2 } = await Promise.resolve().then(() => (
|
|
8947
|
+
const { openSession: openSession2 } = await Promise.resolve().then(() => (init_session2(), session_exports2));
|
|
7267
8948
|
return openSession2(this.slug, {
|
|
7268
8949
|
task,
|
|
7269
8950
|
versionId: this.version.versionId,
|
|
@@ -7299,8 +8980,12 @@ var init_worlds = __esm({
|
|
|
7299
8980
|
// src/index.ts
|
|
7300
8981
|
var src_exports = {};
|
|
7301
8982
|
__export(src_exports, {
|
|
8983
|
+
ACTION_NAMES: () => ACTION_NAMES,
|
|
7302
8984
|
AGENT_ID_KEY: () => AGENT_ID_KEY,
|
|
7303
|
-
|
|
8985
|
+
ActionTracer: () => ActionTracer,
|
|
8986
|
+
AnthropicComputer: () => AnthropicComputer,
|
|
8987
|
+
AnthropicComputer20251124: () => AnthropicComputer20251124,
|
|
8988
|
+
ApiError: () => ApiError,
|
|
7304
8989
|
BROWSER_GONE_PATTERNS: () => BROWSER_GONE_PATTERNS,
|
|
7305
8990
|
BROWSER_TIERS: () => BROWSER_TIERS,
|
|
7306
8991
|
BrowserActionRecorder: () => BrowserActionRecorder,
|
|
@@ -7311,12 +8996,14 @@ __export(src_exports, {
|
|
|
7311
8996
|
CALL_BODY_LIMIT_LABEL: () => CALL_BODY_LIMIT_LABEL,
|
|
7312
8997
|
COMPUTER_USE_SPECS: () => COMPUTER_USE_SPECS,
|
|
7313
8998
|
CheckoutProvenance: () => CheckoutProvenance,
|
|
8999
|
+
ComputerAction: () => ComputerAction,
|
|
7314
9000
|
DEFAULT_BRANCH: () => DEFAULT_BRANCH,
|
|
7315
9001
|
DEFAULT_TIMEOUT_SECONDS: () => DEFAULT_TIMEOUT_SECONDS,
|
|
7316
9002
|
DEFAULT_VIEWPORT: () => DEFAULT_VIEWPORT,
|
|
7317
9003
|
DRY_RUN_AGENT: () => DRY_RUN_AGENT,
|
|
7318
9004
|
DRY_RUN_KIND: () => DRY_RUN_KIND,
|
|
7319
9005
|
DetachedPushError: () => DetachedPushError,
|
|
9006
|
+
Display: () => Display,
|
|
7320
9007
|
DriftError: () => DriftError,
|
|
7321
9008
|
DryRunOutcome: () => DryRunOutcome,
|
|
7322
9009
|
ENV_GATEWAY_HOST: () => ENV_GATEWAY_HOST,
|
|
@@ -7344,10 +9031,20 @@ __export(src_exports, {
|
|
|
7344
9031
|
GatewayToolBlockedError: () => GatewayToolBlockedError,
|
|
7345
9032
|
HostedDryRunClient: () => HostedDryRunClient,
|
|
7346
9033
|
IDLE_WARNING_MINUTES: () => IDLE_WARNING_MINUTES,
|
|
9034
|
+
KEY_NAMES: () => KEY_NAMES,
|
|
9035
|
+
KeyChord: () => KeyChord,
|
|
9036
|
+
NOT_EXECUTED: () => NOT_EXECUTED,
|
|
7347
9037
|
NO_GRADER_REASON: () => NO_GRADER_REASON,
|
|
9038
|
+
NativeComputer: () => NativeComputer,
|
|
9039
|
+
OpenAIComputer: () => OpenAIComputer,
|
|
9040
|
+
OpenAIPreviewComputer: () => OpenAIPreviewComputer,
|
|
9041
|
+
PLATFORM_TIMEOUT_DEFAULT_MS: () => PLATFORM_TIMEOUT_DEFAULT_MS,
|
|
9042
|
+
PLATFORM_TIMEOUT_ENV: () => PLATFORM_TIMEOUT_ENV,
|
|
9043
|
+
PendingSafetyChecks: () => PendingSafetyChecks,
|
|
7348
9044
|
Persona: () => Persona,
|
|
7349
9045
|
PersonaError: () => PersonaError,
|
|
7350
9046
|
PersonasClient: () => PersonasClient,
|
|
9047
|
+
PlatformTransport: () => PlatformTransport,
|
|
7351
9048
|
PushSlugConflict: () => PushSlugConflict,
|
|
7352
9049
|
RECOVER_BUDGET_MS: () => RECOVER_BUDGET_MS,
|
|
7353
9050
|
REPLAY_ENVIRONMENT: () => REPLAY_ENVIRONMENT,
|
|
@@ -7357,7 +9054,10 @@ __export(src_exports, {
|
|
|
7357
9054
|
ReplayReport: () => ReplayReport,
|
|
7358
9055
|
ReplaySuite: () => ReplaySuite,
|
|
7359
9056
|
ReplayTask: () => ReplayTask,
|
|
9057
|
+
SANDBOX_REQUEST_TIMEOUT_MS: () => SANDBOX_REQUEST_TIMEOUT_MS,
|
|
9058
|
+
SECRET_KEY: () => SECRET_KEY,
|
|
7360
9059
|
SESSION_STATES: () => SESSION_STATES,
|
|
9060
|
+
SPAN_PREFIX: () => SPAN_PREFIX,
|
|
7361
9061
|
STATUS_WAIT_CAP_SECONDS: () => STATUS_WAIT_CAP_SECONDS,
|
|
7362
9062
|
STRIP_PREFIX: () => STRIP_PREFIX,
|
|
7363
9063
|
SUCCESS_METRIC_NAME_KEY: () => SUCCESS_METRIC_NAME_KEY,
|
|
@@ -7365,16 +9065,20 @@ __export(src_exports, {
|
|
|
7365
9065
|
SURFACE_KINDS: () => SURFACE_KINDS,
|
|
7366
9066
|
ScoreError: () => ScoreError,
|
|
7367
9067
|
ScoresClient: () => ScoresClient,
|
|
9068
|
+
Screen: () => Screen,
|
|
7368
9069
|
SecretScrubber: () => SecretScrubber,
|
|
7369
9070
|
SessionLoadError: () => SessionLoadError,
|
|
7370
9071
|
SessionRecording: () => SessionRecording,
|
|
7371
9072
|
SessionTrace: () => SessionTrace,
|
|
7372
9073
|
StubMissError: () => StubMissError,
|
|
7373
9074
|
TRANSFORMS: () => TRANSFORMS,
|
|
9075
|
+
TaskEditClient: () => TaskEditClient,
|
|
7374
9076
|
TaskRun: () => TaskRun,
|
|
7375
9077
|
TaskSessions: () => TaskSessions,
|
|
7376
9078
|
ToolStubRegistry: () => ToolStubRegistry,
|
|
7377
9079
|
TraceDiff: () => TraceDiff,
|
|
9080
|
+
TransportCause: () => TransportCause,
|
|
9081
|
+
UnreachableError: () => UnreachableError,
|
|
7378
9082
|
UserProfileError: () => UserProfileError,
|
|
7379
9083
|
UsersClient: () => UsersClient,
|
|
7380
9084
|
VERIFIER_REWARD_PREFIX: () => VERIFIER_REWARD_PREFIX,
|
|
@@ -7469,6 +9173,8 @@ __export(src_exports, {
|
|
|
7469
9173
|
parseTransform: () => parseTransform,
|
|
7470
9174
|
parseWorldTaskRefs: () => parseWorldTaskRefs,
|
|
7471
9175
|
personas: () => personas,
|
|
9176
|
+
platformTimeoutMs: () => platformTimeoutMs,
|
|
9177
|
+
playwrightKey: () => playwrightKey,
|
|
7472
9178
|
preserveForm: () => preserveForm,
|
|
7473
9179
|
propose: () => propose,
|
|
7474
9180
|
pull: () => pull,
|
|
@@ -7478,8 +9184,10 @@ __export(src_exports, {
|
|
|
7478
9184
|
pyText: () => pyText,
|
|
7479
9185
|
queryRows: () => queryRows,
|
|
7480
9186
|
queryRowsSearch: () => queryRowsSearch,
|
|
9187
|
+
readField: () => readField,
|
|
7481
9188
|
readLocalMeta: () => readLocalMeta,
|
|
7482
9189
|
readToolCallRecords: () => readToolCallRecords,
|
|
9190
|
+
rebaseConflicts: () => rebaseConflicts,
|
|
7483
9191
|
redactActionArgs: () => redactActionArgs,
|
|
7484
9192
|
redactionOf: () => redactionOf,
|
|
7485
9193
|
registerArtifact: () => registerArtifact,
|
|
@@ -7519,6 +9227,7 @@ __export(src_exports, {
|
|
|
7519
9227
|
tracing: () => tracing,
|
|
7520
9228
|
uiEntryUrl: () => uiEntryUrl,
|
|
7521
9229
|
uiUrl: () => uiUrl,
|
|
9230
|
+
uncommittedPaths: () => uncommittedPaths,
|
|
7522
9231
|
updateTask: () => updateTask,
|
|
7523
9232
|
upsertRunConfig: () => upsertRunConfig,
|
|
7524
9233
|
users: () => users,
|
|
@@ -9922,7 +11631,7 @@ var gateway = {
|
|
|
9922
11631
|
init_users();
|
|
9923
11632
|
init_scores();
|
|
9924
11633
|
init_worlds();
|
|
9925
|
-
|
|
11634
|
+
init_session2();
|
|
9926
11635
|
|
|
9927
11636
|
// src/files/index.ts
|
|
9928
11637
|
var files_exports = {};
|
|
@@ -9948,7 +11657,7 @@ __export(files_exports, {
|
|
|
9948
11657
|
uploadBytes: () => uploadBytes,
|
|
9949
11658
|
uploadFile: () => uploadFile
|
|
9950
11659
|
});
|
|
9951
|
-
var
|
|
11660
|
+
var import_node_crypto11 = require("crypto");
|
|
9952
11661
|
var fs13 = __toESM(require("fs"));
|
|
9953
11662
|
var path12 = __toESM(require("path"));
|
|
9954
11663
|
var import_node_stream = require("stream");
|
|
@@ -10014,7 +11723,7 @@ async function confirmUpload(options = {}, fileId, ok = true) {
|
|
|
10014
11723
|
return apiRequest(options, "POST", `${BASE}/confirm`, { fileId, ok });
|
|
10015
11724
|
}
|
|
10016
11725
|
async function sha256Base64(localPath) {
|
|
10017
|
-
const hash = (0,
|
|
11726
|
+
const hash = (0, import_node_crypto11.createHash)("sha256");
|
|
10018
11727
|
for await (const chunk of fs13.createReadStream(localPath)) hash.update(chunk);
|
|
10019
11728
|
return hash.digest("base64");
|
|
10020
11729
|
}
|
|
@@ -10099,7 +11808,7 @@ async function uploadBytes(options = {}, bytes, targetPath, upload = {}) {
|
|
|
10099
11808
|
if (!bytes.length) throw new Error("nothing to upload: the content is empty");
|
|
10100
11809
|
const target = drivePath(targetPath);
|
|
10101
11810
|
const contentType = upload.contentType ?? contentTypeFor(target);
|
|
10102
|
-
const sha2562 = (0,
|
|
11811
|
+
const sha2562 = (0, import_node_crypto11.createHash)("sha256").update(bytes).digest("base64");
|
|
10103
11812
|
const granted = await requestUpload(options, { path: target, contentLength: bytes.length, contentType, sha256: sha2562, ...upload.overwrite ? { overwrite: true } : {} });
|
|
10104
11813
|
try {
|
|
10105
11814
|
await putPresigned(granted.uploadUrl, new Uint8Array(bytes), { contentType, contentLength: bytes.length, sha256: sha2562 });
|
|
@@ -10352,10 +12061,10 @@ function swapValue(text2, needle, replacement) {
|
|
|
10352
12061
|
}
|
|
10353
12062
|
|
|
10354
12063
|
// src/hooks/standInDigits.ts
|
|
10355
|
-
var
|
|
12064
|
+
var import_node_crypto12 = require("crypto");
|
|
10356
12065
|
function standInDigits(realDigits, identityName) {
|
|
10357
12066
|
if (!realDigits) return "";
|
|
10358
|
-
const digest = (0,
|
|
12067
|
+
const digest = (0, import_node_crypto12.createHash)("sha256").update(`${identityName}:${realDigits}`).digest("hex");
|
|
10359
12068
|
let digits = "";
|
|
10360
12069
|
for (let i = 0; i < realDigits.length; i++)
|
|
10361
12070
|
digits += String(parseInt(digest[i % digest.length], 16) % 10);
|
|
@@ -10389,7 +12098,7 @@ var DeclaredStandIn = class _DeclaredStandIn {
|
|
|
10389
12098
|
};
|
|
10390
12099
|
|
|
10391
12100
|
// src/hooks/alias.ts
|
|
10392
|
-
var
|
|
12101
|
+
var import_node_crypto13 = require("crypto");
|
|
10393
12102
|
var GIVEN = [
|
|
10394
12103
|
"John",
|
|
10395
12104
|
"Mary",
|
|
@@ -10580,7 +12289,7 @@ function findKind(kind, text2) {
|
|
|
10580
12289
|
return out;
|
|
10581
12290
|
}
|
|
10582
12291
|
function newRunKey() {
|
|
10583
|
-
return (0,
|
|
12292
|
+
return (0, import_node_crypto13.randomBytes)(32).toString("hex");
|
|
10584
12293
|
}
|
|
10585
12294
|
function canonical(kind, value) {
|
|
10586
12295
|
const text2 = String(value).normalize("NFKC").trim();
|
|
@@ -10637,7 +12346,7 @@ function explodeIp(text2) {
|
|
|
10637
12346
|
return groups.map((g) => g.padStart(4, "0")).join(":") + zone;
|
|
10638
12347
|
}
|
|
10639
12348
|
function index(runKey, kind, value, salt = "") {
|
|
10640
|
-
const digest = (0,
|
|
12349
|
+
const digest = (0, import_node_crypto13.createHmac)("sha256", Buffer.from(runKey, "hex")).update(`${kind}:${value}:${salt}`, "utf8").digest();
|
|
10641
12350
|
return digest.readBigUInt64BE(0);
|
|
10642
12351
|
}
|
|
10643
12352
|
var pick = (pool, n) => pool[Number(n % BigInt(pool.length))];
|
|
@@ -10661,7 +12370,7 @@ function nameParts(name) {
|
|
|
10661
12370
|
function format(template, parts2) {
|
|
10662
12371
|
return template.replace(/\{(\w+)\}/g, (_, key2) => parts2[key2] ?? "").trim();
|
|
10663
12372
|
}
|
|
10664
|
-
var
|
|
12373
|
+
var pair2 = (real, fake, template) => [
|
|
10665
12374
|
format(template, real),
|
|
10666
12375
|
format(template, fake)
|
|
10667
12376
|
];
|
|
@@ -10721,7 +12430,7 @@ function namePairs(real, fake) {
|
|
|
10721
12430
|
const out = [[real, fake]];
|
|
10722
12431
|
if (realParts.given && realParts.surname) {
|
|
10723
12432
|
for (const template of NAME_FORMS) {
|
|
10724
|
-
const p =
|
|
12433
|
+
const p = pair2(realParts, fakeParts, template);
|
|
10725
12434
|
if (p[0].length > 2 && !p[0].includes("{")) out.push(p);
|
|
10726
12435
|
}
|
|
10727
12436
|
}
|
|
@@ -10759,7 +12468,7 @@ function emailPairs(real, fake) {
|
|
|
10759
12468
|
};
|
|
10760
12469
|
const out = [[real, fake]];
|
|
10761
12470
|
for (const template of EMAIL_FORMS) {
|
|
10762
|
-
const p =
|
|
12471
|
+
const p = pair2(realParts, fakeParts, template);
|
|
10763
12472
|
if (p[0].length > 2) out.push(p);
|
|
10764
12473
|
}
|
|
10765
12474
|
return dedupe(out);
|
|
@@ -11171,7 +12880,7 @@ var AliasMap = class _AliasMap {
|
|
|
11171
12880
|
const existing = this.aliases.get(key2);
|
|
11172
12881
|
if (existing) return existing.display;
|
|
11173
12882
|
if (this.aliasDigests.has(digest.toLowerCase())) return digest;
|
|
11174
|
-
const standIn = "sha256:" + (0,
|
|
12883
|
+
const standIn = "sha256:" + (0, import_node_crypto13.createHmac)("sha256", Buffer.from(this.runKey, "hex")).update(digest, "utf8").digest("hex");
|
|
11175
12884
|
this.aliasDigests.add(standIn.toLowerCase());
|
|
11176
12885
|
const alias = {
|
|
11177
12886
|
kind: "digest",
|
|
@@ -11210,9 +12919,9 @@ var AliasMap = class _AliasMap {
|
|
|
11210
12919
|
});
|
|
11211
12920
|
if (alias.role === "private") {
|
|
11212
12921
|
for (const slug of this.slugs) {
|
|
11213
|
-
const standIn = "sha256:" + (0,
|
|
12922
|
+
const standIn = "sha256:" + (0, import_node_crypto13.createHash)("sha256").update(`${slug}:${canonical(alias.kind, alias.display)}`, "utf8").digest("hex");
|
|
11214
12923
|
alias.variants.push([
|
|
11215
|
-
"sha256:" + (0,
|
|
12924
|
+
"sha256:" + (0, import_node_crypto13.createHash)("sha256").update(`${slug}:${alias.canonical}`, "utf8").digest("hex"),
|
|
11216
12925
|
standIn
|
|
11217
12926
|
]);
|
|
11218
12927
|
this.aliasDigests.add(standIn.toLowerCase());
|
|
@@ -12027,7 +13736,7 @@ function inputSchema(shorthand, position) {
|
|
|
12027
13736
|
`${position}.input: expected a table of field = "type"`
|
|
12028
13737
|
);
|
|
12029
13738
|
const properties = {};
|
|
12030
|
-
const
|
|
13739
|
+
const required2 = [];
|
|
12031
13740
|
for (const [name, raw] of Object.entries(shorthand)) {
|
|
12032
13741
|
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name))
|
|
12033
13742
|
throw new HookConfigError(
|
|
@@ -12061,9 +13770,9 @@ function inputSchema(shorthand, position) {
|
|
|
12061
13770
|
`${position}.input.${name}: expected "type" or a schema table`
|
|
12062
13771
|
);
|
|
12063
13772
|
properties[name] = schema;
|
|
12064
|
-
if (!optional)
|
|
13773
|
+
if (!optional) required2.push(name);
|
|
12065
13774
|
}
|
|
12066
|
-
return { type: "object", properties, required };
|
|
13775
|
+
return { type: "object", properties, required: required2 };
|
|
12067
13776
|
}
|
|
12068
13777
|
function placeholders(value) {
|
|
12069
13778
|
if (typeof value === "string")
|
|
@@ -14208,7 +15917,7 @@ var RedactionAudit = class _RedactionAudit {
|
|
|
14208
15917
|
};
|
|
14209
15918
|
|
|
14210
15919
|
// src/hooks/run.ts
|
|
14211
|
-
var
|
|
15920
|
+
var import_node_crypto14 = require("crypto");
|
|
14212
15921
|
var fs17 = __toESM(require("fs"));
|
|
14213
15922
|
var path15 = __toESM(require("path"));
|
|
14214
15923
|
var BLOCKING_EVENTS = [
|
|
@@ -14252,7 +15961,7 @@ var HookRun = class _HookRun {
|
|
|
14252
15961
|
source;
|
|
14253
15962
|
constructor(config, options) {
|
|
14254
15963
|
this.config = config;
|
|
14255
|
-
this.runId = options.runId ?? `run-${(0,
|
|
15964
|
+
this.runId = options.runId ?? `run-${(0, import_node_crypto14.randomBytes)(6).toString("hex")}`;
|
|
14256
15965
|
this.runKey = options.runKey ?? newRunKey();
|
|
14257
15966
|
this.alias = new AliasMap(this.runKey, options.slugs ?? config.aliasSlugs, {
|
|
14258
15967
|
publicLayerWins: config.aliasPublicLayerWins,
|
|
@@ -14887,11 +16596,20 @@ init_identity();
|
|
|
14887
16596
|
var tracing_exports = {};
|
|
14888
16597
|
__export(tracing_exports, {
|
|
14889
16598
|
IdentitySpanProcessor: () => IdentitySpanProcessor,
|
|
16599
|
+
MAX_MEDIA_BYTES: () => MAX_MEDIA_BYTES,
|
|
16600
|
+
MediaReference: () => MediaReference,
|
|
16601
|
+
MediaUploadError: () => MediaUploadError,
|
|
16602
|
+
MediaUploader: () => MediaUploader,
|
|
16603
|
+
SECRET_KEYS: () => SECRET_KEYS,
|
|
14890
16604
|
SESSION_ID_ATTRIBUTE: () => SESSION_ID_ATTRIBUTE,
|
|
16605
|
+
SecretRedactingSpanProcessor: () => SecretRedactingSpanProcessor,
|
|
14891
16606
|
SessionSpanProcessor: () => SessionSpanProcessor,
|
|
16607
|
+
SpanSecrets: () => SpanSecrets,
|
|
14892
16608
|
USER_ID_ATTRIBUTE: () => USER_ID_ATTRIBUTE,
|
|
16609
|
+
WORLD_SESSION_ID_ATTRIBUTE: () => WORLD_SESSION_ID_ATTRIBUTE,
|
|
14893
16610
|
flush: () => flush,
|
|
14894
16611
|
getAmbientSessionId: () => getAmbientSessionId,
|
|
16612
|
+
getCurrentWorldSessionId: () => getCurrentWorldSessionId,
|
|
14895
16613
|
identify: () => identify,
|
|
14896
16614
|
init: () => init2,
|
|
14897
16615
|
initIsolated: () => initIsolated,
|
|
@@ -14904,11 +16622,13 @@ __export(tracing_exports, {
|
|
|
14904
16622
|
resetAmbientUser: () => resetAmbientUser,
|
|
14905
16623
|
resolveUserId: () => resolveUserId,
|
|
14906
16624
|
shutdown: () => shutdown2,
|
|
14907
|
-
withSession: () => withSession
|
|
16625
|
+
withSession: () => withSession,
|
|
16626
|
+
withWorldSession: () => withWorldSession
|
|
14908
16627
|
});
|
|
14909
16628
|
init_init();
|
|
14910
16629
|
init_identity();
|
|
14911
|
-
|
|
16630
|
+
init_session();
|
|
16631
|
+
init_secrets();
|
|
14912
16632
|
|
|
14913
16633
|
// src/tracing/observe.ts
|
|
14914
16634
|
var import_api3 = require("@opentelemetry/api");
|
|
@@ -15167,6 +16887,9 @@ async function* observeClaude(stream, options) {
|
|
|
15167
16887
|
}
|
|
15168
16888
|
}
|
|
15169
16889
|
|
|
16890
|
+
// src/tracing/index.ts
|
|
16891
|
+
init_media();
|
|
16892
|
+
|
|
15170
16893
|
// src/index.ts
|
|
15171
16894
|
var tracing = {
|
|
15172
16895
|
...tracing_exports,
|
|
@@ -15186,7 +16909,11 @@ var tracing = {
|
|
|
15186
16909
|
};
|
|
15187
16910
|
// Annotate the CommonJS export names for ESM import in node:
|
|
15188
16911
|
0 && (module.exports = {
|
|
16912
|
+
ACTION_NAMES,
|
|
15189
16913
|
AGENT_ID_KEY,
|
|
16914
|
+
ActionTracer,
|
|
16915
|
+
AnthropicComputer,
|
|
16916
|
+
AnthropicComputer20251124,
|
|
15190
16917
|
ApiError,
|
|
15191
16918
|
BROWSER_GONE_PATTERNS,
|
|
15192
16919
|
BROWSER_TIERS,
|
|
@@ -15198,12 +16925,14 @@ var tracing = {
|
|
|
15198
16925
|
CALL_BODY_LIMIT_LABEL,
|
|
15199
16926
|
COMPUTER_USE_SPECS,
|
|
15200
16927
|
CheckoutProvenance,
|
|
16928
|
+
ComputerAction,
|
|
15201
16929
|
DEFAULT_BRANCH,
|
|
15202
16930
|
DEFAULT_TIMEOUT_SECONDS,
|
|
15203
16931
|
DEFAULT_VIEWPORT,
|
|
15204
16932
|
DRY_RUN_AGENT,
|
|
15205
16933
|
DRY_RUN_KIND,
|
|
15206
16934
|
DetachedPushError,
|
|
16935
|
+
Display,
|
|
15207
16936
|
DriftError,
|
|
15208
16937
|
DryRunOutcome,
|
|
15209
16938
|
ENV_GATEWAY_HOST,
|
|
@@ -15231,10 +16960,20 @@ var tracing = {
|
|
|
15231
16960
|
GatewayToolBlockedError,
|
|
15232
16961
|
HostedDryRunClient,
|
|
15233
16962
|
IDLE_WARNING_MINUTES,
|
|
16963
|
+
KEY_NAMES,
|
|
16964
|
+
KeyChord,
|
|
16965
|
+
NOT_EXECUTED,
|
|
15234
16966
|
NO_GRADER_REASON,
|
|
16967
|
+
NativeComputer,
|
|
16968
|
+
OpenAIComputer,
|
|
16969
|
+
OpenAIPreviewComputer,
|
|
16970
|
+
PLATFORM_TIMEOUT_DEFAULT_MS,
|
|
16971
|
+
PLATFORM_TIMEOUT_ENV,
|
|
16972
|
+
PendingSafetyChecks,
|
|
15235
16973
|
Persona,
|
|
15236
16974
|
PersonaError,
|
|
15237
16975
|
PersonasClient,
|
|
16976
|
+
PlatformTransport,
|
|
15238
16977
|
PushSlugConflict,
|
|
15239
16978
|
RECOVER_BUDGET_MS,
|
|
15240
16979
|
REPLAY_ENVIRONMENT,
|
|
@@ -15244,7 +16983,10 @@ var tracing = {
|
|
|
15244
16983
|
ReplayReport,
|
|
15245
16984
|
ReplaySuite,
|
|
15246
16985
|
ReplayTask,
|
|
16986
|
+
SANDBOX_REQUEST_TIMEOUT_MS,
|
|
16987
|
+
SECRET_KEY,
|
|
15247
16988
|
SESSION_STATES,
|
|
16989
|
+
SPAN_PREFIX,
|
|
15248
16990
|
STATUS_WAIT_CAP_SECONDS,
|
|
15249
16991
|
STRIP_PREFIX,
|
|
15250
16992
|
SUCCESS_METRIC_NAME_KEY,
|
|
@@ -15252,16 +16994,20 @@ var tracing = {
|
|
|
15252
16994
|
SURFACE_KINDS,
|
|
15253
16995
|
ScoreError,
|
|
15254
16996
|
ScoresClient,
|
|
16997
|
+
Screen,
|
|
15255
16998
|
SecretScrubber,
|
|
15256
16999
|
SessionLoadError,
|
|
15257
17000
|
SessionRecording,
|
|
15258
17001
|
SessionTrace,
|
|
15259
17002
|
StubMissError,
|
|
15260
17003
|
TRANSFORMS,
|
|
17004
|
+
TaskEditClient,
|
|
15261
17005
|
TaskRun,
|
|
15262
17006
|
TaskSessions,
|
|
15263
17007
|
ToolStubRegistry,
|
|
15264
17008
|
TraceDiff,
|
|
17009
|
+
TransportCause,
|
|
17010
|
+
UnreachableError,
|
|
15265
17011
|
UserProfileError,
|
|
15266
17012
|
UsersClient,
|
|
15267
17013
|
VERIFIER_REWARD_PREFIX,
|
|
@@ -15356,6 +17102,8 @@ var tracing = {
|
|
|
15356
17102
|
parseTransform,
|
|
15357
17103
|
parseWorldTaskRefs,
|
|
15358
17104
|
personas,
|
|
17105
|
+
platformTimeoutMs,
|
|
17106
|
+
playwrightKey,
|
|
15359
17107
|
preserveForm,
|
|
15360
17108
|
propose,
|
|
15361
17109
|
pull,
|
|
@@ -15365,8 +17113,10 @@ var tracing = {
|
|
|
15365
17113
|
pyText,
|
|
15366
17114
|
queryRows,
|
|
15367
17115
|
queryRowsSearch,
|
|
17116
|
+
readField,
|
|
15368
17117
|
readLocalMeta,
|
|
15369
17118
|
readToolCallRecords,
|
|
17119
|
+
rebaseConflicts,
|
|
15370
17120
|
redactActionArgs,
|
|
15371
17121
|
redactionOf,
|
|
15372
17122
|
registerArtifact,
|
|
@@ -15406,6 +17156,7 @@ var tracing = {
|
|
|
15406
17156
|
tracing,
|
|
15407
17157
|
uiEntryUrl,
|
|
15408
17158
|
uiUrl,
|
|
17159
|
+
uncommittedPaths,
|
|
15409
17160
|
updateTask,
|
|
15410
17161
|
upsertRunConfig,
|
|
15411
17162
|
users,
|