@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/worlds/index.js
CHANGED
|
@@ -42,6 +42,115 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
42
42
|
));
|
|
43
43
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
44
44
|
|
|
45
|
+
// src/worlds/transport.ts
|
|
46
|
+
function platformTimeoutMs(env = process.env) {
|
|
47
|
+
const raw = env[PLATFORM_TIMEOUT_ENV];
|
|
48
|
+
if (raw === void 0 || raw === "") return PLATFORM_TIMEOUT_DEFAULT_MS;
|
|
49
|
+
const value = Number(raw);
|
|
50
|
+
if (Number.isInteger(value) && value > 0) return value;
|
|
51
|
+
throw new Error(`${PLATFORM_TIMEOUT_ENV} must be a positive whole number of milliseconds, not \`${raw}\`.`);
|
|
52
|
+
}
|
|
53
|
+
var PLATFORM_TIMEOUT_ENV, PLATFORM_TIMEOUT_DEFAULT_MS, CHECK_HOST, RETRY, CAUSES, UNKNOWN_CAUSE, TransportCause, UnreachableError, PlatformTransport;
|
|
54
|
+
var init_transport = __esm({
|
|
55
|
+
"src/worlds/transport.ts"() {
|
|
56
|
+
"use strict";
|
|
57
|
+
PLATFORM_TIMEOUT_ENV = "GATEWAY_TIMEOUT_MS";
|
|
58
|
+
PLATFORM_TIMEOUT_DEFAULT_MS = 12e4;
|
|
59
|
+
CHECK_HOST = "Check GATEWAY_HOST (or --host) points at a running platform, then retry.";
|
|
60
|
+
RETRY = "Retry; if it repeats, check the network between here and the platform.";
|
|
61
|
+
CAUSES = {
|
|
62
|
+
ECONNREFUSED: { reason: "connection refused", next: CHECK_HOST },
|
|
63
|
+
ENOTFOUND: { reason: "DNS lookup failed", next: CHECK_HOST },
|
|
64
|
+
EAI_AGAIN: { reason: "DNS lookup failed", next: CHECK_HOST },
|
|
65
|
+
ETIMEDOUT: { reason: "connect timed out", next: CHECK_HOST },
|
|
66
|
+
UND_ERR_CONNECT_TIMEOUT: { reason: "connect timed out", next: CHECK_HOST },
|
|
67
|
+
EHOSTUNREACH: { reason: "host unreachable", next: CHECK_HOST },
|
|
68
|
+
ENETUNREACH: { reason: "network unreachable", next: RETRY },
|
|
69
|
+
ECONNRESET: { reason: "connection dropped", next: RETRY },
|
|
70
|
+
UND_ERR_SOCKET: { reason: "connection dropped", next: RETRY },
|
|
71
|
+
EPIPE: { reason: "connection dropped", next: RETRY }
|
|
72
|
+
};
|
|
73
|
+
UNKNOWN_CAUSE = { reason: "network error", next: CHECK_HOST };
|
|
74
|
+
TransportCause = class _TransportCause {
|
|
75
|
+
constructor(reason, detail, next) {
|
|
76
|
+
this.reason = reason;
|
|
77
|
+
this.detail = detail;
|
|
78
|
+
this.next = next;
|
|
79
|
+
}
|
|
80
|
+
reason;
|
|
81
|
+
detail;
|
|
82
|
+
next;
|
|
83
|
+
static timeout(timeoutMs) {
|
|
84
|
+
return new _TransportCause(
|
|
85
|
+
`timed out after ${timeoutMs / 1e3}s`,
|
|
86
|
+
null,
|
|
87
|
+
`Retry; if the platform is slow, raise ${PLATFORM_TIMEOUT_ENV} (milliseconds per request).`
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
static of(error) {
|
|
91
|
+
const cause = error instanceof Error && error.cause instanceof Error ? error.cause : void 0;
|
|
92
|
+
const code = cause && "code" in cause && typeof cause.code === "string" ? cause.code : null;
|
|
93
|
+
const message = cause?.message ?? (error instanceof Error ? error.message : String(error));
|
|
94
|
+
const known = code && CAUSES[code] || UNKNOWN_CAUSE;
|
|
95
|
+
return new _TransportCause(known.reason, code ? `${code}: ${message}` : message, known.next);
|
|
96
|
+
}
|
|
97
|
+
describe() {
|
|
98
|
+
return this.detail === null ? this.reason : `${this.reason} (${this.detail})`;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
UnreachableError = class extends Error {
|
|
102
|
+
constructor(host, method, route, failure) {
|
|
103
|
+
super(`${method} ${route}: no answer from ${host}: ${failure.describe()}. ${failure.next}`);
|
|
104
|
+
this.host = host;
|
|
105
|
+
this.method = method;
|
|
106
|
+
this.route = route;
|
|
107
|
+
this.failure = failure;
|
|
108
|
+
this.name = "UnreachableError";
|
|
109
|
+
}
|
|
110
|
+
host;
|
|
111
|
+
method;
|
|
112
|
+
route;
|
|
113
|
+
failure;
|
|
114
|
+
};
|
|
115
|
+
PlatformTransport = class {
|
|
116
|
+
constructor(endpoint, timeoutMs = platformTimeoutMs()) {
|
|
117
|
+
this.endpoint = endpoint;
|
|
118
|
+
this.timeoutMs = timeoutMs;
|
|
119
|
+
}
|
|
120
|
+
endpoint;
|
|
121
|
+
timeoutMs;
|
|
122
|
+
/** A request that legitimately takes longer (a sandbox exec, a world create) waits its own budget; every other one waits the default. */
|
|
123
|
+
budget(ownMs) {
|
|
124
|
+
return Math.max(ownMs ?? 0, this.timeoutMs);
|
|
125
|
+
}
|
|
126
|
+
async send(method, route, body, opts = {}) {
|
|
127
|
+
const timeoutMs = this.budget(opts.timeoutMs);
|
|
128
|
+
const payload = body === void 0 ? {} : { body: JSON.stringify(body) };
|
|
129
|
+
const controller = new AbortController();
|
|
130
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
131
|
+
try {
|
|
132
|
+
const res = await fetch(`${this.endpoint.host}${route}`, {
|
|
133
|
+
method,
|
|
134
|
+
headers: {
|
|
135
|
+
"content-type": "application/json",
|
|
136
|
+
accept: "application/json",
|
|
137
|
+
authorization: "Basic " + Buffer.from(`${this.endpoint.publicKey}:${this.endpoint.secretKey}`).toString("base64")
|
|
138
|
+
},
|
|
139
|
+
...payload,
|
|
140
|
+
signal: controller.signal
|
|
141
|
+
});
|
|
142
|
+
return { status: res.status, ok: res.ok, text: await res.text() };
|
|
143
|
+
} catch (error) {
|
|
144
|
+
const cause = controller.signal.aborted ? TransportCause.timeout(timeoutMs) : TransportCause.of(error);
|
|
145
|
+
throw new UnreachableError(this.endpoint.host, method, route, cause);
|
|
146
|
+
} finally {
|
|
147
|
+
clearTimeout(timer);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
|
|
45
154
|
// src/worlds/browserReconnect.ts
|
|
46
155
|
async function closeConnection(c) {
|
|
47
156
|
await c.context.close();
|
|
@@ -225,7 +334,7 @@ function withoutUiToken(url) {
|
|
|
225
334
|
const [beforeHash, hash] = splitHash(url);
|
|
226
335
|
const q = beforeHash.indexOf("?");
|
|
227
336
|
if (q < 0) return url;
|
|
228
|
-
const kept = beforeHash.slice(q + 1).split("&").filter((
|
|
337
|
+
const kept = beforeHash.slice(q + 1).split("&").filter((pair2) => pair2 !== "" && pair2.split("=")[0] !== UI_TOKEN_QUERY);
|
|
229
338
|
return beforeHash.slice(0, q) + (kept.length ? `?${kept.join("&")}` : "") + hash;
|
|
230
339
|
}
|
|
231
340
|
function splitHash(url) {
|
|
@@ -360,7 +469,7 @@ var SURFACE_KINDS, BROWSER_TIERS, DEFAULT_VIEWPORT, SETTLE_TIMEOUT_MS, SETTLE_QU
|
|
|
360
469
|
var init_browser = __esm({
|
|
361
470
|
"src/worlds/browser.ts"() {
|
|
362
471
|
"use strict";
|
|
363
|
-
|
|
472
|
+
init_session2();
|
|
364
473
|
init_browserReconnect();
|
|
365
474
|
SURFACE_KINDS = ["tools", "api", "ui", "browser"];
|
|
366
475
|
BROWSER_TIERS = ["standard", "premium"];
|
|
@@ -506,6 +615,10 @@ var init_browser = __esm({
|
|
|
506
615
|
get agentId() {
|
|
507
616
|
return this.recorder?.agentId ?? null;
|
|
508
617
|
}
|
|
618
|
+
/** `text` with this session's credentials (UI token, browser address) removed. */
|
|
619
|
+
scrub(text2) {
|
|
620
|
+
return this.scrubber.scrub(text2);
|
|
621
|
+
}
|
|
509
622
|
watchNetwork(page) {
|
|
510
623
|
page.on("request", () => {
|
|
511
624
|
this.inflight += 1;
|
|
@@ -787,8 +900,1271 @@ var init_browser = __esm({
|
|
|
787
900
|
signature: "browser_back()",
|
|
788
901
|
doc: "Go back one page in history."
|
|
789
902
|
}
|
|
790
|
-
];
|
|
791
|
-
str = (v, fallback) => typeof v === "string" && v.length > 0 ? v : fallback;
|
|
903
|
+
];
|
|
904
|
+
str = (v, fallback) => typeof v === "string" && v.length > 0 ? v : fallback;
|
|
905
|
+
}
|
|
906
|
+
});
|
|
907
|
+
|
|
908
|
+
// src/worlds/nativeComputer/actions.ts
|
|
909
|
+
function toNumber(value) {
|
|
910
|
+
if (typeof value !== "number" || !Number.isFinite(value))
|
|
911
|
+
throw new Error(`not a number: ${JSON.stringify(value) ?? String(value)}`);
|
|
912
|
+
return value;
|
|
913
|
+
}
|
|
914
|
+
function toInt(value) {
|
|
915
|
+
return Math.trunc(toNumber(value));
|
|
916
|
+
}
|
|
917
|
+
var ACTION_NAMES, SECRET_TEXT, BOUNDS, ComputerAction;
|
|
918
|
+
var init_actions = __esm({
|
|
919
|
+
"src/worlds/nativeComputer/actions.ts"() {
|
|
920
|
+
"use strict";
|
|
921
|
+
ACTION_NAMES = [
|
|
922
|
+
"screenshot",
|
|
923
|
+
"zoom",
|
|
924
|
+
"click",
|
|
925
|
+
"move",
|
|
926
|
+
"mouse_down",
|
|
927
|
+
"mouse_up",
|
|
928
|
+
"drag",
|
|
929
|
+
"scroll",
|
|
930
|
+
"type",
|
|
931
|
+
"key",
|
|
932
|
+
"hold_key",
|
|
933
|
+
"wait",
|
|
934
|
+
"cursor_position",
|
|
935
|
+
"history"
|
|
936
|
+
];
|
|
937
|
+
SECRET_TEXT = "[redacted]";
|
|
938
|
+
BOUNDS = {
|
|
939
|
+
seconds: [0, 300],
|
|
940
|
+
repeat: [1, 100],
|
|
941
|
+
count: [1, 3],
|
|
942
|
+
dx: [-1e4, 1e4],
|
|
943
|
+
dy: [-1e4, 1e4]
|
|
944
|
+
};
|
|
945
|
+
ComputerAction = class {
|
|
946
|
+
constructor(name, args = {}) {
|
|
947
|
+
this.name = name;
|
|
948
|
+
this.args = args;
|
|
949
|
+
if (!ACTION_NAMES.includes(name))
|
|
950
|
+
throw new Error(`unknown computer action: ${name}`);
|
|
951
|
+
for (const [key, [low, high]] of Object.entries(BOUNDS)) {
|
|
952
|
+
const value = args[key];
|
|
953
|
+
if (value !== void 0 && !(Number(value) >= low && Number(value) <= high))
|
|
954
|
+
throw new Error(
|
|
955
|
+
`${name} ${key} must be between ${low} and ${high}, got ${String(value)}`
|
|
956
|
+
);
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
name;
|
|
960
|
+
args;
|
|
961
|
+
/** Flat arguments for the browser timeline and the trace: lists become
|
|
962
|
+
* `"x,y"` strings, and typed text is withheld when it went into a
|
|
963
|
+
* credential field. */
|
|
964
|
+
recordArgs(secretText) {
|
|
965
|
+
const out = {};
|
|
966
|
+
for (const [key, value] of Object.entries(this.args))
|
|
967
|
+
out[key] = Array.isArray(value) ? value.flat().join(",") : value;
|
|
968
|
+
if (secretText && "text" in out) out.text = SECRET_TEXT;
|
|
969
|
+
return out;
|
|
970
|
+
}
|
|
971
|
+
};
|
|
972
|
+
}
|
|
973
|
+
});
|
|
974
|
+
|
|
975
|
+
// src/worlds/nativeComputer/display.ts
|
|
976
|
+
var FIT_STEP, Display;
|
|
977
|
+
var init_display = __esm({
|
|
978
|
+
"src/worlds/nativeComputer/display.ts"() {
|
|
979
|
+
"use strict";
|
|
980
|
+
FIT_STEP = 0.98;
|
|
981
|
+
Display = class _Display {
|
|
982
|
+
constructor(width, height, viewportWidth, viewportHeight) {
|
|
983
|
+
this.width = width;
|
|
984
|
+
this.height = height;
|
|
985
|
+
this.viewportWidth = viewportWidth;
|
|
986
|
+
this.viewportHeight = viewportHeight;
|
|
987
|
+
}
|
|
988
|
+
width;
|
|
989
|
+
height;
|
|
990
|
+
viewportWidth;
|
|
991
|
+
viewportHeight;
|
|
992
|
+
/** `size` when the caller names one; otherwise the largest downscale of the
|
|
993
|
+
* viewport (at most 1:1) that `fits` the provider's limits. */
|
|
994
|
+
static forViewport(viewport, size, fits = () => true) {
|
|
995
|
+
const { width, height } = viewport;
|
|
996
|
+
if (size) return _Display.sized(size[0], size[1], width, height);
|
|
997
|
+
let scale = 1;
|
|
998
|
+
while (!fits(Math.round(width * scale), Math.round(height * scale)))
|
|
999
|
+
scale *= FIT_STEP;
|
|
1000
|
+
return new _Display(
|
|
1001
|
+
Math.round(width * scale),
|
|
1002
|
+
Math.round(height * scale),
|
|
1003
|
+
width,
|
|
1004
|
+
height
|
|
1005
|
+
);
|
|
1006
|
+
}
|
|
1007
|
+
/** A caller's display keeps the viewport's shape: screenshots are scaled
|
|
1008
|
+
* uniformly, so another aspect ratio would map clicks off the image. */
|
|
1009
|
+
static sized(width, height, viewportWidth, viewportHeight) {
|
|
1010
|
+
if (width <= 0 || height <= 0)
|
|
1011
|
+
throw new Error(`display ${width}x${height} must be positive`);
|
|
1012
|
+
const sameShape = width * viewportHeight / viewportWidth;
|
|
1013
|
+
if (Math.abs(sameShape - height) > 1)
|
|
1014
|
+
throw new Error(
|
|
1015
|
+
`display ${width}x${height} must keep the viewport's aspect ratio (${viewportWidth}x${viewportHeight}); try ${width}x${Math.round(sameShape)}`
|
|
1016
|
+
);
|
|
1017
|
+
return new _Display(width, height, viewportWidth, viewportHeight);
|
|
1018
|
+
}
|
|
1019
|
+
get scaled() {
|
|
1020
|
+
return this.width !== this.viewportWidth || this.height !== this.viewportHeight;
|
|
1021
|
+
}
|
|
1022
|
+
get scale() {
|
|
1023
|
+
return Math.min(
|
|
1024
|
+
this.width / this.viewportWidth,
|
|
1025
|
+
this.height / this.viewportHeight
|
|
1026
|
+
);
|
|
1027
|
+
}
|
|
1028
|
+
toPage(x, y) {
|
|
1029
|
+
return [
|
|
1030
|
+
x * this.viewportWidth / this.width,
|
|
1031
|
+
y * this.viewportHeight / this.height
|
|
1032
|
+
];
|
|
1033
|
+
}
|
|
1034
|
+
};
|
|
1035
|
+
}
|
|
1036
|
+
});
|
|
1037
|
+
|
|
1038
|
+
// src/worlds/nativeComputer/screen.ts
|
|
1039
|
+
function pngWidth(png) {
|
|
1040
|
+
if (png.length < 24 || !png.subarray(0, 8).equals(PNG_SIGNATURE)) return null;
|
|
1041
|
+
return png.readUInt32BE(16);
|
|
1042
|
+
}
|
|
1043
|
+
function isNativePage(page) {
|
|
1044
|
+
const candidate = page;
|
|
1045
|
+
const mouse = candidate?.mouse;
|
|
1046
|
+
return typeof candidate?.context === "function" && NATIVE_METHODS.every((m) => typeof mouse?.[m] === "function");
|
|
1047
|
+
}
|
|
1048
|
+
var FOCUSED_FIELD_JS, SECRET_FOCUS, DRAG_STEPS, PNG_SIGNATURE, NATIVE_METHODS, Screen;
|
|
1049
|
+
var init_screen = __esm({
|
|
1050
|
+
"src/worlds/nativeComputer/screen.ts"() {
|
|
1051
|
+
"use strict";
|
|
1052
|
+
init_browser();
|
|
1053
|
+
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(' '); })()";
|
|
1054
|
+
SECRET_FOCUS = ["password", "frame", "opaque"];
|
|
1055
|
+
DRAG_STEPS = 5;
|
|
1056
|
+
PNG_SIGNATURE = Buffer.from([
|
|
1057
|
+
137,
|
|
1058
|
+
80,
|
|
1059
|
+
78,
|
|
1060
|
+
71,
|
|
1061
|
+
13,
|
|
1062
|
+
10,
|
|
1063
|
+
26,
|
|
1064
|
+
10
|
|
1065
|
+
]);
|
|
1066
|
+
NATIVE_METHODS = ["move", "click", "down", "up", "wheel"];
|
|
1067
|
+
Screen = class {
|
|
1068
|
+
constructor(browser, display) {
|
|
1069
|
+
this.browser = browser;
|
|
1070
|
+
this.display = display;
|
|
1071
|
+
}
|
|
1072
|
+
browser;
|
|
1073
|
+
display;
|
|
1074
|
+
cursor = [0, 0];
|
|
1075
|
+
pixelRatio = 1;
|
|
1076
|
+
handlers = {
|
|
1077
|
+
screenshot: async () => ({ image: await this.screenshot() }),
|
|
1078
|
+
zoom: (a) => this.zoom(a),
|
|
1079
|
+
click: (a) => this.click(a),
|
|
1080
|
+
move: (a) => this.held(a.args.modifiers ?? [], () => this.moveTo(this.point(a))),
|
|
1081
|
+
mouse_down: async (a) => {
|
|
1082
|
+
await this.page.mouse.down({ button: a.args.button ?? "left" });
|
|
1083
|
+
return {};
|
|
1084
|
+
},
|
|
1085
|
+
mouse_up: async (a) => {
|
|
1086
|
+
await this.page.mouse.up({ button: a.args.button ?? "left" });
|
|
1087
|
+
return {};
|
|
1088
|
+
},
|
|
1089
|
+
drag: (a) => this.drag(a),
|
|
1090
|
+
scroll: (a) => this.scroll(a),
|
|
1091
|
+
type: async (a) => {
|
|
1092
|
+
await this.page.keyboard.type(a.args.text ?? "");
|
|
1093
|
+
return {};
|
|
1094
|
+
},
|
|
1095
|
+
key: (a) => this.key(a),
|
|
1096
|
+
hold_key: (a) => this.held(
|
|
1097
|
+
a.args.keys ?? [],
|
|
1098
|
+
() => this.page.waitForTimeout((a.args.seconds ?? 0) * 1e3)
|
|
1099
|
+
),
|
|
1100
|
+
wait: async (a) => {
|
|
1101
|
+
await this.page.waitForTimeout((a.args.seconds ?? 0) * 1e3);
|
|
1102
|
+
return {};
|
|
1103
|
+
},
|
|
1104
|
+
cursor_position: async () => ({
|
|
1105
|
+
text: `X=${this.cursor[0]}, Y=${this.cursor[1]}`
|
|
1106
|
+
}),
|
|
1107
|
+
history: async (a) => {
|
|
1108
|
+
const navigate = {
|
|
1109
|
+
back: () => this.page.goBack(),
|
|
1110
|
+
forward: () => this.page.goForward()
|
|
1111
|
+
};
|
|
1112
|
+
await navigate[a.args.direction ?? "back"]();
|
|
1113
|
+
return {};
|
|
1114
|
+
}
|
|
1115
|
+
};
|
|
1116
|
+
/** The live page (a new object after a reconnect), as pixel-level Playwright. */
|
|
1117
|
+
get page() {
|
|
1118
|
+
const page = this.browser.page;
|
|
1119
|
+
if (!isNativePage(page))
|
|
1120
|
+
throw new Error(
|
|
1121
|
+
"native computer use needs a Playwright page (mouse.move/click/down/up/wheel, context())"
|
|
1122
|
+
);
|
|
1123
|
+
return page;
|
|
1124
|
+
}
|
|
1125
|
+
run(action) {
|
|
1126
|
+
return this.handlers[action.name](action);
|
|
1127
|
+
}
|
|
1128
|
+
/** A PNG of the viewport at the model's display size. */
|
|
1129
|
+
async screenshot() {
|
|
1130
|
+
if (!this.display.scaled) return this.page.screenshot({ type: "png" });
|
|
1131
|
+
const { viewportWidth: width, viewportHeight: height } = this.display;
|
|
1132
|
+
return this.capture({ x: 0, y: 0, width, height }, this.display.scale);
|
|
1133
|
+
}
|
|
1134
|
+
/** Whether keystrokes go to a credential field (a password input, or one
|
|
1135
|
+
* named like a token, key or PIN), looking through shadow roots and
|
|
1136
|
+
* same-origin frames. An unreadable page, a cross-origin frame or a focus
|
|
1137
|
+
* that is not a text field (a closed shadow root's host) counts as one. */
|
|
1138
|
+
async focusedFieldIsSecret() {
|
|
1139
|
+
let described;
|
|
1140
|
+
try {
|
|
1141
|
+
described = String(await this.page.evaluate(FOCUSED_FIELD_JS) ?? "");
|
|
1142
|
+
} catch {
|
|
1143
|
+
return true;
|
|
1144
|
+
}
|
|
1145
|
+
return SECRET_FOCUS.some((prefix) => described.startsWith(prefix)) || SECRET_KEY.test(described);
|
|
1146
|
+
}
|
|
1147
|
+
/** CDP renders a clip at the page's device pixel ratio as well as its
|
|
1148
|
+
* `scale` (a Retina host doubles it), so a capture of the wrong width
|
|
1149
|
+
* measures that ratio and is taken once more, corrected. */
|
|
1150
|
+
async capture(clip, scale) {
|
|
1151
|
+
const wanted = Math.round(clip.width * scale);
|
|
1152
|
+
const png = await this.cdpCapture(clip, scale / this.pixelRatio);
|
|
1153
|
+
const width = pngWidth(png);
|
|
1154
|
+
if (width === null || Math.abs(width - wanted) <= 1) return png;
|
|
1155
|
+
this.pixelRatio *= width / wanted;
|
|
1156
|
+
return this.cdpCapture(clip, scale / this.pixelRatio);
|
|
1157
|
+
}
|
|
1158
|
+
async cdpCapture(clip, scale) {
|
|
1159
|
+
const page = this.page;
|
|
1160
|
+
const session = await page.context().newCDPSession(page);
|
|
1161
|
+
try {
|
|
1162
|
+
const shot = await session.send("Page.captureScreenshot", {
|
|
1163
|
+
format: "png",
|
|
1164
|
+
clip: { ...clip, scale }
|
|
1165
|
+
});
|
|
1166
|
+
return Buffer.from(shot.data, "base64");
|
|
1167
|
+
} finally {
|
|
1168
|
+
await session.detach();
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
point(action) {
|
|
1172
|
+
const { x, y } = action.args;
|
|
1173
|
+
return x === void 0 || y === void 0 ? this.cursor : [x, y];
|
|
1174
|
+
}
|
|
1175
|
+
async moveTo(point2, steps = 1) {
|
|
1176
|
+
const [x, y] = this.display.toPage(point2[0], point2[1]);
|
|
1177
|
+
await this.page.mouse.move(x, y, { steps });
|
|
1178
|
+
this.cursor = point2;
|
|
1179
|
+
}
|
|
1180
|
+
async held(modifiers, fn) {
|
|
1181
|
+
for (const key of modifiers) await this.page.keyboard.down(key);
|
|
1182
|
+
try {
|
|
1183
|
+
await fn();
|
|
1184
|
+
} finally {
|
|
1185
|
+
for (const key of [...modifiers].reverse())
|
|
1186
|
+
await this.page.keyboard.up(key);
|
|
1187
|
+
}
|
|
1188
|
+
return {};
|
|
1189
|
+
}
|
|
1190
|
+
async zoom(action) {
|
|
1191
|
+
const [x0, y0, x1, y1] = action.args.region ?? [0, 0, 0, 0];
|
|
1192
|
+
const [left, top] = this.display.toPage(x0, y0);
|
|
1193
|
+
const [right, bottom] = this.display.toPage(x1, y1);
|
|
1194
|
+
if (right <= left || bottom <= top)
|
|
1195
|
+
throw new Error("zoom region must have x1 > x0 and y1 > y0");
|
|
1196
|
+
const width = right - left;
|
|
1197
|
+
const height = bottom - top;
|
|
1198
|
+
const scale = Math.min(
|
|
1199
|
+
this.display.width / width,
|
|
1200
|
+
this.display.height / height
|
|
1201
|
+
);
|
|
1202
|
+
return {
|
|
1203
|
+
image: await this.capture({ x: left, y: top, width, height }, scale)
|
|
1204
|
+
};
|
|
1205
|
+
}
|
|
1206
|
+
async click(action) {
|
|
1207
|
+
const point2 = this.point(action);
|
|
1208
|
+
return this.held(action.args.modifiers ?? [], async () => {
|
|
1209
|
+
await this.moveTo(point2);
|
|
1210
|
+
const [x, y] = this.display.toPage(point2[0], point2[1]);
|
|
1211
|
+
await this.page.mouse.click(x, y, {
|
|
1212
|
+
button: action.args.button ?? "left",
|
|
1213
|
+
clickCount: action.args.count ?? 1
|
|
1214
|
+
});
|
|
1215
|
+
});
|
|
1216
|
+
}
|
|
1217
|
+
async drag(action) {
|
|
1218
|
+
const path12 = action.args.path ?? [];
|
|
1219
|
+
if (path12.length < 2) throw new Error("a drag needs at least two points");
|
|
1220
|
+
return this.held(action.args.modifiers ?? [], async () => {
|
|
1221
|
+
await this.moveTo(path12[0]);
|
|
1222
|
+
await this.page.mouse.down({ button: "left" });
|
|
1223
|
+
try {
|
|
1224
|
+
for (const point2 of path12.slice(1)) await this.moveTo(point2, DRAG_STEPS);
|
|
1225
|
+
} finally {
|
|
1226
|
+
await this.page.mouse.up({ button: "left" });
|
|
1227
|
+
}
|
|
1228
|
+
});
|
|
1229
|
+
}
|
|
1230
|
+
async scroll(action) {
|
|
1231
|
+
await this.moveTo(this.point(action));
|
|
1232
|
+
const scale = this.display.scale;
|
|
1233
|
+
return this.held(
|
|
1234
|
+
action.args.modifiers ?? [],
|
|
1235
|
+
() => this.page.mouse.wheel(
|
|
1236
|
+
(action.args.dx ?? 0) / scale,
|
|
1237
|
+
(action.args.dy ?? 0) / scale
|
|
1238
|
+
)
|
|
1239
|
+
);
|
|
1240
|
+
}
|
|
1241
|
+
async key(action) {
|
|
1242
|
+
const combo = (action.args.keys ?? []).join("+");
|
|
1243
|
+
for (let i = 0; i < (action.args.repeat ?? 1); i += 1)
|
|
1244
|
+
await this.page.keyboard.press(combo);
|
|
1245
|
+
return {};
|
|
1246
|
+
}
|
|
1247
|
+
};
|
|
1248
|
+
}
|
|
1249
|
+
});
|
|
1250
|
+
|
|
1251
|
+
// src/tracing/media.ts
|
|
1252
|
+
async function putBytes(url, data, headers) {
|
|
1253
|
+
const controller = new AbortController();
|
|
1254
|
+
const timer = setTimeout(() => controller.abort(), PUT_TIMEOUT_MS);
|
|
1255
|
+
try {
|
|
1256
|
+
const res = await fetch(url, {
|
|
1257
|
+
method: "PUT",
|
|
1258
|
+
body: new Uint8Array(data),
|
|
1259
|
+
headers,
|
|
1260
|
+
signal: controller.signal
|
|
1261
|
+
});
|
|
1262
|
+
return {
|
|
1263
|
+
status: res.status,
|
|
1264
|
+
error: res.ok ? null : (await res.text()).slice(0, MAX_UPLOAD_ERROR)
|
|
1265
|
+
};
|
|
1266
|
+
} catch (error) {
|
|
1267
|
+
return {
|
|
1268
|
+
status: NETWORK_FAILURE_STATUS,
|
|
1269
|
+
error: error instanceof Error ? error.name : "Error"
|
|
1270
|
+
};
|
|
1271
|
+
} finally {
|
|
1272
|
+
clearTimeout(timer);
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
var import_node_crypto, MEDIA_PATH, MAX_MEDIA_BYTES, PUT_TIMEOUT_MS, MAX_UPLOAD_ERROR, NETWORK_FAILURE_STATUS, MediaUploadError, MediaReference, MediaUploader;
|
|
1276
|
+
var init_media = __esm({
|
|
1277
|
+
"src/tracing/media.ts"() {
|
|
1278
|
+
"use strict";
|
|
1279
|
+
import_node_crypto = require("crypto");
|
|
1280
|
+
init_transport();
|
|
1281
|
+
MEDIA_PATH = "/api/public/media";
|
|
1282
|
+
MAX_MEDIA_BYTES = 5 * 1024 * 1024;
|
|
1283
|
+
PUT_TIMEOUT_MS = 3e4;
|
|
1284
|
+
MAX_UPLOAD_ERROR = 500;
|
|
1285
|
+
NETWORK_FAILURE_STATUS = 599;
|
|
1286
|
+
MediaUploadError = class extends Error {
|
|
1287
|
+
constructor(message, status) {
|
|
1288
|
+
super(message);
|
|
1289
|
+
this.status = status;
|
|
1290
|
+
this.name = "MediaUploadError";
|
|
1291
|
+
}
|
|
1292
|
+
status;
|
|
1293
|
+
};
|
|
1294
|
+
MediaReference = class {
|
|
1295
|
+
constructor(mediaId, contentType) {
|
|
1296
|
+
this.mediaId = mediaId;
|
|
1297
|
+
this.contentType = contentType;
|
|
1298
|
+
}
|
|
1299
|
+
mediaId;
|
|
1300
|
+
contentType;
|
|
1301
|
+
toString() {
|
|
1302
|
+
return `@@@langfuseMedia:type=${this.contentType}|id=${this.mediaId}|source=bytes@@@`;
|
|
1303
|
+
}
|
|
1304
|
+
};
|
|
1305
|
+
MediaUploader = class _MediaUploader {
|
|
1306
|
+
constructor(transport, put = putBytes, maxBytes = MAX_MEDIA_BYTES) {
|
|
1307
|
+
this.transport = transport;
|
|
1308
|
+
this.put = put;
|
|
1309
|
+
this.maxBytes = maxBytes;
|
|
1310
|
+
}
|
|
1311
|
+
transport;
|
|
1312
|
+
put;
|
|
1313
|
+
maxBytes;
|
|
1314
|
+
/** The uploader for `GATEWAY_HOST` / `GATEWAY_PUBLIC_KEY` /
|
|
1315
|
+
* `GATEWAY_SECRET_KEY` (the keys tracing exports with); null when any is unset. */
|
|
1316
|
+
static fromEnv(env = process.env) {
|
|
1317
|
+
const host = env.GATEWAY_HOST;
|
|
1318
|
+
const publicKey = env.GATEWAY_PUBLIC_KEY;
|
|
1319
|
+
const secretKey = env.GATEWAY_SECRET_KEY;
|
|
1320
|
+
if (!host || !publicKey || !secretKey) return null;
|
|
1321
|
+
return new _MediaUploader(
|
|
1322
|
+
new PlatformTransport({
|
|
1323
|
+
host: host.replace(/\/$/, ""),
|
|
1324
|
+
publicKey,
|
|
1325
|
+
secretKey
|
|
1326
|
+
})
|
|
1327
|
+
);
|
|
1328
|
+
}
|
|
1329
|
+
/** Store `data` linked to the trace (and observation) and return its reference. */
|
|
1330
|
+
async upload(data, link) {
|
|
1331
|
+
if (data.length > this.maxBytes)
|
|
1332
|
+
throw new MediaUploadError(
|
|
1333
|
+
`media is ${data.length} bytes, over the ${this.maxBytes}-byte cap`
|
|
1334
|
+
);
|
|
1335
|
+
const sha256Hash = (0, import_node_crypto.createHash)("sha256").update(data).digest("base64");
|
|
1336
|
+
const answer = await this.send("POST", MEDIA_PATH, {
|
|
1337
|
+
traceId: link.traceId,
|
|
1338
|
+
observationId: link.observationId,
|
|
1339
|
+
contentType: link.contentType,
|
|
1340
|
+
contentLength: data.length,
|
|
1341
|
+
sha256Hash,
|
|
1342
|
+
field: link.field
|
|
1343
|
+
});
|
|
1344
|
+
if (typeof answer.mediaId !== "string" || !answer.mediaId)
|
|
1345
|
+
throw new MediaUploadError(
|
|
1346
|
+
"POST /api/public/media answered without a mediaId"
|
|
1347
|
+
);
|
|
1348
|
+
const reference = new MediaReference(answer.mediaId, link.contentType);
|
|
1349
|
+
if (answer.uploadUrl)
|
|
1350
|
+
await this.store(reference, answer.uploadUrl, data, sha256Hash);
|
|
1351
|
+
return reference;
|
|
1352
|
+
}
|
|
1353
|
+
async store(reference, url, data, sha256Hash) {
|
|
1354
|
+
const started = Date.now();
|
|
1355
|
+
const { status, error } = await this.put(url, data, {
|
|
1356
|
+
"Content-Type": reference.contentType,
|
|
1357
|
+
"x-amz-checksum-sha256": sha256Hash,
|
|
1358
|
+
"x-ms-blob-type": "BlockBlob"
|
|
1359
|
+
});
|
|
1360
|
+
await this.send(
|
|
1361
|
+
"PATCH",
|
|
1362
|
+
`${MEDIA_PATH}/${encodeURIComponent(reference.mediaId)}`,
|
|
1363
|
+
{
|
|
1364
|
+
uploadedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1365
|
+
uploadHttpStatus: status,
|
|
1366
|
+
uploadHttpError: error,
|
|
1367
|
+
uploadTimeMs: Date.now() - started
|
|
1368
|
+
}
|
|
1369
|
+
);
|
|
1370
|
+
if (status < 200 || status >= 300)
|
|
1371
|
+
throw new MediaUploadError(
|
|
1372
|
+
`media storage refused the upload (HTTP ${status})`,
|
|
1373
|
+
status
|
|
1374
|
+
);
|
|
1375
|
+
}
|
|
1376
|
+
async send(method, route, body) {
|
|
1377
|
+
const reply = await this.transport.send(method, route, body);
|
|
1378
|
+
if (!reply.ok)
|
|
1379
|
+
throw new MediaUploadError(
|
|
1380
|
+
`${method} ${route} -> ${reply.status}`,
|
|
1381
|
+
reply.status
|
|
1382
|
+
);
|
|
1383
|
+
return reply.text ? JSON.parse(reply.text) : {};
|
|
1384
|
+
}
|
|
1385
|
+
};
|
|
1386
|
+
}
|
|
1387
|
+
});
|
|
1388
|
+
|
|
1389
|
+
// src/worlds/nativeComputer/trace.ts
|
|
1390
|
+
function loadOtelApi() {
|
|
1391
|
+
if (otelApi !== void 0) return otelApi;
|
|
1392
|
+
try {
|
|
1393
|
+
otelApi = require("@opentelemetry/api");
|
|
1394
|
+
} catch {
|
|
1395
|
+
otelApi = null;
|
|
1396
|
+
}
|
|
1397
|
+
return otelApi;
|
|
1398
|
+
}
|
|
1399
|
+
function errorText(error) {
|
|
1400
|
+
return error instanceof Error ? `${error.name}: ${error.message}` : String(error);
|
|
1401
|
+
}
|
|
1402
|
+
function errorName(error) {
|
|
1403
|
+
return error instanceof Error ? error.name : "Error";
|
|
1404
|
+
}
|
|
1405
|
+
var SPAN_PREFIX, MAX_UPLOAD_FAILURES, TRACER_NAME, MAX_ERROR, otelApi, ActionTracer;
|
|
1406
|
+
var init_trace = __esm({
|
|
1407
|
+
"src/worlds/nativeComputer/trace.ts"() {
|
|
1408
|
+
"use strict";
|
|
1409
|
+
init_media();
|
|
1410
|
+
SPAN_PREFIX = "computer.";
|
|
1411
|
+
MAX_UPLOAD_FAILURES = 3;
|
|
1412
|
+
TRACER_NAME = "@withgateway/sdk";
|
|
1413
|
+
MAX_ERROR = 1e3;
|
|
1414
|
+
ActionTracer = class _ActionTracer {
|
|
1415
|
+
constructor(media, warn2 = (m) => console.warn(m)) {
|
|
1416
|
+
this.media = media;
|
|
1417
|
+
this.warn = warn2;
|
|
1418
|
+
}
|
|
1419
|
+
media;
|
|
1420
|
+
warn;
|
|
1421
|
+
failures = 0;
|
|
1422
|
+
warned = false;
|
|
1423
|
+
static fromEnv() {
|
|
1424
|
+
return new _ActionTracer(MediaUploader.fromEnv());
|
|
1425
|
+
}
|
|
1426
|
+
/** `args` are already redacted. A failure's status goes through `scrub`:
|
|
1427
|
+
* browser errors quote the session's ws URL and UI token. */
|
|
1428
|
+
async span(action, args, run, capture, scrub) {
|
|
1429
|
+
const otel = loadOtelApi();
|
|
1430
|
+
if (!otel) return run();
|
|
1431
|
+
const { SpanStatusCode, trace: trace3 } = otel;
|
|
1432
|
+
const attributes = {
|
|
1433
|
+
"gateway.observation.type": "tool",
|
|
1434
|
+
"tool.name": SPAN_PREFIX + action.name,
|
|
1435
|
+
"gateway.observation.input": JSON.stringify({
|
|
1436
|
+
action: action.name,
|
|
1437
|
+
...args
|
|
1438
|
+
})
|
|
1439
|
+
};
|
|
1440
|
+
return trace3.getTracer(TRACER_NAME).startActiveSpan(
|
|
1441
|
+
SPAN_PREFIX + action.name,
|
|
1442
|
+
{ attributes },
|
|
1443
|
+
async (span) => {
|
|
1444
|
+
try {
|
|
1445
|
+
const result = await run();
|
|
1446
|
+
await this.finish(span, result, capture);
|
|
1447
|
+
span.setStatus({ code: SpanStatusCode.OK });
|
|
1448
|
+
return result;
|
|
1449
|
+
} catch (error) {
|
|
1450
|
+
span.setStatus({
|
|
1451
|
+
code: SpanStatusCode.ERROR,
|
|
1452
|
+
message: scrub(errorText(error)).slice(0, MAX_ERROR)
|
|
1453
|
+
});
|
|
1454
|
+
throw error;
|
|
1455
|
+
} finally {
|
|
1456
|
+
span.end();
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
);
|
|
1460
|
+
}
|
|
1461
|
+
async finish(span, result, capture) {
|
|
1462
|
+
if (!span.isRecording()) return;
|
|
1463
|
+
const output = {
|
|
1464
|
+
screenshot: await this.screenshot(span, result, capture)
|
|
1465
|
+
};
|
|
1466
|
+
if (result.text !== void 0) output.text = result.text;
|
|
1467
|
+
span.setAttribute("gateway.observation.output", JSON.stringify(output));
|
|
1468
|
+
}
|
|
1469
|
+
async screenshot(span, result, capture) {
|
|
1470
|
+
let png;
|
|
1471
|
+
try {
|
|
1472
|
+
png = result.image ?? await capture();
|
|
1473
|
+
} catch (error) {
|
|
1474
|
+
return `[screenshot unavailable: ${errorName(error)}]`;
|
|
1475
|
+
}
|
|
1476
|
+
return this.reference(png, span);
|
|
1477
|
+
}
|
|
1478
|
+
async reference(png, span) {
|
|
1479
|
+
if (!this.media)
|
|
1480
|
+
return "[screenshot not uploaded: GATEWAY_HOST / GATEWAY_PUBLIC_KEY / GATEWAY_SECRET_KEY unset]";
|
|
1481
|
+
if (this.failures >= MAX_UPLOAD_FAILURES)
|
|
1482
|
+
return "[screenshot not uploaded: uploads disabled after repeated failures]";
|
|
1483
|
+
const { traceId, spanId } = span.spanContext();
|
|
1484
|
+
try {
|
|
1485
|
+
const reference = await this.media.upload(png, {
|
|
1486
|
+
contentType: "image/png",
|
|
1487
|
+
traceId,
|
|
1488
|
+
observationId: spanId,
|
|
1489
|
+
field: "output"
|
|
1490
|
+
});
|
|
1491
|
+
this.failures = 0;
|
|
1492
|
+
return reference.toString();
|
|
1493
|
+
} catch (error) {
|
|
1494
|
+
return this.failed(error);
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1497
|
+
failed(error) {
|
|
1498
|
+
this.failures += 1;
|
|
1499
|
+
if (!this.warned) {
|
|
1500
|
+
this.warned = true;
|
|
1501
|
+
this.warn(
|
|
1502
|
+
`native computer: screenshot upload failed (${errorName(error)}: ${error instanceof Error ? error.message : String(error)}); spans keep going without it`
|
|
1503
|
+
);
|
|
1504
|
+
}
|
|
1505
|
+
return `[screenshot not uploaded: ${errorName(error)}]`;
|
|
1506
|
+
}
|
|
1507
|
+
};
|
|
1508
|
+
}
|
|
1509
|
+
});
|
|
1510
|
+
|
|
1511
|
+
// src/worlds/nativeComputer/base.ts
|
|
1512
|
+
function readField(item, ...names) {
|
|
1513
|
+
const record = item ?? {};
|
|
1514
|
+
return names.map((name) => record[name]).find((value) => value !== void 0 && value !== null);
|
|
1515
|
+
}
|
|
1516
|
+
var REPLAYABLE, SETTLING, EVENT_PREFIX, NativeComputer;
|
|
1517
|
+
var init_base = __esm({
|
|
1518
|
+
"src/worlds/nativeComputer/base.ts"() {
|
|
1519
|
+
"use strict";
|
|
1520
|
+
init_browser();
|
|
1521
|
+
init_actions();
|
|
1522
|
+
init_display();
|
|
1523
|
+
init_screen();
|
|
1524
|
+
init_trace();
|
|
1525
|
+
REPLAYABLE = /* @__PURE__ */ new Set(["screenshot", "zoom", "cursor_position", "wait"]);
|
|
1526
|
+
SETTLING = /* @__PURE__ */ new Set(["click", "mouse_up", "drag", "key", "history"]);
|
|
1527
|
+
EVENT_PREFIX = "computer_";
|
|
1528
|
+
NativeComputer = class _NativeComputer {
|
|
1529
|
+
constructor(browser, options = {}) {
|
|
1530
|
+
this.browser = browser;
|
|
1531
|
+
const kind = this.constructor;
|
|
1532
|
+
this.display = Display.forViewport(
|
|
1533
|
+
browser.viewport,
|
|
1534
|
+
options.display,
|
|
1535
|
+
(w, h) => kind.fits(w, h)
|
|
1536
|
+
);
|
|
1537
|
+
this.screen = new Screen(browser, this.display);
|
|
1538
|
+
this.tracer = options.tracer ?? ActionTracer.fromEnv();
|
|
1539
|
+
}
|
|
1540
|
+
browser;
|
|
1541
|
+
static kinds = /* @__PURE__ */ new Map();
|
|
1542
|
+
display;
|
|
1543
|
+
screen;
|
|
1544
|
+
tracer;
|
|
1545
|
+
queue = Promise.resolve();
|
|
1546
|
+
static register(provider, kind) {
|
|
1547
|
+
_NativeComputer.kinds.set(provider, kind);
|
|
1548
|
+
}
|
|
1549
|
+
static get providers() {
|
|
1550
|
+
return [..._NativeComputer.kinds.keys()].sort();
|
|
1551
|
+
}
|
|
1552
|
+
static forProvider(provider, browser, options = {}) {
|
|
1553
|
+
const Kind = _NativeComputer.kinds.get(provider);
|
|
1554
|
+
if (!Kind)
|
|
1555
|
+
throw new Error(
|
|
1556
|
+
`unknown computer-use provider '${provider}'; choose from ${_NativeComputer.providers.join(", ")}`
|
|
1557
|
+
);
|
|
1558
|
+
return new Kind(browser, options);
|
|
1559
|
+
}
|
|
1560
|
+
/** Whether a screenshot of this size is within the provider's limits. */
|
|
1561
|
+
static fits(_width, _height) {
|
|
1562
|
+
return true;
|
|
1563
|
+
}
|
|
1564
|
+
/** Run one provider-shaped action (an OpenAI action object, or an Anthropic
|
|
1565
|
+
* `{ action: "left_click", ... }` input) and return what it produced: the
|
|
1566
|
+
* door for any agent framework that hands actions over one at a time. */
|
|
1567
|
+
executeAction(raw) {
|
|
1568
|
+
return this.perform(this.parse(raw));
|
|
1569
|
+
}
|
|
1570
|
+
/** Run one action on the page: reported on the session's browser timeline
|
|
1571
|
+
* and, when tracing is on, as a span with the screen after. */
|
|
1572
|
+
async perform(action) {
|
|
1573
|
+
const secret = action.name === "type" && await this.screen.focusedFieldIsSecret();
|
|
1574
|
+
const event = EVENT_PREFIX + action.name;
|
|
1575
|
+
const args = redactActionArgs(event, action.recordArgs(secret));
|
|
1576
|
+
return this.tracer.span(
|
|
1577
|
+
action,
|
|
1578
|
+
args,
|
|
1579
|
+
() => this.browser.act(
|
|
1580
|
+
event,
|
|
1581
|
+
args,
|
|
1582
|
+
() => this.runOnScreen(action),
|
|
1583
|
+
this.onLoss(action)
|
|
1584
|
+
),
|
|
1585
|
+
() => this.screen.screenshot(),
|
|
1586
|
+
(text2) => this.browser.scrub(text2)
|
|
1587
|
+
);
|
|
1588
|
+
}
|
|
1589
|
+
async performAll(actions) {
|
|
1590
|
+
const results = [];
|
|
1591
|
+
for (const action of actions) results.push(await this.perform(action));
|
|
1592
|
+
return results;
|
|
1593
|
+
}
|
|
1594
|
+
/** The screen as the model sees it, as a traced `screenshot` action. */
|
|
1595
|
+
async screenshot() {
|
|
1596
|
+
return (await this.perform(new ComputerAction("screenshot"))).image ?? Buffer.alloc(0);
|
|
1597
|
+
}
|
|
1598
|
+
/** Run `fn` after every earlier call made through here: the AI SDK starts a
|
|
1599
|
+
* step's tool calls concurrently, but one screen takes one action at a time. */
|
|
1600
|
+
serial(fn) {
|
|
1601
|
+
const next = this.queue.then(fn, fn);
|
|
1602
|
+
this.queue = next.catch(() => void 0);
|
|
1603
|
+
return next;
|
|
1604
|
+
}
|
|
1605
|
+
async runOnScreen(action) {
|
|
1606
|
+
const result = await this.screen.run(action);
|
|
1607
|
+
if (SETTLING.has(action.name)) await this.browser.settle();
|
|
1608
|
+
return result;
|
|
1609
|
+
}
|
|
1610
|
+
onLoss(action) {
|
|
1611
|
+
return REPLAYABLE.has(action.name) ? "retry" : "report";
|
|
1612
|
+
}
|
|
1613
|
+
};
|
|
1614
|
+
}
|
|
1615
|
+
});
|
|
1616
|
+
|
|
1617
|
+
// src/worlds/nativeComputer/keys.ts
|
|
1618
|
+
function playwrightKey(token) {
|
|
1619
|
+
return KEY_NAMES[token.toLowerCase()] ?? token;
|
|
1620
|
+
}
|
|
1621
|
+
function letterOrName(key) {
|
|
1622
|
+
return /^[a-zA-Z]$/.test(key) ? key.toLowerCase() : playwrightKey(key);
|
|
1623
|
+
}
|
|
1624
|
+
function modifierChord(text2) {
|
|
1625
|
+
return typeof text2 === "string" && text2 ? [...KeyChord.fromXdotool(text2).keys] : [];
|
|
1626
|
+
}
|
|
1627
|
+
function modifierKeys(keys) {
|
|
1628
|
+
return Array.isArray(keys) && keys.length > 0 ? [...KeyChord.fromKeys(keys.map(String)).keys] : [];
|
|
1629
|
+
}
|
|
1630
|
+
var F_KEYS, KEY_NAMES, KeyChord;
|
|
1631
|
+
var init_keys = __esm({
|
|
1632
|
+
"src/worlds/nativeComputer/keys.ts"() {
|
|
1633
|
+
"use strict";
|
|
1634
|
+
F_KEYS = Object.fromEntries(
|
|
1635
|
+
Array.from({ length: 12 }, (_, i) => [`f${i + 1}`, `F${i + 1}`])
|
|
1636
|
+
);
|
|
1637
|
+
KEY_NAMES = {
|
|
1638
|
+
return: "Enter",
|
|
1639
|
+
enter: "Enter",
|
|
1640
|
+
kp_enter: "Enter",
|
|
1641
|
+
esc: "Escape",
|
|
1642
|
+
escape: "Escape",
|
|
1643
|
+
tab: "Tab",
|
|
1644
|
+
space: "Space",
|
|
1645
|
+
backspace: "Backspace",
|
|
1646
|
+
delete: "Delete",
|
|
1647
|
+
del: "Delete",
|
|
1648
|
+
insert: "Insert",
|
|
1649
|
+
home: "Home",
|
|
1650
|
+
end: "End",
|
|
1651
|
+
pageup: "PageUp",
|
|
1652
|
+
page_up: "PageUp",
|
|
1653
|
+
prior: "PageUp",
|
|
1654
|
+
pagedown: "PageDown",
|
|
1655
|
+
page_down: "PageDown",
|
|
1656
|
+
next: "PageDown",
|
|
1657
|
+
up: "ArrowUp",
|
|
1658
|
+
arrowup: "ArrowUp",
|
|
1659
|
+
down: "ArrowDown",
|
|
1660
|
+
arrowdown: "ArrowDown",
|
|
1661
|
+
left: "ArrowLeft",
|
|
1662
|
+
arrowleft: "ArrowLeft",
|
|
1663
|
+
right: "ArrowRight",
|
|
1664
|
+
arrowright: "ArrowRight",
|
|
1665
|
+
ctrl: "Control",
|
|
1666
|
+
control: "Control",
|
|
1667
|
+
shift: "Shift",
|
|
1668
|
+
alt: "Alt",
|
|
1669
|
+
option: "Alt",
|
|
1670
|
+
super: "Meta",
|
|
1671
|
+
meta: "Meta",
|
|
1672
|
+
cmd: "Meta",
|
|
1673
|
+
command: "Meta",
|
|
1674
|
+
win: "Meta",
|
|
1675
|
+
capslock: "CapsLock",
|
|
1676
|
+
caps_lock: "CapsLock",
|
|
1677
|
+
plus: "+",
|
|
1678
|
+
minus: "-",
|
|
1679
|
+
...F_KEYS
|
|
1680
|
+
};
|
|
1681
|
+
KeyChord = class _KeyChord {
|
|
1682
|
+
constructor(keys) {
|
|
1683
|
+
this.keys = keys;
|
|
1684
|
+
if (keys.length === 0)
|
|
1685
|
+
throw new Error("a key action needs at least one key");
|
|
1686
|
+
}
|
|
1687
|
+
keys;
|
|
1688
|
+
/** `ctrl+shift+t` / `Return`: Anthropic's vocabulary, case kept. */
|
|
1689
|
+
static fromXdotool(text2) {
|
|
1690
|
+
return new _KeyChord(
|
|
1691
|
+
text2.trim().split("+").filter(Boolean).map(playwrightKey)
|
|
1692
|
+
);
|
|
1693
|
+
}
|
|
1694
|
+
/** `["CTRL", "A"]`: OpenAI's vocabulary. A lone letter is the unshifted key. */
|
|
1695
|
+
static fromKeys(keys) {
|
|
1696
|
+
return new _KeyChord(keys.map(letterOrName));
|
|
1697
|
+
}
|
|
1698
|
+
/** What `page.keyboard.press` takes: `Control+a`. */
|
|
1699
|
+
get combo() {
|
|
1700
|
+
return this.keys.join("+");
|
|
1701
|
+
}
|
|
1702
|
+
};
|
|
1703
|
+
}
|
|
1704
|
+
});
|
|
1705
|
+
|
|
1706
|
+
// src/worlds/nativeComputer/anthropic.ts
|
|
1707
|
+
function required(raw, key) {
|
|
1708
|
+
const value = raw[key];
|
|
1709
|
+
if (value === void 0 || value === null)
|
|
1710
|
+
throw new Error(`${String(raw.action)} needs ${key}`);
|
|
1711
|
+
return value;
|
|
1712
|
+
}
|
|
1713
|
+
function pair(raw, key) {
|
|
1714
|
+
const value = required(raw, key);
|
|
1715
|
+
return [toInt(value[0]), toInt(value[1])];
|
|
1716
|
+
}
|
|
1717
|
+
function point(raw) {
|
|
1718
|
+
if (raw.coordinate === void 0 || raw.coordinate === null) return {};
|
|
1719
|
+
const [x, y] = pair(raw, "coordinate");
|
|
1720
|
+
return { x, y };
|
|
1721
|
+
}
|
|
1722
|
+
function chord(raw) {
|
|
1723
|
+
return [...KeyChord.fromXdotool(String(required(raw, "text"))).keys];
|
|
1724
|
+
}
|
|
1725
|
+
function click(button, count) {
|
|
1726
|
+
return (raw) => new ComputerAction("click", {
|
|
1727
|
+
...point(raw),
|
|
1728
|
+
button,
|
|
1729
|
+
count,
|
|
1730
|
+
modifiers: modifierChord(raw.text)
|
|
1731
|
+
});
|
|
1732
|
+
}
|
|
1733
|
+
var SCROLL_STEP_PX, NOT_EXECUTED, MAX_ERROR2, SCROLL_DIRECTIONS, MEMBERS, AnthropicComputer, AnthropicComputer20251124;
|
|
1734
|
+
var init_anthropic = __esm({
|
|
1735
|
+
"src/worlds/nativeComputer/anthropic.ts"() {
|
|
1736
|
+
"use strict";
|
|
1737
|
+
init_actions();
|
|
1738
|
+
init_base();
|
|
1739
|
+
init_keys();
|
|
1740
|
+
SCROLL_STEP_PX = 100;
|
|
1741
|
+
NOT_EXECUTED = "Not executed: an earlier computer action in this turn failed.";
|
|
1742
|
+
MAX_ERROR2 = 1e3;
|
|
1743
|
+
SCROLL_DIRECTIONS = {
|
|
1744
|
+
up: [0, -1],
|
|
1745
|
+
down: [0, 1],
|
|
1746
|
+
left: [-1, 0],
|
|
1747
|
+
right: [1, 0]
|
|
1748
|
+
};
|
|
1749
|
+
MEMBERS = {
|
|
1750
|
+
screenshot: () => new ComputerAction("screenshot"),
|
|
1751
|
+
zoom: (raw) => new ComputerAction("zoom", {
|
|
1752
|
+
region: required(raw, "region").map(toInt)
|
|
1753
|
+
}),
|
|
1754
|
+
left_click: click("left", 1),
|
|
1755
|
+
right_click: click("right", 1),
|
|
1756
|
+
middle_click: click("middle", 1),
|
|
1757
|
+
double_click: click("left", 2),
|
|
1758
|
+
triple_click: click("left", 3),
|
|
1759
|
+
left_click_drag: (raw) => new ComputerAction("drag", {
|
|
1760
|
+
path: [pair(raw, "start_coordinate"), pair(raw, "coordinate")],
|
|
1761
|
+
modifiers: modifierChord(raw.text)
|
|
1762
|
+
}),
|
|
1763
|
+
mouse_move: (raw) => {
|
|
1764
|
+
const [x, y] = pair(raw, "coordinate");
|
|
1765
|
+
return new ComputerAction("move", { x, y });
|
|
1766
|
+
},
|
|
1767
|
+
left_mouse_down: () => new ComputerAction("mouse_down", { button: "left" }),
|
|
1768
|
+
left_mouse_up: () => new ComputerAction("mouse_up", { button: "left" }),
|
|
1769
|
+
cursor_position: () => new ComputerAction("cursor_position"),
|
|
1770
|
+
scroll: (raw) => {
|
|
1771
|
+
const direction = String(raw.scroll_direction ?? "down");
|
|
1772
|
+
if (!Object.hasOwn(SCROLL_DIRECTIONS, direction))
|
|
1773
|
+
throw new Error(
|
|
1774
|
+
`scroll_direction must be one of ${Object.keys(SCROLL_DIRECTIONS).join(", ")}`
|
|
1775
|
+
);
|
|
1776
|
+
const [dx, dy] = SCROLL_DIRECTIONS[direction];
|
|
1777
|
+
const amount = toInt(raw.scroll_amount ?? 1) * SCROLL_STEP_PX;
|
|
1778
|
+
return new ComputerAction("scroll", {
|
|
1779
|
+
...point(raw),
|
|
1780
|
+
dx: dx * amount,
|
|
1781
|
+
dy: dy * amount,
|
|
1782
|
+
modifiers: modifierChord(raw.text)
|
|
1783
|
+
});
|
|
1784
|
+
},
|
|
1785
|
+
type: (raw) => new ComputerAction("type", { text: String(required(raw, "text")) }),
|
|
1786
|
+
key: (raw) => new ComputerAction("key", {
|
|
1787
|
+
keys: chord(raw),
|
|
1788
|
+
repeat: toInt(raw.repeat ?? 1)
|
|
1789
|
+
}),
|
|
1790
|
+
hold_key: (raw) => new ComputerAction("hold_key", {
|
|
1791
|
+
keys: chord(raw),
|
|
1792
|
+
seconds: toNumber(required(raw, "duration"))
|
|
1793
|
+
}),
|
|
1794
|
+
wait: (raw) => new ComputerAction("wait", { seconds: toNumber(raw.duration ?? 1) })
|
|
1795
|
+
};
|
|
1796
|
+
AnthropicComputer = class _AnthropicComputer extends NativeComputer {
|
|
1797
|
+
static TOOL_TYPE = "computer_toolset_20260801";
|
|
1798
|
+
static TOOLSET = "computer";
|
|
1799
|
+
static BETA = null;
|
|
1800
|
+
static MAX_LONG_EDGE = 2576;
|
|
1801
|
+
static MAX_VISUAL_TOKENS = 4784;
|
|
1802
|
+
static PATCH_PX = 28;
|
|
1803
|
+
static fits(width, height) {
|
|
1804
|
+
const tokens = Math.ceil(width / this.PATCH_PX) * Math.ceil(height / this.PATCH_PX);
|
|
1805
|
+
return Math.max(width, height) <= this.MAX_LONG_EDGE && tokens <= this.MAX_VISUAL_TOKENS;
|
|
1806
|
+
}
|
|
1807
|
+
tool() {
|
|
1808
|
+
return { type: _AnthropicComputer.TOOL_TYPE };
|
|
1809
|
+
}
|
|
1810
|
+
/** Whether a content block is a call to this computer. */
|
|
1811
|
+
owns(block) {
|
|
1812
|
+
return readField(block, "type") === "tool_use" && readField(block, "toolset_name") === _AnthropicComputer.TOOLSET;
|
|
1813
|
+
}
|
|
1814
|
+
member(block) {
|
|
1815
|
+
return [
|
|
1816
|
+
String(readField(block, "name")),
|
|
1817
|
+
{ ...readField(block, "input") ?? {} }
|
|
1818
|
+
];
|
|
1819
|
+
}
|
|
1820
|
+
parse(raw) {
|
|
1821
|
+
const name = String(readField(raw, "action"));
|
|
1822
|
+
const parser = Object.hasOwn(MEMBERS, name) ? MEMBERS[name] : void 0;
|
|
1823
|
+
if (!parser) throw new Error(`unknown computer action: ${name}`);
|
|
1824
|
+
return parser(raw);
|
|
1825
|
+
}
|
|
1826
|
+
/** Run every computer `tool_use` in a response's content, in order, and
|
|
1827
|
+
* return one `tool_result` per block. Other blocks are skipped. */
|
|
1828
|
+
async execute(content) {
|
|
1829
|
+
const results = [];
|
|
1830
|
+
let failed = false;
|
|
1831
|
+
for (const block of content) {
|
|
1832
|
+
if (!this.owns(block)) continue;
|
|
1833
|
+
if (failed) {
|
|
1834
|
+
results.push(this.envelope(block, NOT_EXECUTED, true));
|
|
1835
|
+
continue;
|
|
1836
|
+
}
|
|
1837
|
+
const [result, blockFailed] = await this.runBlock(block);
|
|
1838
|
+
results.push(result);
|
|
1839
|
+
failed = blockFailed;
|
|
1840
|
+
}
|
|
1841
|
+
return results;
|
|
1842
|
+
}
|
|
1843
|
+
/** The content an `ActionResult` goes back to the model as. */
|
|
1844
|
+
static content(result) {
|
|
1845
|
+
if (result.image)
|
|
1846
|
+
return [
|
|
1847
|
+
{
|
|
1848
|
+
type: "image",
|
|
1849
|
+
source: {
|
|
1850
|
+
type: "base64",
|
|
1851
|
+
media_type: "image/png",
|
|
1852
|
+
data: result.image.toString("base64")
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
];
|
|
1856
|
+
return [{ type: "text", text: result.text ?? "OK" }];
|
|
1857
|
+
}
|
|
1858
|
+
/** For `anthropic.tools.computerToolset_20260801({ ...computer.aiSdk() })`
|
|
1859
|
+
* (or `computer_20251124` with the legacy kind): `execute` runs one action
|
|
1860
|
+
* and returns `{ type: "image", data }` or text; `toModelOutput` turns that
|
|
1861
|
+
* into the tool result. Calls run one at a time, and once a call fails the
|
|
1862
|
+
* rest of that step's calls answer as not executed. */
|
|
1863
|
+
aiSdk() {
|
|
1864
|
+
let failedStep;
|
|
1865
|
+
const execute = (input, options) => this.serial(async () => {
|
|
1866
|
+
const step = options?.messages?.length;
|
|
1867
|
+
if (step !== void 0 && step === failedStep)
|
|
1868
|
+
throw new Error(NOT_EXECUTED);
|
|
1869
|
+
try {
|
|
1870
|
+
return _AnthropicComputer.aiSdkOutput(await this.executeAction(input));
|
|
1871
|
+
} catch (error) {
|
|
1872
|
+
failedStep = step;
|
|
1873
|
+
throw error instanceof Error ? new Error(this.browser.scrub(error.message)) : error;
|
|
1874
|
+
}
|
|
1875
|
+
});
|
|
1876
|
+
return {
|
|
1877
|
+
execute,
|
|
1878
|
+
toModelOutput: ({ output }) => _AnthropicComputer.aiSdkModelOutput(output)
|
|
1879
|
+
};
|
|
1880
|
+
}
|
|
1881
|
+
static aiSdkOutput(result) {
|
|
1882
|
+
if (result.image)
|
|
1883
|
+
return { type: "image", data: result.image.toString("base64") };
|
|
1884
|
+
return result.text ?? "OK";
|
|
1885
|
+
}
|
|
1886
|
+
/** `image-data` is what AI SDK 6's Anthropic provider turns into an image
|
|
1887
|
+
* block; AI SDK 7 still accepts it (and converts it to a `file` part). */
|
|
1888
|
+
static aiSdkModelOutput(output) {
|
|
1889
|
+
if (typeof output === "string") return { type: "text", value: output };
|
|
1890
|
+
return {
|
|
1891
|
+
type: "content",
|
|
1892
|
+
value: [
|
|
1893
|
+
{ type: "image-data", data: output.data, mediaType: "image/png" }
|
|
1894
|
+
]
|
|
1895
|
+
};
|
|
1896
|
+
}
|
|
1897
|
+
envelope(block, content, isError = false) {
|
|
1898
|
+
return {
|
|
1899
|
+
type: "tool_result",
|
|
1900
|
+
tool_use_id: String(readField(block, "id")),
|
|
1901
|
+
toolset_name: _AnthropicComputer.TOOLSET,
|
|
1902
|
+
content,
|
|
1903
|
+
...isError ? { is_error: true } : {}
|
|
1904
|
+
};
|
|
1905
|
+
}
|
|
1906
|
+
async runBlock(block) {
|
|
1907
|
+
const [name, payload] = this.member(block);
|
|
1908
|
+
try {
|
|
1909
|
+
const result = await this.executeAction({ ...payload, action: name });
|
|
1910
|
+
return [this.envelope(block, _AnthropicComputer.content(result)), false];
|
|
1911
|
+
} catch (error) {
|
|
1912
|
+
const detail = error instanceof Error ? `${error.name}: ${error.message}` : String(error);
|
|
1913
|
+
return [
|
|
1914
|
+
this.envelope(
|
|
1915
|
+
block,
|
|
1916
|
+
this.browser.scrub(`Error: ${detail}`).slice(0, MAX_ERROR2),
|
|
1917
|
+
true
|
|
1918
|
+
),
|
|
1919
|
+
true
|
|
1920
|
+
];
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1923
|
+
};
|
|
1924
|
+
AnthropicComputer20251124 = class _AnthropicComputer20251124 extends AnthropicComputer {
|
|
1925
|
+
static TOOL_TYPE = "computer_20251124";
|
|
1926
|
+
static BETA = "computer-use-2025-11-24";
|
|
1927
|
+
static MAX_LONG_EDGE = 1568;
|
|
1928
|
+
static MAX_PIXELS = 115e4;
|
|
1929
|
+
static fits(width, height) {
|
|
1930
|
+
return Math.max(width, height) <= this.MAX_LONG_EDGE && width * height <= this.MAX_PIXELS;
|
|
1931
|
+
}
|
|
1932
|
+
tool() {
|
|
1933
|
+
return {
|
|
1934
|
+
type: _AnthropicComputer20251124.TOOL_TYPE,
|
|
1935
|
+
name: AnthropicComputer.TOOLSET,
|
|
1936
|
+
display_width_px: this.display.width,
|
|
1937
|
+
display_height_px: this.display.height,
|
|
1938
|
+
enable_zoom: true
|
|
1939
|
+
};
|
|
1940
|
+
}
|
|
1941
|
+
owns(block) {
|
|
1942
|
+
return readField(block, "type") === "tool_use" && readField(block, "name") === AnthropicComputer.TOOLSET;
|
|
1943
|
+
}
|
|
1944
|
+
member(block) {
|
|
1945
|
+
const { action, ...payload } = readField(block, "input") ?? {};
|
|
1946
|
+
return [String(action ?? ""), payload];
|
|
1947
|
+
}
|
|
1948
|
+
envelope(block, content, isError = false) {
|
|
1949
|
+
const { toolset_name: _dropped, ...rest } = super.envelope(
|
|
1950
|
+
block,
|
|
1951
|
+
content,
|
|
1952
|
+
isError
|
|
1953
|
+
);
|
|
1954
|
+
return rest;
|
|
1955
|
+
}
|
|
1956
|
+
};
|
|
1957
|
+
NativeComputer.register("anthropic", AnthropicComputer);
|
|
1958
|
+
NativeComputer.register(
|
|
1959
|
+
"anthropic-computer-20251124",
|
|
1960
|
+
AnthropicComputer20251124
|
|
1961
|
+
);
|
|
1962
|
+
}
|
|
1963
|
+
});
|
|
1964
|
+
|
|
1965
|
+
// src/worlds/nativeComputer/openai.ts
|
|
1966
|
+
function safetyCheck(raw) {
|
|
1967
|
+
const check = { id: String(readField(raw, "id") ?? "") };
|
|
1968
|
+
const code = readField(raw, "code");
|
|
1969
|
+
const message = readField(raw, "message");
|
|
1970
|
+
if (code !== void 0) check.code = String(code);
|
|
1971
|
+
if (message !== void 0) check.message = String(message);
|
|
1972
|
+
return check;
|
|
1973
|
+
}
|
|
1974
|
+
function dataUrl(png) {
|
|
1975
|
+
return `data:image/png;base64,${png.toString("base64")}`;
|
|
1976
|
+
}
|
|
1977
|
+
function xy(raw) {
|
|
1978
|
+
return {
|
|
1979
|
+
x: toInt(readField(raw, "x") ?? 0),
|
|
1980
|
+
y: toInt(readField(raw, "y") ?? 0)
|
|
1981
|
+
};
|
|
1982
|
+
}
|
|
1983
|
+
function held(raw) {
|
|
1984
|
+
return modifierKeys(readField(raw, "keys"));
|
|
1985
|
+
}
|
|
1986
|
+
var WAIT_SECONDS, BUTTONS, HISTORY_BUTTONS, PendingSafetyChecks, ACTIONS, OpenAIComputer, OpenAIPreviewComputer;
|
|
1987
|
+
var init_openai = __esm({
|
|
1988
|
+
"src/worlds/nativeComputer/openai.ts"() {
|
|
1989
|
+
"use strict";
|
|
1990
|
+
init_actions();
|
|
1991
|
+
init_base();
|
|
1992
|
+
init_keys();
|
|
1993
|
+
WAIT_SECONDS = 1;
|
|
1994
|
+
BUTTONS = {
|
|
1995
|
+
left: "left",
|
|
1996
|
+
right: "right",
|
|
1997
|
+
wheel: "middle",
|
|
1998
|
+
middle: "middle"
|
|
1999
|
+
};
|
|
2000
|
+
HISTORY_BUTTONS = /* @__PURE__ */ new Set(["back", "forward"]);
|
|
2001
|
+
PendingSafetyChecks = class extends Error {
|
|
2002
|
+
constructor(callId, checks) {
|
|
2003
|
+
const listed = checks.map((c) => `${c.code ?? "check"}: ${c.message ?? ""}`.trim()).join("; ");
|
|
2004
|
+
super(
|
|
2005
|
+
`computer_call ${callId} needs ${checks.length} safety check(s) acknowledged: ${listed}`
|
|
2006
|
+
);
|
|
2007
|
+
this.callId = callId;
|
|
2008
|
+
this.checks = checks;
|
|
2009
|
+
this.name = "PendingSafetyChecks";
|
|
2010
|
+
}
|
|
2011
|
+
callId;
|
|
2012
|
+
checks;
|
|
2013
|
+
};
|
|
2014
|
+
ACTIONS = {
|
|
2015
|
+
click: (raw) => {
|
|
2016
|
+
const button = String(readField(raw, "button") ?? "left");
|
|
2017
|
+
if (HISTORY_BUTTONS.has(button))
|
|
2018
|
+
return new ComputerAction("history", {
|
|
2019
|
+
direction: button
|
|
2020
|
+
});
|
|
2021
|
+
if (!Object.hasOwn(BUTTONS, button))
|
|
2022
|
+
throw new Error(`unknown mouse button: ${button}`);
|
|
2023
|
+
return new ComputerAction("click", {
|
|
2024
|
+
...xy(raw),
|
|
2025
|
+
button: BUTTONS[button],
|
|
2026
|
+
count: 1,
|
|
2027
|
+
modifiers: held(raw)
|
|
2028
|
+
});
|
|
2029
|
+
},
|
|
2030
|
+
double_click: (raw) => new ComputerAction("click", {
|
|
2031
|
+
...xy(raw),
|
|
2032
|
+
button: "left",
|
|
2033
|
+
count: 2,
|
|
2034
|
+
modifiers: held(raw)
|
|
2035
|
+
}),
|
|
2036
|
+
drag: (raw) => new ComputerAction("drag", {
|
|
2037
|
+
path: (readField(raw, "path") ?? []).map(
|
|
2038
|
+
(p) => [toInt(readField(p, "x")), toInt(readField(p, "y"))]
|
|
2039
|
+
),
|
|
2040
|
+
modifiers: held(raw)
|
|
2041
|
+
}),
|
|
2042
|
+
keypress: (raw) => new ComputerAction("key", {
|
|
2043
|
+
keys: [
|
|
2044
|
+
...KeyChord.fromKeys(readField(raw, "keys") ?? []).keys
|
|
2045
|
+
],
|
|
2046
|
+
repeat: 1
|
|
2047
|
+
}),
|
|
2048
|
+
move: (raw) => new ComputerAction("move", { ...xy(raw), modifiers: held(raw) }),
|
|
2049
|
+
scroll: (raw) => new ComputerAction("scroll", {
|
|
2050
|
+
...xy(raw),
|
|
2051
|
+
dx: toInt(readField(raw, "scroll_x", "scrollX") ?? 0),
|
|
2052
|
+
dy: toInt(readField(raw, "scroll_y", "scrollY") ?? 0),
|
|
2053
|
+
modifiers: held(raw)
|
|
2054
|
+
}),
|
|
2055
|
+
type: (raw) => new ComputerAction("type", { text: String(readField(raw, "text") ?? "") }),
|
|
2056
|
+
wait: () => new ComputerAction("wait", { seconds: WAIT_SECONDS }),
|
|
2057
|
+
screenshot: () => new ComputerAction("screenshot")
|
|
2058
|
+
};
|
|
2059
|
+
OpenAIComputer = class _OpenAIComputer extends NativeComputer {
|
|
2060
|
+
tool() {
|
|
2061
|
+
return { type: "computer" };
|
|
2062
|
+
}
|
|
2063
|
+
owns(item) {
|
|
2064
|
+
return readField(item, "type") === "computer_call";
|
|
2065
|
+
}
|
|
2066
|
+
parse(raw) {
|
|
2067
|
+
const kind = String(readField(raw, "type"));
|
|
2068
|
+
const parser = Object.hasOwn(ACTIONS, kind) ? ACTIONS[kind] : void 0;
|
|
2069
|
+
if (!parser) throw new Error(`unknown computer action: ${kind}`);
|
|
2070
|
+
return parser(raw);
|
|
2071
|
+
}
|
|
2072
|
+
static actionsOf(call) {
|
|
2073
|
+
const batch = readField(call, "actions");
|
|
2074
|
+
if (Array.isArray(batch)) return batch;
|
|
2075
|
+
const single = readField(call, "action");
|
|
2076
|
+
return single === void 0 ? [] : [single];
|
|
2077
|
+
}
|
|
2078
|
+
/** Run a `computer_call`'s actions and return its `computer_call_output`.
|
|
2079
|
+
* Throws `PendingSafetyChecks` (before anything runs) while a check the
|
|
2080
|
+
* model raised is not in `acknowledged`. */
|
|
2081
|
+
async execute(call, acknowledged = []) {
|
|
2082
|
+
const callId = String(readField(call, "call_id", "callId"));
|
|
2083
|
+
const checks = (readField(
|
|
2084
|
+
call,
|
|
2085
|
+
"pending_safety_checks",
|
|
2086
|
+
"pendingSafetyChecks"
|
|
2087
|
+
) ?? []).map(safetyCheck);
|
|
2088
|
+
const png = await this.runCall(
|
|
2089
|
+
callId,
|
|
2090
|
+
_OpenAIComputer.actionsOf(call),
|
|
2091
|
+
checks,
|
|
2092
|
+
acknowledged
|
|
2093
|
+
);
|
|
2094
|
+
return {
|
|
2095
|
+
type: "computer_call_output",
|
|
2096
|
+
call_id: callId,
|
|
2097
|
+
output: {
|
|
2098
|
+
type: "computer_screenshot",
|
|
2099
|
+
image_url: dataUrl(png),
|
|
2100
|
+
detail: "original"
|
|
2101
|
+
},
|
|
2102
|
+
...checks.length > 0 ? { acknowledged_safety_checks: checks } : {}
|
|
2103
|
+
};
|
|
2104
|
+
}
|
|
2105
|
+
/** For `openai.tools.computer({ ...computer.aiSdk() })`: `execute` runs a
|
|
2106
|
+
* call's `actions` and returns the screenshot output. A call with pending
|
|
2107
|
+
* safety checks asks for approval first (`needsApproval`), so the AI SDK's
|
|
2108
|
+
* approval flow puts them in front of a person; once approved, `execute`
|
|
2109
|
+
* acknowledges them. */
|
|
2110
|
+
aiSdk() {
|
|
2111
|
+
return {
|
|
2112
|
+
needsApproval: (input) => (input.pendingSafetyChecks ?? []).length > 0,
|
|
2113
|
+
execute: (input) => this.serial(async () => {
|
|
2114
|
+
const checks = (input.pendingSafetyChecks ?? []).map(safetyCheck);
|
|
2115
|
+
const png = await this.runCall(
|
|
2116
|
+
"ai-sdk",
|
|
2117
|
+
input.actions ?? [],
|
|
2118
|
+
checks,
|
|
2119
|
+
checks
|
|
2120
|
+
);
|
|
2121
|
+
return {
|
|
2122
|
+
output: { type: "computer_screenshot", imageUrl: dataUrl(png) },
|
|
2123
|
+
...checks.length > 0 ? { acknowledgedSafetyChecks: checks } : {}
|
|
2124
|
+
};
|
|
2125
|
+
})
|
|
2126
|
+
};
|
|
2127
|
+
}
|
|
2128
|
+
/** The batch's actions, run after the safety checks clear; the screen after them. */
|
|
2129
|
+
async runCall(callId, rawActions, checks, acknowledged) {
|
|
2130
|
+
const cleared = new Set(acknowledged.map((c) => safetyCheck(c).id));
|
|
2131
|
+
const waiting = checks.filter((c) => !c.id || !cleared.has(c.id));
|
|
2132
|
+
if (waiting.length > 0) throw new PendingSafetyChecks(callId, waiting);
|
|
2133
|
+
const actions = rawActions.map((raw) => this.parse(raw));
|
|
2134
|
+
const results = await this.performAll(actions);
|
|
2135
|
+
const last = actions.at(-1);
|
|
2136
|
+
if (last?.name === "screenshot")
|
|
2137
|
+
return results.at(-1)?.image ?? Buffer.alloc(0);
|
|
2138
|
+
return this.screenshot();
|
|
2139
|
+
}
|
|
2140
|
+
};
|
|
2141
|
+
OpenAIPreviewComputer = class extends OpenAIComputer {
|
|
2142
|
+
tool() {
|
|
2143
|
+
return {
|
|
2144
|
+
type: "computer_use_preview",
|
|
2145
|
+
display_width: this.display.width,
|
|
2146
|
+
display_height: this.display.height,
|
|
2147
|
+
environment: "browser"
|
|
2148
|
+
};
|
|
2149
|
+
}
|
|
2150
|
+
};
|
|
2151
|
+
NativeComputer.register("openai", OpenAIComputer);
|
|
2152
|
+
NativeComputer.register("openai-preview", OpenAIPreviewComputer);
|
|
2153
|
+
}
|
|
2154
|
+
});
|
|
2155
|
+
|
|
2156
|
+
// src/worlds/nativeComputer/index.ts
|
|
2157
|
+
var init_nativeComputer = __esm({
|
|
2158
|
+
"src/worlds/nativeComputer/index.ts"() {
|
|
2159
|
+
"use strict";
|
|
2160
|
+
init_actions();
|
|
2161
|
+
init_base();
|
|
2162
|
+
init_display();
|
|
2163
|
+
init_keys();
|
|
2164
|
+
init_screen();
|
|
2165
|
+
init_trace();
|
|
2166
|
+
init_anthropic();
|
|
2167
|
+
init_openai();
|
|
792
2168
|
}
|
|
793
2169
|
});
|
|
794
2170
|
|
|
@@ -845,6 +2221,75 @@ var init_sessionContract = __esm({
|
|
|
845
2221
|
}
|
|
846
2222
|
});
|
|
847
2223
|
|
|
2224
|
+
// src/tracing/session.ts
|
|
2225
|
+
var session_exports = {};
|
|
2226
|
+
__export(session_exports, {
|
|
2227
|
+
SESSION_ID_ATTRIBUTE: () => SESSION_ID_ATTRIBUTE,
|
|
2228
|
+
SessionSpanProcessor: () => SessionSpanProcessor,
|
|
2229
|
+
WORLD_SESSION_ID_ATTRIBUTE: () => WORLD_SESSION_ID_ATTRIBUTE,
|
|
2230
|
+
getAmbientSessionId: () => getAmbientSessionId,
|
|
2231
|
+
getCurrentWorldSessionId: () => getCurrentWorldSessionId,
|
|
2232
|
+
withSession: () => withSession,
|
|
2233
|
+
withWorldSession: () => withWorldSession
|
|
2234
|
+
});
|
|
2235
|
+
function getAmbientSessionId() {
|
|
2236
|
+
return currentSessionStorage.getStore();
|
|
2237
|
+
}
|
|
2238
|
+
function getCurrentWorldSessionId() {
|
|
2239
|
+
return currentWorldSessionStorage.getStore();
|
|
2240
|
+
}
|
|
2241
|
+
function runIn(storage, value, fn) {
|
|
2242
|
+
return new Promise((resolve7, reject) => {
|
|
2243
|
+
storage.run(value, () => {
|
|
2244
|
+
Promise.resolve().then(fn).then(resolve7, reject);
|
|
2245
|
+
});
|
|
2246
|
+
});
|
|
2247
|
+
}
|
|
2248
|
+
function withSession(sessionId, fn) {
|
|
2249
|
+
return runIn(currentSessionStorage, sessionId, fn);
|
|
2250
|
+
}
|
|
2251
|
+
function withWorldSession(worldSessionId, fn) {
|
|
2252
|
+
return runIn(
|
|
2253
|
+
currentWorldSessionStorage,
|
|
2254
|
+
worldSessionId,
|
|
2255
|
+
() => withSession(worldSessionId, fn)
|
|
2256
|
+
);
|
|
2257
|
+
}
|
|
2258
|
+
var import_async_hooks, SESSION_ID_ATTRIBUTE, WORLD_SESSION_ID_ATTRIBUTE, processStorage, currentSessionStorage, currentWorldSessionStorage, SessionSpanProcessor;
|
|
2259
|
+
var init_session = __esm({
|
|
2260
|
+
"src/tracing/session.ts"() {
|
|
2261
|
+
"use strict";
|
|
2262
|
+
import_async_hooks = require("async_hooks");
|
|
2263
|
+
SESSION_ID_ATTRIBUTE = "gateway.session.id";
|
|
2264
|
+
WORLD_SESSION_ID_ATTRIBUTE = "gateway.trace.metadata.world_session_id";
|
|
2265
|
+
processStorage = (name) => {
|
|
2266
|
+
const key = /* @__PURE__ */ Symbol.for(`@withgateway/sdk/${name}`);
|
|
2267
|
+
const slots = globalThis;
|
|
2268
|
+
slots[key] ??= new import_async_hooks.AsyncLocalStorage();
|
|
2269
|
+
return slots[key];
|
|
2270
|
+
};
|
|
2271
|
+
currentSessionStorage = processStorage("session-storage");
|
|
2272
|
+
currentWorldSessionStorage = processStorage("world-session-storage");
|
|
2273
|
+
SessionSpanProcessor = class {
|
|
2274
|
+
onStart(span, _parentContext) {
|
|
2275
|
+
const worldSessionId = getCurrentWorldSessionId();
|
|
2276
|
+
if (worldSessionId)
|
|
2277
|
+
span.setAttribute(WORLD_SESSION_ID_ATTRIBUTE, worldSessionId);
|
|
2278
|
+
const sessionId = getAmbientSessionId();
|
|
2279
|
+
if (!sessionId || span.attributes?.[SESSION_ID_ATTRIBUTE] !== void 0)
|
|
2280
|
+
return;
|
|
2281
|
+
span.setAttribute(SESSION_ID_ATTRIBUTE, sessionId);
|
|
2282
|
+
}
|
|
2283
|
+
onEnd(_span) {
|
|
2284
|
+
}
|
|
2285
|
+
async shutdown() {
|
|
2286
|
+
}
|
|
2287
|
+
async forceFlush() {
|
|
2288
|
+
}
|
|
2289
|
+
};
|
|
2290
|
+
}
|
|
2291
|
+
});
|
|
2292
|
+
|
|
848
2293
|
// src/worlds/taskRef.ts
|
|
849
2294
|
var isTaskIdRef, isTaskSpec, taskLabel, assertTaskRef;
|
|
850
2295
|
var init_taskRef = __esm({
|
|
@@ -869,8 +2314,8 @@ var init_taskRef = __esm({
|
|
|
869
2314
|
});
|
|
870
2315
|
|
|
871
2316
|
// src/worlds/session.ts
|
|
872
|
-
var
|
|
873
|
-
__export(
|
|
2317
|
+
var session_exports2 = {};
|
|
2318
|
+
__export(session_exports2, {
|
|
874
2319
|
WorldSession: () => WorldSession,
|
|
875
2320
|
WorldSessionCallError: () => WorldSessionCallError,
|
|
876
2321
|
WorldSessionTimeout: () => WorldSessionTimeout,
|
|
@@ -923,7 +2368,7 @@ function schemaFromSignature(spec) {
|
|
|
923
2368
|
};
|
|
924
2369
|
const inside = /\(([\s\S]*)\)\s*$/.exec(spec.signature.trim())?.[1] ?? "";
|
|
925
2370
|
const properties = {};
|
|
926
|
-
const
|
|
2371
|
+
const required2 = [];
|
|
927
2372
|
const params = [];
|
|
928
2373
|
let depth = 0;
|
|
929
2374
|
let current = "";
|
|
@@ -944,7 +2389,7 @@ function schemaFromSignature(spec) {
|
|
|
944
2389
|
if (!name) continue;
|
|
945
2390
|
if (eq === -1) {
|
|
946
2391
|
properties[name] = { type: "string" };
|
|
947
|
-
|
|
2392
|
+
required2.push(name);
|
|
948
2393
|
continue;
|
|
949
2394
|
}
|
|
950
2395
|
const value = param.slice(eq + 1).trim();
|
|
@@ -958,7 +2403,7 @@ function schemaFromSignature(spec) {
|
|
|
958
2403
|
function: {
|
|
959
2404
|
name: modelToolName(spec.name),
|
|
960
2405
|
description: spec.doc ?? spec.name,
|
|
961
|
-
parameters: { type: "object", properties, required }
|
|
2406
|
+
parameters: { type: "object", properties, required: required2 }
|
|
962
2407
|
}
|
|
963
2408
|
};
|
|
964
2409
|
}
|
|
@@ -1027,13 +2472,16 @@ async function runSessions(opts) {
|
|
|
1027
2472
|
task = taskLabel(taskRef, session.taskInfo);
|
|
1028
2473
|
await session.ready();
|
|
1029
2474
|
const toolkit = await session.toolkit();
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
2475
|
+
const live = session;
|
|
2476
|
+
await live.withTraceContext(
|
|
2477
|
+
() => opts.agent({
|
|
2478
|
+
session: live,
|
|
2479
|
+
toolkit,
|
|
2480
|
+
instruction: live.instruction ?? (isTaskSpec(taskRef) ? taskRef.instruction : task),
|
|
2481
|
+
task,
|
|
2482
|
+
taskRef
|
|
2483
|
+
})
|
|
2484
|
+
);
|
|
1037
2485
|
const graded = await session.grade();
|
|
1038
2486
|
const result = {
|
|
1039
2487
|
task,
|
|
@@ -1070,14 +2518,16 @@ async function runSessions(opts) {
|
|
|
1070
2518
|
passed: failed === 0 && (opts.failUnder === void 0 || mean >= opts.failUnder)
|
|
1071
2519
|
};
|
|
1072
2520
|
}
|
|
1073
|
-
var
|
|
1074
|
-
var
|
|
2521
|
+
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, sleep, modelToolName, WorldSessionTimeout, WorldSessionCallError, WorldSession, OPEN_SESSION_OPTION_KEYS, isOpenSessionOptions;
|
|
2522
|
+
var init_session2 = __esm({
|
|
1075
2523
|
"src/worlds/session.ts"() {
|
|
1076
2524
|
"use strict";
|
|
1077
|
-
|
|
2525
|
+
import_node_crypto2 = require("crypto");
|
|
1078
2526
|
init_worlds();
|
|
1079
2527
|
init_browser();
|
|
2528
|
+
init_nativeComputer();
|
|
1080
2529
|
init_sessionContract();
|
|
2530
|
+
init_session();
|
|
1081
2531
|
init_taskRef();
|
|
1082
2532
|
init_taskRef();
|
|
1083
2533
|
READY_TIMEOUT_MS = 10 * 6e4;
|
|
@@ -1211,7 +2661,7 @@ var init_session = __esm({
|
|
|
1211
2661
|
/** The reporter `browser()` uses; exposed for a page you drive yourself. */
|
|
1212
2662
|
browserRecorder(agentId) {
|
|
1213
2663
|
const path12 = `/api/public/world-sessions/${encodeURIComponent(this.sessionId)}/browser-events`;
|
|
1214
|
-
const id = agentId ?? process.env.GATEWAY_AGENT_ID ?? `agent-${(0,
|
|
2664
|
+
const id = agentId ?? process.env.GATEWAY_AGENT_ID ?? `agent-${(0, import_node_crypto2.randomUUID)().replace(/-/g, "").slice(0, 8)}`;
|
|
1215
2665
|
return new BrowserActionRecorder(
|
|
1216
2666
|
async (events) => {
|
|
1217
2667
|
await apiRequest(this.options, "POST", path12, { events });
|
|
@@ -1231,6 +2681,12 @@ var init_session = __esm({
|
|
|
1231
2681
|
computerUseTools(browser) {
|
|
1232
2682
|
return computerUseToolkit(browser);
|
|
1233
2683
|
}
|
|
2684
|
+
/** The browser as a provider's own pixel-based computer-use tool: `anthropic`
|
|
2685
|
+
* (`computer_toolset_20260801`), `openai` (Responses `computer`),
|
|
2686
|
+
* `anthropic-computer-20251124` or `openai-preview`. See `nativeComputer/`. */
|
|
2687
|
+
nativeComputer(browser, provider = "anthropic", options = {}) {
|
|
2688
|
+
return NativeComputer.forProvider(provider, browser, options);
|
|
2689
|
+
}
|
|
1234
2690
|
/** The session's latest platform state (one request, no waiting). */
|
|
1235
2691
|
async status() {
|
|
1236
2692
|
const fresh = await apiRequest(
|
|
@@ -1465,6 +2921,21 @@ var init_session = __esm({
|
|
|
1465
2921
|
{ keepWarm: opts.keepWarm ?? false }
|
|
1466
2922
|
);
|
|
1467
2923
|
}
|
|
2924
|
+
/**
|
|
2925
|
+
* Run `fn` as work inside this session: spans it records take `sessionId`
|
|
2926
|
+
* as their session id and carry `world_session_id` trace metadata, so the
|
|
2927
|
+
* agent's traces land in the same session as the platform's traces of this
|
|
2928
|
+
* session's tool calls. A `withSession()` block inside still wins for the
|
|
2929
|
+
* session id. No effect before `tracing.init()`. `runSessions` wraps each
|
|
2930
|
+
* agent call in it.
|
|
2931
|
+
*
|
|
2932
|
+
* ```typescript
|
|
2933
|
+
* await session.withTraceContext(() => myAgent(toolkit, session.instruction));
|
|
2934
|
+
* ```
|
|
2935
|
+
*/
|
|
2936
|
+
withTraceContext(fn) {
|
|
2937
|
+
return withWorldSession(this.sessionId, fn);
|
|
2938
|
+
}
|
|
1468
2939
|
};
|
|
1469
2940
|
OPEN_SESSION_OPTION_KEYS = /* @__PURE__ */ new Set([
|
|
1470
2941
|
"task",
|
|
@@ -1614,7 +3085,11 @@ function fromResponse(answer, options) {
|
|
|
1614
3085
|
const worlds = {};
|
|
1615
3086
|
for (const [alias, state2] of Object.entries(answer.sessions)) {
|
|
1616
3087
|
sessions[alias] = new WorldSession(state2.sessionId, state2, options);
|
|
1617
|
-
worlds[alias] = {
|
|
3088
|
+
worlds[alias] = {
|
|
3089
|
+
slug: state2.slug,
|
|
3090
|
+
ref: state2.ref,
|
|
3091
|
+
private: state2.private ?? null
|
|
3092
|
+
};
|
|
1618
3093
|
}
|
|
1619
3094
|
return new TaskSessions(
|
|
1620
3095
|
answer.taskId,
|
|
@@ -1688,6 +3163,7 @@ async function attachTask(taskId, options = {}) {
|
|
|
1688
3163
|
{
|
|
1689
3164
|
slug: row.slug ?? "",
|
|
1690
3165
|
ref: null,
|
|
3166
|
+
private: null,
|
|
1691
3167
|
versionId: row.versionId,
|
|
1692
3168
|
sessionId: row.sessionId,
|
|
1693
3169
|
ready: row.ready,
|
|
@@ -1717,7 +3193,7 @@ async function attachManifest(manifest, options = {}) {
|
|
|
1717
3193
|
Object.fromEntries(
|
|
1718
3194
|
Object.entries(manifest.sessions).map(([alias, entry]) => [
|
|
1719
3195
|
alias,
|
|
1720
|
-
{ slug: entry.slug, ref: entry.ref }
|
|
3196
|
+
{ slug: entry.slug, ref: entry.ref, private: entry.private ?? null }
|
|
1721
3197
|
])
|
|
1722
3198
|
)
|
|
1723
3199
|
);
|
|
@@ -1731,12 +3207,13 @@ var init_taskSessions = __esm({
|
|
|
1731
3207
|
"use strict";
|
|
1732
3208
|
init_worlds();
|
|
1733
3209
|
init_browser();
|
|
1734
|
-
|
|
3210
|
+
init_session2();
|
|
1735
3211
|
TASK_SESSIONS = "/api/public/world-task-sessions";
|
|
1736
3212
|
VERIFIER_REWARD_PREFIX = "x.";
|
|
1737
3213
|
manifestSession = (s, state2, world) => ({
|
|
1738
3214
|
slug: world.slug,
|
|
1739
3215
|
ref: world.ref,
|
|
3216
|
+
private: world.private,
|
|
1740
3217
|
versionId: state2.versionId,
|
|
1741
3218
|
sessionId: state2.sessionId,
|
|
1742
3219
|
ready: state2.ready,
|
|
@@ -1771,10 +3248,10 @@ var init_taskSessions = __esm({
|
|
|
1771
3248
|
sessions;
|
|
1772
3249
|
worlds;
|
|
1773
3250
|
hash;
|
|
1774
|
-
/** This alias's
|
|
1775
|
-
*
|
|
3251
|
+
/** This alias's world as recorded at open/attach — what a `TaskRun`
|
|
3252
|
+
* filing needs to name, without exposing the whole map. */
|
|
1776
3253
|
worldRef(alias) {
|
|
1777
|
-
return this.worlds[alias] ?? { slug: "", ref: null };
|
|
3254
|
+
return this.worlds[alias] ?? { slug: "", ref: null, private: null };
|
|
1778
3255
|
}
|
|
1779
3256
|
/** The aliases, in the spec's order. */
|
|
1780
3257
|
get aliases() {
|
|
@@ -2144,15 +3621,15 @@ function resolveUserId() {
|
|
|
2144
3621
|
const envUser = process.env.GATEWAY_USER_ID?.trim();
|
|
2145
3622
|
return envUser ? envUser : void 0;
|
|
2146
3623
|
}
|
|
2147
|
-
var
|
|
3624
|
+
var import_async_hooks2, import_api, USER_ID_ATTRIBUTE, currentUserStorage, IdentitySpanProcessor;
|
|
2148
3625
|
var init_identity = __esm({
|
|
2149
3626
|
"src/tracing/identity.ts"() {
|
|
2150
3627
|
"use strict";
|
|
2151
|
-
|
|
3628
|
+
import_async_hooks2 = require("async_hooks");
|
|
2152
3629
|
import_api = require("@opentelemetry/api");
|
|
2153
3630
|
init_users();
|
|
2154
3631
|
USER_ID_ATTRIBUTE = "gateway.user.id";
|
|
2155
|
-
currentUserStorage = new
|
|
3632
|
+
currentUserStorage = new import_async_hooks2.AsyncLocalStorage();
|
|
2156
3633
|
IdentitySpanProcessor = class {
|
|
2157
3634
|
onStart(span, _parentContext) {
|
|
2158
3635
|
const userId = resolveUserId();
|
|
@@ -2170,43 +3647,224 @@ var init_identity = __esm({
|
|
|
2170
3647
|
}
|
|
2171
3648
|
});
|
|
2172
3649
|
|
|
2173
|
-
// src/tracing/
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
}
|
|
2181
|
-
|
|
2182
|
-
return
|
|
3650
|
+
// src/tracing/secrets.ts
|
|
3651
|
+
function jsonOrUndefined(text2) {
|
|
3652
|
+
let parsed;
|
|
3653
|
+
try {
|
|
3654
|
+
parsed = JSON.parse(text2);
|
|
3655
|
+
} catch {
|
|
3656
|
+
return void 0;
|
|
3657
|
+
}
|
|
3658
|
+
if (typeof parsed === "string") return parsed;
|
|
3659
|
+
return parsed !== null && typeof parsed === "object" ? parsed : void 0;
|
|
2183
3660
|
}
|
|
2184
|
-
function
|
|
2185
|
-
return
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
3661
|
+
function encodings(value) {
|
|
3662
|
+
return [value, percentEncoded(value), JSON.stringify(value).slice(1, -1)];
|
|
3663
|
+
}
|
|
3664
|
+
function percentEncoded(value) {
|
|
3665
|
+
try {
|
|
3666
|
+
return encodeURIComponent(value);
|
|
3667
|
+
} catch {
|
|
3668
|
+
return value;
|
|
3669
|
+
}
|
|
3670
|
+
}
|
|
3671
|
+
function union(sets) {
|
|
3672
|
+
return new Set(sets.flatMap((set) => [...set]));
|
|
3673
|
+
}
|
|
3674
|
+
function leaves(value) {
|
|
3675
|
+
if (typeof value === "string") {
|
|
3676
|
+
return [...value].length >= MIN_SECRET_LENGTH ? /* @__PURE__ */ new Set([value]) : /* @__PURE__ */ new Set();
|
|
3677
|
+
}
|
|
3678
|
+
if (Array.isArray(value)) return union(value.map(leaves));
|
|
3679
|
+
if (value === null || typeof value !== "object") return /* @__PURE__ */ new Set();
|
|
3680
|
+
return union(Object.values(value).map(leaves));
|
|
3681
|
+
}
|
|
3682
|
+
function sameAttributes(before, after) {
|
|
3683
|
+
const keys = Object.keys(before);
|
|
3684
|
+
if (keys.length !== Object.keys(after).length) return false;
|
|
3685
|
+
return keys.every(
|
|
3686
|
+
(key) => before[key] === after[key] || sameArray(before[key], after[key])
|
|
3687
|
+
);
|
|
3688
|
+
}
|
|
3689
|
+
function sameArray(before, after) {
|
|
3690
|
+
if (!Array.isArray(before) || !Array.isArray(after)) return false;
|
|
3691
|
+
return before.length === after.length && before.every((item, i) => item === after[i]);
|
|
3692
|
+
}
|
|
3693
|
+
function scrubbedRead(reads, property) {
|
|
3694
|
+
return typeof property === "string" && property in reads ? reads[property] : void 0;
|
|
3695
|
+
}
|
|
3696
|
+
function viewOf(span, reads) {
|
|
3697
|
+
const view = new Proxy(span, {
|
|
3698
|
+
get(target, property) {
|
|
3699
|
+
const read = scrubbedRead(reads, property);
|
|
3700
|
+
if (read) return read();
|
|
3701
|
+
const value = Reflect.get(target, property, target);
|
|
3702
|
+
if (typeof value !== "function") return value;
|
|
3703
|
+
return (...args) => {
|
|
3704
|
+
const result = value.apply(target, args);
|
|
3705
|
+
return result === target ? view : result;
|
|
3706
|
+
};
|
|
3707
|
+
},
|
|
3708
|
+
getOwnPropertyDescriptor(target, property) {
|
|
3709
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(target, property);
|
|
3710
|
+
const read = scrubbedRead(reads, property);
|
|
3711
|
+
if (!read || !descriptor || !("value" in descriptor)) return descriptor;
|
|
3712
|
+
return { ...descriptor, value: read() };
|
|
3713
|
+
}
|
|
2189
3714
|
});
|
|
3715
|
+
return view;
|
|
2190
3716
|
}
|
|
2191
|
-
var
|
|
2192
|
-
var
|
|
2193
|
-
"src/tracing/
|
|
3717
|
+
var SECRET_KEYS, REDACTED2, MIN_SECRET_LENGTH, SpanSecrets, SPAN_SECRETS, SecretRedactingSpanProcessor;
|
|
3718
|
+
var init_secrets = __esm({
|
|
3719
|
+
"src/tracing/secrets.ts"() {
|
|
2194
3720
|
"use strict";
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
3721
|
+
SECRET_KEYS = /* @__PURE__ */ new Set([
|
|
3722
|
+
"authorization_token",
|
|
3723
|
+
"authorizationToken"
|
|
3724
|
+
]);
|
|
3725
|
+
REDACTED2 = "[redacted: holds a credential]";
|
|
3726
|
+
MIN_SECRET_LENGTH = 8;
|
|
3727
|
+
SpanSecrets = class {
|
|
3728
|
+
constructor(keys = SECRET_KEYS) {
|
|
3729
|
+
this.keys = keys;
|
|
3730
|
+
}
|
|
3731
|
+
keys;
|
|
3732
|
+
isSecret(key) {
|
|
3733
|
+
return this.keys.has(key);
|
|
3734
|
+
}
|
|
3735
|
+
drops(attribute) {
|
|
3736
|
+
return this.mentions(attribute);
|
|
3737
|
+
}
|
|
3738
|
+
strip(value) {
|
|
3739
|
+
if (typeof value === "string") return this.stripNested(value);
|
|
3740
|
+
if (Array.isArray(value)) return value.map((item) => this.strip(item));
|
|
3741
|
+
if (value === null || typeof value !== "object") return value;
|
|
3742
|
+
return Object.fromEntries(
|
|
3743
|
+
Object.entries(value).filter(([key]) => !this.isSecret(key)).map(([key, item]) => [key, this.strip(item)])
|
|
3744
|
+
);
|
|
3745
|
+
}
|
|
3746
|
+
scrubAttribute(value) {
|
|
3747
|
+
try {
|
|
3748
|
+
return this.scrubbedValue(value);
|
|
3749
|
+
} catch {
|
|
3750
|
+
return Array.isArray(value) ? [REDACTED2] : REDACTED2;
|
|
2203
3751
|
}
|
|
2204
3752
|
}
|
|
2205
|
-
|
|
3753
|
+
scrubbedValue(value) {
|
|
3754
|
+
if (typeof value === "string") return this.scrubbedText(value);
|
|
3755
|
+
if (!Array.isArray(value)) return value;
|
|
3756
|
+
const results = value.map(
|
|
3757
|
+
(item) => typeof item === "string" ? this.cleaned(item) : { text: item, removed: /* @__PURE__ */ new Set() }
|
|
3758
|
+
);
|
|
3759
|
+
const removed = new Set(results.flatMap((r) => [...r.removed]));
|
|
3760
|
+
const scrubbed = results.map((r) => r.text);
|
|
3761
|
+
const withheld = scrubbed.some(
|
|
3762
|
+
(item) => typeof item === "string" && this.carries(item, removed)
|
|
3763
|
+
);
|
|
3764
|
+
return withheld ? [REDACTED2] : scrubbed;
|
|
2206
3765
|
}
|
|
2207
|
-
|
|
3766
|
+
scrubAttributes(attributes) {
|
|
3767
|
+
return Object.fromEntries(
|
|
3768
|
+
Object.entries(attributes).filter(([key]) => !this.drops(key)).map(([key, value]) => [key, this.scrubAttribute(value)])
|
|
3769
|
+
);
|
|
2208
3770
|
}
|
|
2209
|
-
|
|
3771
|
+
mentions(text2) {
|
|
3772
|
+
return [...this.keys].some((key) => text2.includes(key));
|
|
3773
|
+
}
|
|
3774
|
+
scrubbedText(text2) {
|
|
3775
|
+
const { text: cleaned, removed } = this.cleaned(text2);
|
|
3776
|
+
return this.carries(cleaned, removed) ? REDACTED2 : cleaned;
|
|
3777
|
+
}
|
|
3778
|
+
cleaned(text2) {
|
|
3779
|
+
if (!this.mentions(text2)) return { text: text2, removed: /* @__PURE__ */ new Set() };
|
|
3780
|
+
const parsed = jsonOrUndefined(text2);
|
|
3781
|
+
if (parsed === void 0) return { text: REDACTED2, removed: /* @__PURE__ */ new Set() };
|
|
3782
|
+
return {
|
|
3783
|
+
text: JSON.stringify(this.strip(parsed)),
|
|
3784
|
+
removed: this.removed(parsed)
|
|
3785
|
+
};
|
|
3786
|
+
}
|
|
3787
|
+
carries(text2, removed) {
|
|
3788
|
+
if (text2 === REDACTED2 || this.mentions(text2)) return true;
|
|
3789
|
+
return [...removed].some(
|
|
3790
|
+
(value) => encodings(value).some((form) => text2.includes(form))
|
|
3791
|
+
);
|
|
3792
|
+
}
|
|
3793
|
+
removed(value) {
|
|
3794
|
+
if (typeof value === "string") {
|
|
3795
|
+
const nested = this.mentions(value) ? jsonOrUndefined(value) : void 0;
|
|
3796
|
+
return nested === void 0 ? /* @__PURE__ */ new Set() : this.removed(nested);
|
|
3797
|
+
}
|
|
3798
|
+
if (Array.isArray(value)) return union(value.map((v) => this.removed(v)));
|
|
3799
|
+
if (value === null || typeof value !== "object") return /* @__PURE__ */ new Set();
|
|
3800
|
+
return union(
|
|
3801
|
+
Object.entries(value).map(
|
|
3802
|
+
([key, item]) => this.isSecret(key) ? leaves(item) : this.removed(item)
|
|
3803
|
+
)
|
|
3804
|
+
);
|
|
3805
|
+
}
|
|
3806
|
+
stripNested(text2) {
|
|
3807
|
+
if (!this.mentions(text2)) return text2;
|
|
3808
|
+
const parsed = jsonOrUndefined(text2);
|
|
3809
|
+
if (parsed === void 0) return text2;
|
|
3810
|
+
return JSON.stringify(this.strip(parsed));
|
|
3811
|
+
}
|
|
3812
|
+
};
|
|
3813
|
+
SPAN_SECRETS = new SpanSecrets();
|
|
3814
|
+
SecretRedactingSpanProcessor = class {
|
|
3815
|
+
constructor(inner, secrets = SPAN_SECRETS) {
|
|
3816
|
+
this.inner = inner;
|
|
3817
|
+
this.secrets = secrets;
|
|
3818
|
+
}
|
|
3819
|
+
inner;
|
|
3820
|
+
secrets;
|
|
3821
|
+
views = /* @__PURE__ */ new WeakMap();
|
|
3822
|
+
onStart(span, parentContext) {
|
|
3823
|
+
this.inner.onStart(this.viewFor(span), parentContext);
|
|
3824
|
+
}
|
|
3825
|
+
onEnd(span) {
|
|
3826
|
+
const view = this.viewFor(span);
|
|
3827
|
+
try {
|
|
3828
|
+
void [view.attributes, view.events, view.status];
|
|
3829
|
+
} catch (error) {
|
|
3830
|
+
console.warn(
|
|
3831
|
+
`[gatewaysdk.tracing] Dropped span "${span.name}": could not redact it: ${error?.name}`
|
|
3832
|
+
);
|
|
3833
|
+
return;
|
|
3834
|
+
}
|
|
3835
|
+
this.inner.onEnd(view);
|
|
3836
|
+
}
|
|
3837
|
+
viewFor(span) {
|
|
3838
|
+
const known = this.views.get(span);
|
|
3839
|
+
if (known) return known;
|
|
3840
|
+
const view = viewOf(span, {
|
|
3841
|
+
attributes: () => this.scrubbedAttributes(span.attributes),
|
|
3842
|
+
events: () => span.events.map((event) => this.scrubbedEvent(event)),
|
|
3843
|
+
status: () => this.scrubbedStatus(span.status)
|
|
3844
|
+
});
|
|
3845
|
+
this.views.set(span, view);
|
|
3846
|
+
return view;
|
|
3847
|
+
}
|
|
3848
|
+
forceFlush() {
|
|
3849
|
+
return this.inner.forceFlush();
|
|
3850
|
+
}
|
|
3851
|
+
shutdown() {
|
|
3852
|
+
return this.inner.shutdown();
|
|
3853
|
+
}
|
|
3854
|
+
scrubbedAttributes(attributes) {
|
|
3855
|
+
const clean = this.secrets.scrubAttributes(attributes);
|
|
3856
|
+
return sameAttributes(attributes, clean) ? attributes : clean;
|
|
3857
|
+
}
|
|
3858
|
+
scrubbedStatus(status) {
|
|
3859
|
+
if (!status.message) return status;
|
|
3860
|
+
const message = this.secrets.scrubAttribute(status.message);
|
|
3861
|
+
return message === status.message ? status : { ...status, message };
|
|
3862
|
+
}
|
|
3863
|
+
scrubbedEvent(event) {
|
|
3864
|
+
if (!event.attributes) return event;
|
|
3865
|
+
const attributes = this.scrubbedAttributes(event.attributes);
|
|
3866
|
+
if (attributes === event.attributes) return event;
|
|
3867
|
+
return { ...event, attributes };
|
|
2210
3868
|
}
|
|
2211
3869
|
};
|
|
2212
3870
|
}
|
|
@@ -2433,7 +4091,7 @@ var require_package = __commonJS({
|
|
|
2433
4091
|
"package.json"(exports2, module2) {
|
|
2434
4092
|
module2.exports = {
|
|
2435
4093
|
name: "@withgateway/sdk",
|
|
2436
|
-
version: "0.
|
|
4094
|
+
version: "0.3.0",
|
|
2437
4095
|
description: "Gateway SDK for TypeScript - A/B experiments, tracing, and observability",
|
|
2438
4096
|
main: "./dist/index.js",
|
|
2439
4097
|
module: "./dist/index.mjs",
|
|
@@ -2644,7 +4302,7 @@ function canonicalJson(value) {
|
|
|
2644
4302
|
return `{${entries.map(([k, v]) => `${JSON.stringify(k)}:${canonicalJson(v)}`).join(",")}}`;
|
|
2645
4303
|
}
|
|
2646
4304
|
function sha256(text2) {
|
|
2647
|
-
return `sha256:${(0,
|
|
4305
|
+
return `sha256:${(0, import_node_crypto3.createHash)("sha256").update(text2).digest("hex")}`;
|
|
2648
4306
|
}
|
|
2649
4307
|
function getRegisteredTools() {
|
|
2650
4308
|
return [...registeredTools.values()].sort(
|
|
@@ -2819,11 +4477,11 @@ async function registerBuild(params) {
|
|
|
2819
4477
|
);
|
|
2820
4478
|
}
|
|
2821
4479
|
}
|
|
2822
|
-
var
|
|
4480
|
+
var import_node_crypto3, registeredTools, registeredPrompts, registeredSkills, registeredArtifacts, activeBuilds;
|
|
2823
4481
|
var init_build = __esm({
|
|
2824
4482
|
"src/build/index.ts"() {
|
|
2825
4483
|
"use strict";
|
|
2826
|
-
|
|
4484
|
+
import_node_crypto3 = require("crypto");
|
|
2827
4485
|
registeredTools = /* @__PURE__ */ new Map();
|
|
2828
4486
|
registeredPrompts = /* @__PURE__ */ new Map();
|
|
2829
4487
|
registeredSkills = /* @__PURE__ */ new Map();
|
|
@@ -2953,7 +4611,7 @@ function buildProvider(config, logFn) {
|
|
|
2953
4611
|
const spanProcessors = [];
|
|
2954
4612
|
if (config.customSpanProcessors) {
|
|
2955
4613
|
for (const sp of config.customSpanProcessors) {
|
|
2956
|
-
spanProcessors.push(sp);
|
|
4614
|
+
spanProcessors.push(new SecretRedactingSpanProcessor(sp));
|
|
2957
4615
|
logFn(
|
|
2958
4616
|
"Added custom span processor: %s",
|
|
2959
4617
|
sp.constructor?.name ?? "unknown"
|
|
@@ -2972,7 +4630,11 @@ function buildProvider(config, logFn) {
|
|
|
2972
4630
|
if (config.batch?.maxExportBatchSize) {
|
|
2973
4631
|
batchConfig.maxExportBatchSize = config.batch.maxExportBatchSize;
|
|
2974
4632
|
}
|
|
2975
|
-
spanProcessors.push(
|
|
4633
|
+
spanProcessors.push(
|
|
4634
|
+
new SecretRedactingSpanProcessor(
|
|
4635
|
+
new BatchSpanProcessor(exporter, batchConfig)
|
|
4636
|
+
)
|
|
4637
|
+
);
|
|
2976
4638
|
let provider = new NodeTracerProvider({
|
|
2977
4639
|
resource: createResource(resourceAttrs)
|
|
2978
4640
|
});
|
|
@@ -3110,7 +4772,8 @@ var init_init = __esm({
|
|
|
3110
4772
|
"src/tracing/init.ts"() {
|
|
3111
4773
|
"use strict";
|
|
3112
4774
|
init_identity();
|
|
3113
|
-
|
|
4775
|
+
init_secrets();
|
|
4776
|
+
init_session();
|
|
3114
4777
|
init_scores();
|
|
3115
4778
|
init_build();
|
|
3116
4779
|
ENV_VARS = {
|
|
@@ -3225,7 +4888,7 @@ function reportFromResult(result) {
|
|
|
3225
4888
|
return { report, extra };
|
|
3226
4889
|
}
|
|
3227
4890
|
async function runTask(ref, agent, opts) {
|
|
3228
|
-
const runId = `wtr-${(0,
|
|
4891
|
+
const runId = `wtr-${(0, import_node_crypto4.randomBytes)(6).toString("hex")}`;
|
|
3229
4892
|
const outDir = opts.outDir ?? "runs";
|
|
3230
4893
|
const runDir = path.join(outDir, runId);
|
|
3231
4894
|
fs.mkdirSync(runDir, { recursive: true });
|
|
@@ -3263,7 +4926,7 @@ async function runTask(ref, agent, opts) {
|
|
|
3263
4926
|
let extra = {};
|
|
3264
4927
|
try {
|
|
3265
4928
|
const invoke = () => agent(taskRun);
|
|
3266
|
-
const result = traced ? await (await Promise.resolve().then(() => (
|
|
4929
|
+
const result = traced ? await (await Promise.resolve().then(() => (init_session(), session_exports))).withSession(runId, invoke) : await invoke();
|
|
3267
4930
|
({ report, extra } = reportFromResult(result));
|
|
3268
4931
|
} catch (error) {
|
|
3269
4932
|
const message = (error instanceof Error ? error.message : String(error)) || "Unknown error";
|
|
@@ -3330,16 +4993,16 @@ async function runTask(ref, agent, opts) {
|
|
|
3330
4993
|
}
|
|
3331
4994
|
}
|
|
3332
4995
|
}
|
|
3333
|
-
var
|
|
4996
|
+
var import_node_crypto4, fs, path, TaskRun, describeValue, RESULT_CONTRACT;
|
|
3334
4997
|
var init_taskRun = __esm({
|
|
3335
4998
|
"src/worlds/taskRun.ts"() {
|
|
3336
4999
|
"use strict";
|
|
3337
|
-
|
|
5000
|
+
import_node_crypto4 = require("crypto");
|
|
3338
5001
|
fs = __toESM(require("fs"));
|
|
3339
5002
|
path = __toESM(require("path"));
|
|
3340
5003
|
init_browser();
|
|
3341
5004
|
init_evals();
|
|
3342
|
-
|
|
5005
|
+
init_session2();
|
|
3343
5006
|
init_taskSessions();
|
|
3344
5007
|
TaskRun = class {
|
|
3345
5008
|
constructor(runId, instruction, model, sessions, manifest) {
|
|
@@ -3648,11 +5311,11 @@ var init_checkoutTarget = __esm({
|
|
|
3648
5311
|
});
|
|
3649
5312
|
|
|
3650
5313
|
// src/worlds/worldDir.ts
|
|
3651
|
-
var
|
|
5314
|
+
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;
|
|
3652
5315
|
var init_worldDir = __esm({
|
|
3653
5316
|
"src/worlds/worldDir.ts"() {
|
|
3654
5317
|
"use strict";
|
|
3655
|
-
|
|
5318
|
+
import_node_crypto5 = require("crypto");
|
|
3656
5319
|
fs3 = __toESM(require("fs"));
|
|
3657
5320
|
path3 = __toESM(require("path"));
|
|
3658
5321
|
WORLD_MANIFEST = "gateway-env.toml";
|
|
@@ -3758,7 +5421,7 @@ var init_worldDir = __esm({
|
|
|
3758
5421
|
* sorted order: the version's identity, byte-compatible with
|
|
3759
5422
|
* `_archive.compute_content_hash` and Prime Intellect. */
|
|
3760
5423
|
get contentHash() {
|
|
3761
|
-
const hasher = (0,
|
|
5424
|
+
const hasher = (0, import_node_crypto5.createHash)("sha256");
|
|
3762
5425
|
for (const rel of this.archivePaths) {
|
|
3763
5426
|
hasher.update(Buffer.from(`file:${rel}`, "utf-8"));
|
|
3764
5427
|
hasher.update(fs3.readFileSync(path3.join(this.dir, rel)));
|
|
@@ -4062,7 +5725,7 @@ function writeLocalMeta(dir, meta) {
|
|
|
4062
5725
|
function snapshotTreeHashes(dir) {
|
|
4063
5726
|
const out = {};
|
|
4064
5727
|
for (const relPath of collectArchiveRelPaths(dir)) {
|
|
4065
|
-
out[relPath] = (0,
|
|
5728
|
+
out[relPath] = (0, import_node_crypto6.createHash)("sha256").update(fs5.readFileSync(path5.join(dir, relPath))).digest("hex");
|
|
4066
5729
|
}
|
|
4067
5730
|
return out;
|
|
4068
5731
|
}
|
|
@@ -4108,7 +5771,7 @@ function buildFileManifest(dir) {
|
|
|
4108
5771
|
path: relPath,
|
|
4109
5772
|
isDirectory: false,
|
|
4110
5773
|
size: payload.length,
|
|
4111
|
-
sha256: (0,
|
|
5774
|
+
sha256: (0, import_node_crypto6.createHash)("sha256").update(payload).digest("hex")
|
|
4112
5775
|
};
|
|
4113
5776
|
});
|
|
4114
5777
|
}
|
|
@@ -4307,11 +5970,11 @@ async function createRef(slug, name, kind, versionId, options = {}) {
|
|
|
4307
5970
|
...versionId ? { versionId } : {}
|
|
4308
5971
|
});
|
|
4309
5972
|
}
|
|
4310
|
-
var
|
|
5973
|
+
var import_node_crypto6, import_node_zlib2, fs5, path5, DEFAULT_BRANCH, META_RELPATH, FILE_MODE, MINTED_SUFFIX, PushSlugConflict, sha256b64, DetachedPushError;
|
|
4311
5974
|
var init_hub = __esm({
|
|
4312
5975
|
"src/worlds/hub.ts"() {
|
|
4313
5976
|
"use strict";
|
|
4314
|
-
|
|
5977
|
+
import_node_crypto6 = require("crypto");
|
|
4315
5978
|
import_node_zlib2 = require("zlib");
|
|
4316
5979
|
fs5 = __toESM(require("fs"));
|
|
4317
5980
|
path5 = __toESM(require("path"));
|
|
@@ -4337,7 +6000,7 @@ var init_hub = __esm({
|
|
|
4337
6000
|
tracked;
|
|
4338
6001
|
declared;
|
|
4339
6002
|
};
|
|
4340
|
-
sha256b64 = (data) => (0,
|
|
6003
|
+
sha256b64 = (data) => (0, import_node_crypto6.createHash)("sha256").update(data).digest("base64");
|
|
4341
6004
|
DetachedPushError = class extends Error {
|
|
4342
6005
|
constructor(dir, tag) {
|
|
4343
6006
|
super(
|
|
@@ -4538,6 +6201,34 @@ function parseSlugRef(slugRef) {
|
|
|
4538
6201
|
if (at === -1) return { slug: slugRef };
|
|
4539
6202
|
return { slug: slugRef.slice(0, at), ref: slugRef.slice(at + 1) };
|
|
4540
6203
|
}
|
|
6204
|
+
function rebaseConflicts(error) {
|
|
6205
|
+
if (!(error instanceof ApiError) || error.status !== 409) return null;
|
|
6206
|
+
let body;
|
|
6207
|
+
try {
|
|
6208
|
+
body = JSON.parse(error.text);
|
|
6209
|
+
} catch {
|
|
6210
|
+
return null;
|
|
6211
|
+
}
|
|
6212
|
+
const conflicts = body?.conflicts;
|
|
6213
|
+
if (!Array.isArray(conflicts)) return null;
|
|
6214
|
+
return conflicts.filter(isConflictPath).map(({ path: path12, reason }) => ({ path: path12, reason }));
|
|
6215
|
+
}
|
|
6216
|
+
function isConflictPath(value) {
|
|
6217
|
+
const entry = value;
|
|
6218
|
+
return typeof entry?.path === "string" && typeof entry.reason === "string";
|
|
6219
|
+
}
|
|
6220
|
+
function uncommittedPaths(error) {
|
|
6221
|
+
if (!(error instanceof ApiError) || error.status !== 409 || error.code !== "sandbox_uncommitted") return null;
|
|
6222
|
+
let body;
|
|
6223
|
+
try {
|
|
6224
|
+
body = JSON.parse(error.text);
|
|
6225
|
+
} catch {
|
|
6226
|
+
return null;
|
|
6227
|
+
}
|
|
6228
|
+
const uncommitted = body?.uncommitted;
|
|
6229
|
+
if (!Array.isArray(uncommitted)) return null;
|
|
6230
|
+
return uncommitted.filter((p) => typeof p === "string");
|
|
6231
|
+
}
|
|
4541
6232
|
function listQuery(filter) {
|
|
4542
6233
|
const params = new URLSearchParams();
|
|
4543
6234
|
if (filter.status) params.set("status", filter.status);
|
|
@@ -4546,18 +6237,25 @@ function listQuery(filter) {
|
|
|
4546
6237
|
const qs = params.toString();
|
|
4547
6238
|
return qs ? `?${qs}` : "";
|
|
4548
6239
|
}
|
|
4549
|
-
var isSandboxImportPending, sid, WorldSandboxClient;
|
|
6240
|
+
var isSandboxImportPending, sid, SANDBOXES, SANDBOX_REQUEST_TIMEOUT_MS, WorldSandboxClient;
|
|
4550
6241
|
var init_sandbox = __esm({
|
|
4551
6242
|
"src/worlds/sandbox.ts"() {
|
|
4552
6243
|
"use strict";
|
|
4553
6244
|
init_worlds();
|
|
4554
6245
|
isSandboxImportPending = (answer) => !("versionId" in answer);
|
|
4555
6246
|
sid = encodeURIComponent;
|
|
6247
|
+
SANDBOXES = "/api/public/benchmark-containers/sandboxes";
|
|
6248
|
+
SANDBOX_REQUEST_TIMEOUT_MS = 66e4;
|
|
4556
6249
|
WorldSandboxClient = class {
|
|
4557
6250
|
constructor(options = {}) {
|
|
4558
6251
|
this.options = options;
|
|
4559
6252
|
}
|
|
4560
6253
|
options;
|
|
6254
|
+
request(method, path12, body) {
|
|
6255
|
+
return apiRequest(this.options, method, path12, body, {
|
|
6256
|
+
timeoutMs: SANDBOX_REQUEST_TIMEOUT_MS
|
|
6257
|
+
});
|
|
6258
|
+
}
|
|
4561
6259
|
/**
|
|
4562
6260
|
* `{ slug, ref? }` opens a READY version; `{ new, from }` opens a sandbox on
|
|
4563
6261
|
* a world that does not exist yet (409 `world_exists` if the slug is taken,
|
|
@@ -4565,42 +6263,39 @@ var init_sandbox = __esm({
|
|
|
4565
6263
|
* creates the world on `main`.
|
|
4566
6264
|
*/
|
|
4567
6265
|
open(target) {
|
|
4568
|
-
return
|
|
6266
|
+
return this.request("POST", `${SANDBOXES}`, target);
|
|
4569
6267
|
}
|
|
4570
6268
|
status(sandboxId) {
|
|
4571
|
-
return
|
|
6269
|
+
return this.request("GET", `${SANDBOXES}/${sid(sandboxId)}`);
|
|
4572
6270
|
}
|
|
4573
6271
|
/** The project's sandboxes, newest first — how an agent finds one it left open. */
|
|
4574
6272
|
async list(filter = {}) {
|
|
4575
|
-
const res = await
|
|
4576
|
-
this.options,
|
|
4577
|
-
"GET",
|
|
4578
|
-
`/api/public/benchmark-containers/sandboxes${listQuery(filter)}`
|
|
4579
|
-
);
|
|
6273
|
+
const res = await this.request("GET", `${SANDBOXES}${listQuery(filter)}`);
|
|
4580
6274
|
return res.sandboxes;
|
|
4581
6275
|
}
|
|
4582
6276
|
async read(sandboxId, filePath) {
|
|
4583
|
-
const res = await
|
|
4584
|
-
this.options,
|
|
6277
|
+
const res = await this.request(
|
|
4585
6278
|
"GET",
|
|
4586
|
-
|
|
6279
|
+
`${SANDBOXES}/${sid(sandboxId)}/file?path=${encodeURIComponent(filePath)}`
|
|
4587
6280
|
);
|
|
4588
6281
|
return { path: res.path, size: res.size, bytes: Buffer.from(res.contentBase64, "base64") };
|
|
4589
6282
|
}
|
|
4590
6283
|
write(sandboxId, filePath, bytes) {
|
|
4591
|
-
return
|
|
6284
|
+
return this.request("PUT", `${SANDBOXES}/${sid(sandboxId)}/file`, {
|
|
4592
6285
|
path: filePath,
|
|
4593
6286
|
contentBase64: bytes.toString("base64")
|
|
4594
6287
|
});
|
|
4595
6288
|
}
|
|
4596
6289
|
exec(sandboxId, input) {
|
|
4597
|
-
return
|
|
6290
|
+
return this.request("POST", `${SANDBOXES}/${sid(sandboxId)}/exec`, input);
|
|
4598
6291
|
}
|
|
4599
6292
|
check(sandboxId) {
|
|
4600
|
-
return
|
|
6293
|
+
return this.request("POST", `${SANDBOXES}/${sid(sandboxId)}/check`, {});
|
|
4601
6294
|
}
|
|
6295
|
+
/** With `rebase`, a moved base is replayed onto; a 409 then names the conflicting paths (`rebaseConflicts`). */
|
|
4602
6296
|
commit(sandboxId, input) {
|
|
4603
|
-
|
|
6297
|
+
const { rebase, ...rest } = input;
|
|
6298
|
+
return this.request("POST", `${SANDBOXES}/${sid(sandboxId)}/commit`, rebase ? { ...rest, rebase: true } : rest);
|
|
4604
6299
|
}
|
|
4605
6300
|
/**
|
|
4606
6301
|
* A rows file already in the sandbox tree into the PLATFORM world the
|
|
@@ -4609,10 +6304,11 @@ var init_sandbox = __esm({
|
|
|
4609
6304
|
* tree and never carries data.
|
|
4610
6305
|
*/
|
|
4611
6306
|
importData(sandboxId, input) {
|
|
4612
|
-
return
|
|
6307
|
+
return this.request("POST", `${SANDBOXES}/${sid(sandboxId)}/import`, input);
|
|
4613
6308
|
}
|
|
4614
|
-
|
|
4615
|
-
|
|
6309
|
+
/** Uncommitted work is a 409 (`uncommittedPaths`) unless `force` discards it. */
|
|
6310
|
+
close(sandboxId, opts = {}) {
|
|
6311
|
+
return this.request("DELETE", `${SANDBOXES}/${sid(sandboxId)}`, opts.force ? { force: true } : void 0);
|
|
4616
6312
|
}
|
|
4617
6313
|
};
|
|
4618
6314
|
}
|
|
@@ -4948,11 +6644,11 @@ function applyTransforms(value, chain) {
|
|
|
4948
6644
|
for (const step of steps) out = step(out);
|
|
4949
6645
|
return out;
|
|
4950
6646
|
}
|
|
4951
|
-
var
|
|
6647
|
+
var import_node_crypto7, WHITESPACE, WHITESPACE_EDGES, WHITESPACE_RUN, NOT_DIGIT, STRIP_PREFIX, trim, emailLocalPart, emailDomain, stripPrefix, hex, SIMPLE, TRANSFORMS, text;
|
|
4952
6648
|
var init_transforms = __esm({
|
|
4953
6649
|
"src/worlds/transforms.ts"() {
|
|
4954
6650
|
"use strict";
|
|
4955
|
-
|
|
6651
|
+
import_node_crypto7 = require("crypto");
|
|
4956
6652
|
init_json();
|
|
4957
6653
|
WHITESPACE = " \n\r\f\v";
|
|
4958
6654
|
WHITESPACE_EDGES = new RegExp(`^[${WHITESPACE}]+|[${WHITESPACE}]+$`, "g");
|
|
@@ -4969,7 +6665,7 @@ var init_transforms = __esm({
|
|
|
4969
6665
|
return at === -1 ? "" : value.slice(at + 1).toLowerCase();
|
|
4970
6666
|
};
|
|
4971
6667
|
stripPrefix = (prefix) => (value) => value.startsWith(prefix) ? value.slice(prefix.length) : value;
|
|
4972
|
-
hex = (algorithm, value) => (0,
|
|
6668
|
+
hex = (algorithm, value) => (0, import_node_crypto7.createHash)(algorithm).update(value, "utf8").digest("hex");
|
|
4973
6669
|
SIMPLE = {
|
|
4974
6670
|
lower: (value) => value.toLowerCase(),
|
|
4975
6671
|
upper: (value) => value.toUpperCase(),
|
|
@@ -5001,7 +6697,7 @@ function pyText(value) {
|
|
|
5001
6697
|
return pyFloatRepr(value);
|
|
5002
6698
|
}
|
|
5003
6699
|
function hashForm(slug, plaintext) {
|
|
5004
|
-
return "sha256:" + (0,
|
|
6700
|
+
return "sha256:" + (0, import_node_crypto8.createHash)("sha256").update(`${slug}:${pyText(plaintext)}`, "utf8").digest("hex");
|
|
5005
6701
|
}
|
|
5006
6702
|
function preserveForm(slug, plaintext) {
|
|
5007
6703
|
const kind = typeof plaintext === "string" ? "str" : isInt(plaintext) ? "int" : "float";
|
|
@@ -5010,12 +6706,12 @@ function preserveForm(slug, plaintext) {
|
|
|
5010
6706
|
}
|
|
5011
6707
|
function shapeText(slug, text2, kind) {
|
|
5012
6708
|
const seed = Buffer.from(`${slug}:${text2}`, "utf8");
|
|
5013
|
-
let digest = (0,
|
|
6709
|
+
let digest = (0, import_node_crypto8.createHash)("sha256").update(seed).digest();
|
|
5014
6710
|
let cursor = 0;
|
|
5015
6711
|
const out = [];
|
|
5016
6712
|
for (const char of text2) {
|
|
5017
6713
|
if (cursor === digest.length) {
|
|
5018
|
-
digest = (0,
|
|
6714
|
+
digest = (0, import_node_crypto8.createHash)("sha256").update(Buffer.concat([digest, seed])).digest();
|
|
5019
6715
|
cursor = 0;
|
|
5020
6716
|
}
|
|
5021
6717
|
const byte = digest[cursor];
|
|
@@ -5052,11 +6748,11 @@ function storedForms(world, field2, plaintext, transform) {
|
|
|
5052
6748
|
if (policy !== null) return [roundForm(plaintext, world.redact.round[field2])];
|
|
5053
6749
|
return [plaintext];
|
|
5054
6750
|
}
|
|
5055
|
-
var
|
|
6751
|
+
var import_node_crypto8, isInt;
|
|
5056
6752
|
var init_redaction = __esm({
|
|
5057
6753
|
"src/worlds/redaction.ts"() {
|
|
5058
6754
|
"use strict";
|
|
5059
|
-
|
|
6755
|
+
import_node_crypto8 = require("crypto");
|
|
5060
6756
|
init_json();
|
|
5061
6757
|
init_transforms();
|
|
5062
6758
|
isInt = (value) => typeof value === "number" && Number.isInteger(value);
|
|
@@ -5141,42 +6837,12 @@ var init_router = __esm({
|
|
|
5141
6837
|
});
|
|
5142
6838
|
|
|
5143
6839
|
// src/cli/config.ts
|
|
5144
|
-
function transportDetail(error, timeoutMs) {
|
|
5145
|
-
if (error instanceof Error && error.name === "AbortError") return `timed out after ${Math.round(timeoutMs / 1e3)}s`;
|
|
5146
|
-
const cause = error instanceof Error && error.cause instanceof Error ? error.cause : void 0;
|
|
5147
|
-
const code = cause && "code" in cause && typeof cause.code === "string" ? `${cause.code}: ` : "";
|
|
5148
|
-
const message = cause?.message ?? (error instanceof Error ? error.message : String(error));
|
|
5149
|
-
return `${code}${message}`;
|
|
5150
|
-
}
|
|
5151
6840
|
async function api(creds, method, route, body, init2 = {}) {
|
|
5152
|
-
const
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
let res;
|
|
5156
|
-
try {
|
|
5157
|
-
res = await fetch(`${creds.host}${route}`, {
|
|
5158
|
-
method,
|
|
5159
|
-
headers: {
|
|
5160
|
-
"content-type": "application/json",
|
|
5161
|
-
accept: "application/json",
|
|
5162
|
-
authorization: "Basic " + Buffer.from(`${creds.publicKey}:${creds.secretKey}`).toString("base64")
|
|
5163
|
-
},
|
|
5164
|
-
...body === void 0 ? {} : { body: JSON.stringify(body) },
|
|
5165
|
-
signal: controller.signal
|
|
5166
|
-
});
|
|
5167
|
-
} catch (error) {
|
|
5168
|
-
clearTimeout(timer);
|
|
5169
|
-
throw new UnreachableError(creds.host, method, route, transportDetail(error, timeoutMs));
|
|
5170
|
-
}
|
|
5171
|
-
try {
|
|
5172
|
-
const text2 = await res.text();
|
|
5173
|
-
if (!res.ok) throw new ApiError(res.status, method, route, text2);
|
|
5174
|
-
return text2 ? JSON.parse(text2) : {};
|
|
5175
|
-
} finally {
|
|
5176
|
-
clearTimeout(timer);
|
|
5177
|
-
}
|
|
6841
|
+
const reply = await new PlatformTransport(creds).send(method, route, body, init2);
|
|
6842
|
+
if (!reply.ok) throw new ApiError2(reply.status, method, route, reply.text);
|
|
6843
|
+
return reply.text ? JSON.parse(reply.text) : {};
|
|
5178
6844
|
}
|
|
5179
|
-
var fs6, os, path6,
|
|
6845
|
+
var fs6, os, path6, ApiError2;
|
|
5180
6846
|
var init_config = __esm({
|
|
5181
6847
|
"src/cli/config.ts"() {
|
|
5182
6848
|
"use strict";
|
|
@@ -5185,7 +6851,8 @@ var init_config = __esm({
|
|
|
5185
6851
|
path6 = __toESM(require("path"));
|
|
5186
6852
|
init_router();
|
|
5187
6853
|
init_worlds();
|
|
5188
|
-
|
|
6854
|
+
init_transport();
|
|
6855
|
+
ApiError2 = class extends CliError {
|
|
5189
6856
|
constructor(status, method, route, text2) {
|
|
5190
6857
|
const body = parseErrorBody(text2);
|
|
5191
6858
|
super(`${method} ${route} -> ${status}: ${body.detail}`, 1);
|
|
@@ -5201,19 +6868,6 @@ var init_config = __esm({
|
|
|
5201
6868
|
text;
|
|
5202
6869
|
code;
|
|
5203
6870
|
};
|
|
5204
|
-
UnreachableError = class extends CliError {
|
|
5205
|
-
constructor(host, method, route, detail) {
|
|
5206
|
-
super(`${method} ${route}: no answer from ${host} (${detail}). Check the host and the network, then retry.`, 1);
|
|
5207
|
-
this.host = host;
|
|
5208
|
-
this.method = method;
|
|
5209
|
-
this.route = route;
|
|
5210
|
-
this.detail = detail;
|
|
5211
|
-
}
|
|
5212
|
-
host;
|
|
5213
|
-
method;
|
|
5214
|
-
route;
|
|
5215
|
-
detail;
|
|
5216
|
-
};
|
|
5217
6871
|
}
|
|
5218
6872
|
});
|
|
5219
6873
|
|
|
@@ -5392,7 +7046,7 @@ var init_local = __esm({
|
|
|
5392
7046
|
path7 = __toESM(require("path"));
|
|
5393
7047
|
init_router();
|
|
5394
7048
|
init_config();
|
|
5395
|
-
MIN_PYTHON = [3,
|
|
7049
|
+
MIN_PYTHON = [3, 12];
|
|
5396
7050
|
DIAGNOSTIC_TAIL = 600;
|
|
5397
7051
|
BRIDGE_BOOTSTRAP = `import sys,runpy,types,os
|
|
5398
7052
|
root=sys.argv[1]
|
|
@@ -5404,7 +7058,6 @@ runpy.run_module('gatewaysdk.environment.schema.platform',run_name='__main__')`;
|
|
|
5404
7058
|
PYTHON_CANDIDATES = [
|
|
5405
7059
|
"python3.13",
|
|
5406
7060
|
"python3.12",
|
|
5407
|
-
"python3.11",
|
|
5408
7061
|
"python3",
|
|
5409
7062
|
"python"
|
|
5410
7063
|
];
|
|
@@ -5514,47 +7167,33 @@ function runsLocally(request) {
|
|
|
5514
7167
|
async function runtime(creds, request, opts = {}) {
|
|
5515
7168
|
const local = localRuntime();
|
|
5516
7169
|
if (local && runsLocally(request)) {
|
|
5517
|
-
const
|
|
5518
|
-
const
|
|
5519
|
-
if (
|
|
5520
|
-
return
|
|
7170
|
+
const payload2 = await localBridge(request, local, opts);
|
|
7171
|
+
const detail2 = detailFrom(payload2);
|
|
7172
|
+
if (detail2) throw new BridgeRejected(detail2);
|
|
7173
|
+
return payload2;
|
|
5521
7174
|
}
|
|
5522
7175
|
if (!creds)
|
|
5523
7176
|
throw new CliError(
|
|
5524
7177
|
"This needs the schema runtime (the CLI bundles it) or platform credentials (`gateway auth login`). " + localRuntimeReason()
|
|
5525
7178
|
);
|
|
5526
|
-
const controller = new AbortController();
|
|
5527
|
-
const timer = setTimeout(() => controller.abort(), opts.timeoutMs ?? 18e4);
|
|
5528
7179
|
const route = "/api/public/worlds/runtime";
|
|
7180
|
+
const res = await new PlatformTransport(creds).send("POST", route, request, {
|
|
7181
|
+
timeoutMs: opts.timeoutMs ?? RUNTIME_TIMEOUT_MS
|
|
7182
|
+
});
|
|
7183
|
+
let payload = null;
|
|
5529
7184
|
try {
|
|
5530
|
-
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
"content-type": "application/json",
|
|
5534
|
-
accept: "application/json",
|
|
5535
|
-
authorization: "Basic " + Buffer.from(`${creds.publicKey}:${creds.secretKey}`).toString("base64")
|
|
5536
|
-
},
|
|
5537
|
-
body: JSON.stringify(request),
|
|
5538
|
-
signal: controller.signal
|
|
5539
|
-
});
|
|
5540
|
-
const text2 = await res.text();
|
|
5541
|
-
let payload = null;
|
|
5542
|
-
try {
|
|
5543
|
-
payload = text2 ? JSON.parse(text2) : {};
|
|
5544
|
-
} catch {
|
|
5545
|
-
payload = null;
|
|
5546
|
-
}
|
|
5547
|
-
const detail = detailFrom(payload);
|
|
5548
|
-
if (detail) throw new BridgeRejected(detail);
|
|
5549
|
-
if (!res.ok)
|
|
5550
|
-
throw new CliError(`POST ${route} (${request.command}) -> ${res.status}: ${text2.slice(0, 600)}`, 1);
|
|
5551
|
-
if (payload === null) throw new CliError(`POST ${route} (${request.command}) returned non-JSON`, 1);
|
|
5552
|
-
return payload;
|
|
5553
|
-
} finally {
|
|
5554
|
-
clearTimeout(timer);
|
|
7185
|
+
payload = res.text ? JSON.parse(res.text) : {};
|
|
7186
|
+
} catch {
|
|
7187
|
+
payload = null;
|
|
5555
7188
|
}
|
|
7189
|
+
const detail = detailFrom(payload);
|
|
7190
|
+
if (detail) throw new BridgeRejected(detail);
|
|
7191
|
+
if (!res.ok)
|
|
7192
|
+
throw new CliError(`POST ${route} (${request.command}) -> ${res.status}: ${res.text.slice(0, 600)}`, 1);
|
|
7193
|
+
if (payload === null) throw new CliError(`POST ${route} (${request.command}) returned non-JSON`, 1);
|
|
7194
|
+
return payload;
|
|
5556
7195
|
}
|
|
5557
|
-
var fs8, path8, MAX_WORLD_FILES, SKIP_DIRS, BUILD_OUTPUT, BridgeRejected, YAML_NAME;
|
|
7196
|
+
var fs8, path8, MAX_WORLD_FILES, RUNTIME_TIMEOUT_MS, SKIP_DIRS, BUILD_OUTPUT, BridgeRejected, YAML_NAME;
|
|
5558
7197
|
var init_client = __esm({
|
|
5559
7198
|
"src/cli/runtime/client.ts"() {
|
|
5560
7199
|
"use strict";
|
|
@@ -5562,7 +7201,9 @@ var init_client = __esm({
|
|
|
5562
7201
|
path8 = __toESM(require("path"));
|
|
5563
7202
|
init_router();
|
|
5564
7203
|
init_local();
|
|
7204
|
+
init_transport();
|
|
5565
7205
|
MAX_WORLD_FILES = 2e3;
|
|
7206
|
+
RUNTIME_TIMEOUT_MS = 18e4;
|
|
5566
7207
|
SKIP_DIRS = /* @__PURE__ */ new Set(["__pycache__", ".git", "node_modules", ".gateway"]);
|
|
5567
7208
|
BUILD_OUTPUT = /(^|\/)state\.(sqlite|json)$/;
|
|
5568
7209
|
BridgeRejected = class extends CliError {
|
|
@@ -5980,7 +7621,7 @@ function uploadHeadersFor(gz) {
|
|
|
5980
7621
|
return {
|
|
5981
7622
|
"content-type": "application/gzip",
|
|
5982
7623
|
"content-length": String(gz.length),
|
|
5983
|
-
"x-amz-checksum-sha256": (0,
|
|
7624
|
+
"x-amz-checksum-sha256": (0, import_node_crypto9.createHash)("sha256").update(gz).digest("base64")
|
|
5984
7625
|
};
|
|
5985
7626
|
}
|
|
5986
7627
|
async function forEachLimited(items, limit, fn) {
|
|
@@ -6026,11 +7667,11 @@ function phaseLine(status) {
|
|
|
6026
7667
|
const phase = status.progress?.phase;
|
|
6027
7668
|
return phase ? `${status.state} (${phase})` : status.state;
|
|
6028
7669
|
}
|
|
6029
|
-
var
|
|
7670
|
+
var import_node_crypto9, fs11, TERMINAL_STATES, sleepMs, WorldDataApi;
|
|
6030
7671
|
var init_batches = __esm({
|
|
6031
7672
|
"src/cli/platform/worldData/batches.ts"() {
|
|
6032
7673
|
"use strict";
|
|
6033
|
-
|
|
7674
|
+
import_node_crypto9 = require("crypto");
|
|
6034
7675
|
fs11 = __toESM(require("fs"));
|
|
6035
7676
|
init_config();
|
|
6036
7677
|
init_router();
|
|
@@ -6224,12 +7865,12 @@ function finishChunk(ordinal, raw, rows, entity, firstRow = 0) {
|
|
|
6224
7865
|
const gz = gzipDeterministic(raw, { name: chunkName(ordinal) });
|
|
6225
7866
|
return {
|
|
6226
7867
|
ordinal,
|
|
6227
|
-
digest: (0,
|
|
7868
|
+
digest: (0, import_node_crypto10.createHash)("sha256").update(gz).digest("hex"),
|
|
6228
7869
|
bytes: gz.length,
|
|
6229
7870
|
rows,
|
|
6230
7871
|
entity,
|
|
6231
7872
|
rawBytes: raw.length,
|
|
6232
|
-
contentSha256: (0,
|
|
7873
|
+
contentSha256: (0, import_node_crypto10.createHash)("sha256").update(raw).digest("hex"),
|
|
6233
7874
|
firstRow,
|
|
6234
7875
|
gz
|
|
6235
7876
|
};
|
|
@@ -6269,11 +7910,11 @@ function crc32(data) {
|
|
|
6269
7910
|
crc = table[(crc ^ data[i]) & 255] ^ crc >>> 8;
|
|
6270
7911
|
return (crc ^ 4294967295) >>> 0;
|
|
6271
7912
|
}
|
|
6272
|
-
var
|
|
7913
|
+
var import_node_crypto10, import_node_zlib3, DEFAULT_CHUNK_BYTES, GZIP_LEVEL, chunkName, table;
|
|
6273
7914
|
var init_chunker = __esm({
|
|
6274
7915
|
"src/cli/platform/worldData/chunker.ts"() {
|
|
6275
7916
|
"use strict";
|
|
6276
|
-
|
|
7917
|
+
import_node_crypto10 = require("crypto");
|
|
6277
7918
|
import_node_zlib3 = require("zlib");
|
|
6278
7919
|
init_json();
|
|
6279
7920
|
DEFAULT_CHUNK_BYTES = 64 * 1024 * 1024;
|
|
@@ -6568,7 +8209,7 @@ var init_ingest = __esm({
|
|
|
6568
8209
|
});
|
|
6569
8210
|
|
|
6570
8211
|
// src/worlds/editSessions.ts
|
|
6571
|
-
var WORLDS, WorldEditClient;
|
|
8212
|
+
var WORLDS, WorldEditClient, TASK_EDITS, TaskEditClient;
|
|
6572
8213
|
var init_editSessions = __esm({
|
|
6573
8214
|
"src/worlds/editSessions.ts"() {
|
|
6574
8215
|
"use strict";
|
|
@@ -6600,6 +8241,22 @@ var init_editSessions = __esm({
|
|
|
6600
8241
|
return apiRequest(this.options, "POST", `${WORLDS}/${encodeURIComponent(slug)}/edits/rollback`, input);
|
|
6601
8242
|
}
|
|
6602
8243
|
};
|
|
8244
|
+
TASK_EDITS = "/api/public/world-task-edits";
|
|
8245
|
+
TaskEditClient = class {
|
|
8246
|
+
constructor(options = {}) {
|
|
8247
|
+
this.options = options;
|
|
8248
|
+
}
|
|
8249
|
+
options;
|
|
8250
|
+
status(task) {
|
|
8251
|
+
return apiRequest(this.options, "POST", `${TASK_EDITS}/status`, { task });
|
|
8252
|
+
}
|
|
8253
|
+
close(task, input = {}) {
|
|
8254
|
+
return apiRequest(this.options, "POST", `${TASK_EDITS}/close`, { task, ...input });
|
|
8255
|
+
}
|
|
8256
|
+
rollback(task, input) {
|
|
8257
|
+
return apiRequest(this.options, "POST", `${TASK_EDITS}/rollback`, { task, ...input });
|
|
8258
|
+
}
|
|
8259
|
+
};
|
|
6603
8260
|
}
|
|
6604
8261
|
});
|
|
6605
8262
|
|
|
@@ -6695,7 +8352,11 @@ var init_dryRun = __esm({
|
|
|
6695
8352
|
// src/worlds/index.ts
|
|
6696
8353
|
var worlds_exports = {};
|
|
6697
8354
|
__export(worlds_exports, {
|
|
6698
|
-
|
|
8355
|
+
ACTION_NAMES: () => ACTION_NAMES,
|
|
8356
|
+
ActionTracer: () => ActionTracer,
|
|
8357
|
+
AnthropicComputer: () => AnthropicComputer,
|
|
8358
|
+
AnthropicComputer20251124: () => AnthropicComputer20251124,
|
|
8359
|
+
ApiError: () => ApiError,
|
|
6699
8360
|
BROWSER_GONE_PATTERNS: () => BROWSER_GONE_PATTERNS,
|
|
6700
8361
|
BROWSER_TIERS: () => BROWSER_TIERS,
|
|
6701
8362
|
BrowserActionRecorder: () => BrowserActionRecorder,
|
|
@@ -6706,11 +8367,13 @@ __export(worlds_exports, {
|
|
|
6706
8367
|
CALL_BODY_LIMIT_LABEL: () => CALL_BODY_LIMIT_LABEL,
|
|
6707
8368
|
COMPUTER_USE_SPECS: () => COMPUTER_USE_SPECS,
|
|
6708
8369
|
CheckoutProvenance: () => CheckoutProvenance,
|
|
8370
|
+
ComputerAction: () => ComputerAction,
|
|
6709
8371
|
DEFAULT_BRANCH: () => DEFAULT_BRANCH,
|
|
6710
8372
|
DEFAULT_VIEWPORT: () => DEFAULT_VIEWPORT,
|
|
6711
8373
|
DRY_RUN_AGENT: () => DRY_RUN_AGENT,
|
|
6712
8374
|
DRY_RUN_KIND: () => DRY_RUN_KIND,
|
|
6713
8375
|
DetachedPushError: () => DetachedPushError,
|
|
8376
|
+
Display: () => Display,
|
|
6714
8377
|
DryRunOutcome: () => DryRunOutcome,
|
|
6715
8378
|
EVENT_BATCH_SIZE: () => EVENT_BATCH_SIZE,
|
|
6716
8379
|
EVENT_FLUSH_INTERVAL_MS: () => EVENT_FLUSH_INTERVAL_MS,
|
|
@@ -6720,17 +8383,34 @@ __export(worlds_exports, {
|
|
|
6720
8383
|
GatewayEvalsClient: () => GatewayEvalsClient,
|
|
6721
8384
|
HostedDryRunClient: () => HostedDryRunClient,
|
|
6722
8385
|
IDLE_WARNING_MINUTES: () => IDLE_WARNING_MINUTES,
|
|
8386
|
+
KEY_NAMES: () => KEY_NAMES,
|
|
8387
|
+
KeyChord: () => KeyChord,
|
|
8388
|
+
NOT_EXECUTED: () => NOT_EXECUTED,
|
|
6723
8389
|
NO_GRADER_REASON: () => NO_GRADER_REASON,
|
|
8390
|
+
NativeComputer: () => NativeComputer,
|
|
8391
|
+
OpenAIComputer: () => OpenAIComputer,
|
|
8392
|
+
OpenAIPreviewComputer: () => OpenAIPreviewComputer,
|
|
8393
|
+
PLATFORM_TIMEOUT_DEFAULT_MS: () => PLATFORM_TIMEOUT_DEFAULT_MS,
|
|
8394
|
+
PLATFORM_TIMEOUT_ENV: () => PLATFORM_TIMEOUT_ENV,
|
|
8395
|
+
PendingSafetyChecks: () => PendingSafetyChecks,
|
|
8396
|
+
PlatformTransport: () => PlatformTransport,
|
|
6724
8397
|
PushSlugConflict: () => PushSlugConflict,
|
|
6725
8398
|
RECOVER_BUDGET_MS: () => RECOVER_BUDGET_MS,
|
|
8399
|
+
SANDBOX_REQUEST_TIMEOUT_MS: () => SANDBOX_REQUEST_TIMEOUT_MS,
|
|
8400
|
+
SECRET_KEY: () => SECRET_KEY,
|
|
6726
8401
|
SESSION_STATES: () => SESSION_STATES,
|
|
8402
|
+
SPAN_PREFIX: () => SPAN_PREFIX,
|
|
6727
8403
|
STATUS_WAIT_CAP_SECONDS: () => STATUS_WAIT_CAP_SECONDS,
|
|
6728
8404
|
STRIP_PREFIX: () => STRIP_PREFIX,
|
|
6729
8405
|
SURFACE_KINDS: () => SURFACE_KINDS,
|
|
8406
|
+
Screen: () => Screen,
|
|
6730
8407
|
SecretScrubber: () => SecretScrubber,
|
|
6731
8408
|
TRANSFORMS: () => TRANSFORMS,
|
|
8409
|
+
TaskEditClient: () => TaskEditClient,
|
|
6732
8410
|
TaskRun: () => TaskRun,
|
|
6733
8411
|
TaskSessions: () => TaskSessions,
|
|
8412
|
+
TransportCause: () => TransportCause,
|
|
8413
|
+
UnreachableError: () => UnreachableError,
|
|
6734
8414
|
VERIFIER_REWARD_PREFIX: () => VERIFIER_REWARD_PREFIX,
|
|
6735
8415
|
WHITESPACE: () => WHITESPACE,
|
|
6736
8416
|
WorldBrowser: () => WorldBrowser,
|
|
@@ -6798,6 +8478,8 @@ __export(worlds_exports, {
|
|
|
6798
8478
|
parseToolCallRecord: () => parseToolCallRecord,
|
|
6799
8479
|
parseTransform: () => parseTransform,
|
|
6800
8480
|
parseWorldTaskRefs: () => parseWorldTaskRefs,
|
|
8481
|
+
platformTimeoutMs: () => platformTimeoutMs,
|
|
8482
|
+
playwrightKey: () => playwrightKey,
|
|
6801
8483
|
preserveForm: () => preserveForm,
|
|
6802
8484
|
propose: () => propose,
|
|
6803
8485
|
pull: () => pull,
|
|
@@ -6807,8 +8489,10 @@ __export(worlds_exports, {
|
|
|
6807
8489
|
pyText: () => pyText,
|
|
6808
8490
|
queryRows: () => queryRows,
|
|
6809
8491
|
queryRowsSearch: () => queryRowsSearch,
|
|
8492
|
+
readField: () => readField,
|
|
6810
8493
|
readLocalMeta: () => readLocalMeta,
|
|
6811
8494
|
readToolCallRecords: () => readToolCallRecords,
|
|
8495
|
+
rebaseConflicts: () => rebaseConflicts,
|
|
6812
8496
|
redactActionArgs: () => redactActionArgs,
|
|
6813
8497
|
redactionOf: () => redactionOf,
|
|
6814
8498
|
releaseConnection: () => releaseConnection,
|
|
@@ -6831,6 +8515,7 @@ __export(worlds_exports, {
|
|
|
6831
8515
|
toolCallsFromObservations: () => toolCallsFromObservations,
|
|
6832
8516
|
uiEntryUrl: () => uiEntryUrl,
|
|
6833
8517
|
uiUrl: () => uiUrl,
|
|
8518
|
+
uncommittedPaths: () => uncommittedPaths,
|
|
6834
8519
|
updateTask: () => updateTask,
|
|
6835
8520
|
upsertRunConfig: () => upsertRunConfig,
|
|
6836
8521
|
validateTask: () => validateTask,
|
|
@@ -6870,19 +8555,10 @@ function parseErrorBody(text2, limit = 600) {
|
|
|
6870
8555
|
code: stableCode
|
|
6871
8556
|
};
|
|
6872
8557
|
}
|
|
6873
|
-
async function apiRequest(options, method, path12, body) {
|
|
6874
|
-
const
|
|
6875
|
-
|
|
6876
|
-
|
|
6877
|
-
headers: {
|
|
6878
|
-
"content-type": "application/json",
|
|
6879
|
-
authorization: "Basic " + Buffer.from(`${publicKey}:${secretKey}`).toString("base64")
|
|
6880
|
-
},
|
|
6881
|
-
...body === void 0 ? {} : { body: JSON.stringify(body) }
|
|
6882
|
-
});
|
|
6883
|
-
const text2 = await res.text();
|
|
6884
|
-
if (!res.ok) throw new ApiError2(res.status, method, path12, text2);
|
|
6885
|
-
return JSON.parse(text2);
|
|
8558
|
+
async function apiRequest(options, method, path12, body, init2 = {}) {
|
|
8559
|
+
const reply = await new PlatformTransport(resolveEnv(options)).send(method, path12, body, init2);
|
|
8560
|
+
if (!reply.ok) throw new ApiError(reply.status, method, path12, reply.text);
|
|
8561
|
+
return JSON.parse(reply.text);
|
|
6886
8562
|
}
|
|
6887
8563
|
async function setEnvSecret(slug, key, value, options = {}) {
|
|
6888
8564
|
return apiRequest(
|
|
@@ -7058,10 +8734,12 @@ async function resolveWorld(slugRef, slug, ref, pin, options) {
|
|
|
7058
8734
|
}
|
|
7059
8735
|
return world;
|
|
7060
8736
|
}
|
|
7061
|
-
var
|
|
8737
|
+
var ApiError, WorldTask, WorldSet;
|
|
7062
8738
|
var init_worlds = __esm({
|
|
7063
8739
|
"src/worlds/index.ts"() {
|
|
7064
|
-
|
|
8740
|
+
init_transport();
|
|
8741
|
+
init_transport();
|
|
8742
|
+
init_session2();
|
|
7065
8743
|
init_sessionList();
|
|
7066
8744
|
init_sessionContract();
|
|
7067
8745
|
init_taskRef();
|
|
@@ -7073,6 +8751,7 @@ var init_worlds = __esm({
|
|
|
7073
8751
|
init_evals();
|
|
7074
8752
|
init_browser();
|
|
7075
8753
|
init_browserReconnect();
|
|
8754
|
+
init_nativeComputer();
|
|
7076
8755
|
init_hub();
|
|
7077
8756
|
init_validate();
|
|
7078
8757
|
init_describe();
|
|
@@ -7084,15 +8763,17 @@ var init_worlds = __esm({
|
|
|
7084
8763
|
init_sandbox();
|
|
7085
8764
|
init_editSessions();
|
|
7086
8765
|
init_dryRun();
|
|
7087
|
-
|
|
7088
|
-
constructor(status, method, path12,
|
|
7089
|
-
const parsed = parseErrorBody(
|
|
8766
|
+
ApiError = class extends Error {
|
|
8767
|
+
constructor(status, method, path12, text2) {
|
|
8768
|
+
const parsed = parseErrorBody(text2);
|
|
7090
8769
|
super(`${method} ${path12} -> ${status}: ${parsed.detail}`);
|
|
7091
8770
|
this.status = status;
|
|
8771
|
+
this.text = text2;
|
|
7092
8772
|
this.name = "ApiError";
|
|
7093
8773
|
this.code = parsed.code;
|
|
7094
8774
|
}
|
|
7095
8775
|
status;
|
|
8776
|
+
text;
|
|
7096
8777
|
code;
|
|
7097
8778
|
};
|
|
7098
8779
|
WorldTask = class {
|
|
@@ -7137,7 +8818,7 @@ var init_worlds = __esm({
|
|
|
7137
8818
|
* worlds/session.ts.
|
|
7138
8819
|
*/
|
|
7139
8820
|
async open(task, opts = {}) {
|
|
7140
|
-
const { openSession: openSession2 } = await Promise.resolve().then(() => (
|
|
8821
|
+
const { openSession: openSession2 } = await Promise.resolve().then(() => (init_session2(), session_exports2));
|
|
7141
8822
|
return openSession2(this.slug, {
|
|
7142
8823
|
task,
|
|
7143
8824
|
versionId: this.version.versionId,
|
|
@@ -7172,6 +8853,10 @@ var init_worlds = __esm({
|
|
|
7172
8853
|
init_worlds();
|
|
7173
8854
|
// Annotate the CommonJS export names for ESM import in node:
|
|
7174
8855
|
0 && (module.exports = {
|
|
8856
|
+
ACTION_NAMES,
|
|
8857
|
+
ActionTracer,
|
|
8858
|
+
AnthropicComputer,
|
|
8859
|
+
AnthropicComputer20251124,
|
|
7175
8860
|
ApiError,
|
|
7176
8861
|
BROWSER_GONE_PATTERNS,
|
|
7177
8862
|
BROWSER_TIERS,
|
|
@@ -7183,11 +8868,13 @@ init_worlds();
|
|
|
7183
8868
|
CALL_BODY_LIMIT_LABEL,
|
|
7184
8869
|
COMPUTER_USE_SPECS,
|
|
7185
8870
|
CheckoutProvenance,
|
|
8871
|
+
ComputerAction,
|
|
7186
8872
|
DEFAULT_BRANCH,
|
|
7187
8873
|
DEFAULT_VIEWPORT,
|
|
7188
8874
|
DRY_RUN_AGENT,
|
|
7189
8875
|
DRY_RUN_KIND,
|
|
7190
8876
|
DetachedPushError,
|
|
8877
|
+
Display,
|
|
7191
8878
|
DryRunOutcome,
|
|
7192
8879
|
EVENT_BATCH_SIZE,
|
|
7193
8880
|
EVENT_FLUSH_INTERVAL_MS,
|
|
@@ -7197,17 +8884,34 @@ init_worlds();
|
|
|
7197
8884
|
GatewayEvalsClient,
|
|
7198
8885
|
HostedDryRunClient,
|
|
7199
8886
|
IDLE_WARNING_MINUTES,
|
|
8887
|
+
KEY_NAMES,
|
|
8888
|
+
KeyChord,
|
|
8889
|
+
NOT_EXECUTED,
|
|
7200
8890
|
NO_GRADER_REASON,
|
|
8891
|
+
NativeComputer,
|
|
8892
|
+
OpenAIComputer,
|
|
8893
|
+
OpenAIPreviewComputer,
|
|
8894
|
+
PLATFORM_TIMEOUT_DEFAULT_MS,
|
|
8895
|
+
PLATFORM_TIMEOUT_ENV,
|
|
8896
|
+
PendingSafetyChecks,
|
|
8897
|
+
PlatformTransport,
|
|
7201
8898
|
PushSlugConflict,
|
|
7202
8899
|
RECOVER_BUDGET_MS,
|
|
8900
|
+
SANDBOX_REQUEST_TIMEOUT_MS,
|
|
8901
|
+
SECRET_KEY,
|
|
7203
8902
|
SESSION_STATES,
|
|
8903
|
+
SPAN_PREFIX,
|
|
7204
8904
|
STATUS_WAIT_CAP_SECONDS,
|
|
7205
8905
|
STRIP_PREFIX,
|
|
7206
8906
|
SURFACE_KINDS,
|
|
8907
|
+
Screen,
|
|
7207
8908
|
SecretScrubber,
|
|
7208
8909
|
TRANSFORMS,
|
|
8910
|
+
TaskEditClient,
|
|
7209
8911
|
TaskRun,
|
|
7210
8912
|
TaskSessions,
|
|
8913
|
+
TransportCause,
|
|
8914
|
+
UnreachableError,
|
|
7211
8915
|
VERIFIER_REWARD_PREFIX,
|
|
7212
8916
|
WHITESPACE,
|
|
7213
8917
|
WorldBrowser,
|
|
@@ -7275,6 +8979,8 @@ init_worlds();
|
|
|
7275
8979
|
parseToolCallRecord,
|
|
7276
8980
|
parseTransform,
|
|
7277
8981
|
parseWorldTaskRefs,
|
|
8982
|
+
platformTimeoutMs,
|
|
8983
|
+
playwrightKey,
|
|
7278
8984
|
preserveForm,
|
|
7279
8985
|
propose,
|
|
7280
8986
|
pull,
|
|
@@ -7284,8 +8990,10 @@ init_worlds();
|
|
|
7284
8990
|
pyText,
|
|
7285
8991
|
queryRows,
|
|
7286
8992
|
queryRowsSearch,
|
|
8993
|
+
readField,
|
|
7287
8994
|
readLocalMeta,
|
|
7288
8995
|
readToolCallRecords,
|
|
8996
|
+
rebaseConflicts,
|
|
7289
8997
|
redactActionArgs,
|
|
7290
8998
|
redactionOf,
|
|
7291
8999
|
releaseConnection,
|
|
@@ -7308,6 +9016,7 @@ init_worlds();
|
|
|
7308
9016
|
toolCallsFromObservations,
|
|
7309
9017
|
uiEntryUrl,
|
|
7310
9018
|
uiUrl,
|
|
9019
|
+
uncommittedPaths,
|
|
7311
9020
|
updateTask,
|
|
7312
9021
|
upsertRunConfig,
|
|
7313
9022
|
validateTask,
|