@withgateway/sdk 0.3.0 → 0.3.3
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 +6 -1
- package/dist/cli.js +3971 -2338
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +3950 -2318
- package/dist/cli.mjs.map +1 -1
- package/dist/files/index.d.mts +1 -1
- package/dist/files/index.d.ts +1 -1
- package/dist/files/index.js +214 -41
- package/dist/files/index.js.map +1 -1
- package/dist/files/index.mjs +206 -35
- package/dist/files/index.mjs.map +1 -1
- package/dist/{index-DAb-FCMg.d.ts → index-DUHmS74p.d.ts} +3 -13
- package/dist/{index-D6oi1TWE.d.mts → index-mJhG3vZU.d.mts} +3 -13
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1456 -564
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1433 -557
- package/dist/index.mjs.map +1 -1
- package/dist/{media-CbcAfQvd.d.mts → media-BIApiPzS.d.mts} +21 -2
- package/dist/{media-CbcAfQvd.d.ts → media-BIApiPzS.d.ts} +21 -2
- package/dist/traces/index.d.mts +1 -1
- package/dist/traces/index.d.ts +1 -1
- package/dist/traces/index.js +211 -38
- package/dist/traces/index.js.map +1 -1
- package/dist/traces/index.mjs +203 -32
- package/dist/traces/index.mjs.map +1 -1
- package/dist/tracing/index.d.mts +2 -2
- package/dist/tracing/index.d.ts +2 -2
- package/dist/tracing/index.js +96 -21
- package/dist/tracing/index.js.map +1 -1
- package/dist/tracing/index.mjs +96 -21
- package/dist/tracing/index.mjs.map +1 -1
- package/dist/worlds/index.d.mts +300 -123
- package/dist/worlds/index.d.ts +300 -123
- package/dist/worlds/index.js +1385 -508
- package/dist/worlds/index.js.map +1 -1
- package/dist/worlds/index.mjs +1377 -501
- package/dist/worlds/index.mjs.map +1 -1
- package/package.json +1 -1
- package/runtime/gatewaysdk/environment/_bundle.py +2 -27
- package/runtime/gatewaysdk/environment/_materialize.py +49 -69
- package/runtime/gatewaysdk/environment/_world.py +122 -197
- package/runtime/gatewaysdk/environment/backing.py +137 -0
- package/runtime/gatewaysdk/environment/core.py +1 -1
- package/runtime/gatewaysdk/environment/legacy_sqlite.py +301 -0
- package/runtime/gatewaysdk/environment/reward_keys.py +25 -0
- package/runtime/gatewaysdk/environment/runtime.py +8 -13
- package/runtime/gatewaysdk/environment/schema/__init__.py +4 -4
- package/runtime/gatewaysdk/environment/schema/admin_routes.py +86 -0
- package/runtime/gatewaysdk/environment/schema/api.py +266 -515
- package/runtime/gatewaysdk/environment/schema/batch.py +42 -37
- package/runtime/gatewaysdk/environment/schema/bundle_runtime.py +17 -5
- package/runtime/gatewaysdk/environment/schema/call_log.py +291 -0
- package/runtime/gatewaysdk/environment/schema/call_redaction.py +344 -0
- package/runtime/gatewaysdk/environment/schema/cast.py +31 -4
- package/runtime/gatewaysdk/environment/schema/compiler.py +334 -158
- package/runtime/gatewaysdk/environment/schema/conform.py +8 -12
- package/runtime/gatewaysdk/environment/schema/connector.py +27 -62
- package/runtime/gatewaysdk/environment/schema/data.py +50 -207
- package/runtime/gatewaysdk/environment/schema/database/__init__.py +24 -0
- package/runtime/gatewaysdk/environment/schema/database/audit.py +121 -0
- package/runtime/gatewaysdk/environment/schema/database/base.py +995 -0
- package/runtime/gatewaysdk/environment/schema/database/budget.py +33 -0
- package/runtime/gatewaysdk/environment/schema/database/connections.py +101 -0
- package/runtime/gatewaysdk/environment/schema/database/engines.py +8 -0
- package/runtime/gatewaysdk/environment/schema/database/guard.py +208 -0
- package/runtime/gatewaysdk/environment/schema/database/ingest.py +154 -0
- package/runtime/gatewaysdk/environment/schema/database/matching.py +58 -0
- package/runtime/gatewaysdk/environment/schema/database/provenance.py +30 -0
- package/runtime/gatewaysdk/environment/schema/database/rows.py +53 -0
- package/runtime/gatewaysdk/environment/schema/database/runtime_rows.py +39 -0
- package/runtime/gatewaysdk/environment/schema/database/sqlite.py +367 -0
- package/runtime/gatewaysdk/environment/schema/domain_migration.py +236 -0
- package/runtime/gatewaysdk/environment/schema/envelope.py +169 -0
- package/runtime/gatewaysdk/environment/schema/extract.py +6 -13
- package/runtime/gatewaysdk/environment/schema/grading.py +45 -30
- package/runtime/gatewaysdk/environment/schema/handler_errors.py +142 -12
- package/runtime/gatewaysdk/environment/schema/host.py +158 -250
- package/runtime/gatewaysdk/environment/schema/lanes.py +53 -0
- package/runtime/gatewaysdk/environment/schema/local.py +44 -71
- package/runtime/gatewaysdk/environment/schema/mapping.py +5 -25
- package/runtime/gatewaysdk/environment/schema/openapi_import.py +112 -73
- package/runtime/gatewaysdk/environment/schema/openapi_paging.py +147 -0
- package/runtime/gatewaysdk/environment/schema/openapi_payloads.py +288 -0
- package/runtime/gatewaysdk/environment/schema/openapi_routes.py +97 -102
- package/runtime/gatewaysdk/environment/schema/openapi_schemas.py +113 -30
- package/runtime/gatewaysdk/environment/schema/platform.py +124 -178
- package/runtime/gatewaysdk/environment/schema/platform_import.py +2 -3
- package/runtime/gatewaysdk/environment/schema/platform_query.py +61 -5
- package/runtime/gatewaysdk/environment/schema/primary_key.py +61 -0
- package/runtime/gatewaysdk/environment/schema/proof.py +19 -12
- package/runtime/gatewaysdk/environment/schema/runtime.py +77 -160
- package/runtime/gatewaysdk/environment/schema/served_names.py +58 -0
- package/runtime/gatewaysdk/environment/schema/session_files.py +166 -0
- package/runtime/gatewaysdk/environment/schema/skills/benchmarks-getting-started/SKILL.md +2 -2
- package/runtime/gatewaysdk/environment/schema/skills/connector-schema-authoring/SKILL.md +22 -14
- package/runtime/gatewaysdk/environment/schema/skills/world-data-ingestion/ROWS.md +29 -3
- package/runtime/gatewaysdk/environment/schema/skills/world-data-ingestion/SKILL.md +16 -16
- 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 +3 -2
- package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/gotchas.md +15 -0
- package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/openapi-import.md +50 -21
- package/runtime/gatewaysdk/environment/schema/slack.py +4 -8
- package/runtime/gatewaysdk/environment/schema/snapshot.py +385 -129
- package/runtime/gatewaysdk/environment/schema/store_contract.py +8 -14
- package/runtime/gatewaysdk/environment/schema/tasks.py +140 -55
- package/runtime/gatewaysdk/environment/schema/tools_world.py +110 -87
- package/runtime/gatewaysdk/environment/schema/ui.py +24 -5
- package/runtime/gatewaysdk/environment/schema/ui_static/app.js +100 -130
- package/runtime/gatewaysdk/environment/schema/ui_static/index.html +1 -8
- package/runtime/gatewaysdk/environment/schema/validation.py +166 -40
- package/runtime/gatewaysdk/environment/schema/workers.py +142 -57
- package/runtime/gatewaysdk/environment/schema/world_sql.py +81 -0
- package/runtime/gatewaysdk/environment/schema/world_tests.py +71 -39
- package/runtime/gatewaysdk/environment/score.py +57 -0
- package/runtime/gatewaysdk/environment/secret_values.py +36 -0
- package/runtime/gatewaysdk/environment/world.py +42 -3
- package/runtime/gatewaysdk/environment/world_session_contract.py +32 -5
- package/skills/benchmarks-getting-started/SKILL.md +2 -2
- package/skills/connector-schema-authoring/SKILL.md +22 -14
- package/skills/connector-schema-authoring/connector-worlds.md +26 -10
- package/skills/connector-schema-authoring/world-schema.md +111 -51
- package/skills/world-data-ingestion/ROWS.md +29 -3
- package/skills/world-data-ingestion/SKILL.md +16 -16
- package/skills/worlds-getting-started/SKILL.md +18 -18
- package/skills/worlds-getting-started/references/cli-mcp-map.md +3 -2
- package/skills/worlds-getting-started/references/gotchas.md +15 -0
- package/skills/worlds-getting-started/references/openapi-import.md +50 -21
- package/runtime/gatewaysdk/environment/schema/store.py +0 -1013
|
@@ -32,6 +32,23 @@ declare class UnreachableError extends Error {
|
|
|
32
32
|
readonly failure: TransportCause;
|
|
33
33
|
constructor(host: string, method: string, route: string, failure: TransportCause);
|
|
34
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Another attempt after a gateway 5xx (502, 503, 504) or no answer at all, for a request whose repeat is harmless: a
|
|
37
|
+
* keyed filing step, which the platform answers with the first filing. Every other request gets one attempt (`NONE`).
|
|
38
|
+
*/
|
|
39
|
+
declare class RetryPolicy {
|
|
40
|
+
readonly delaysMs: readonly number[];
|
|
41
|
+
private readonly wait;
|
|
42
|
+
readonly budgetMs: number;
|
|
43
|
+
private readonly now;
|
|
44
|
+
static readonly NONE: RetryPolicy;
|
|
45
|
+
/** A platform restart or a short edge outage: no wait starts that would end past five minutes, so a step ends
|
|
46
|
+
* within the budget plus one request timeout. */
|
|
47
|
+
static readonly FILING: RetryPolicy;
|
|
48
|
+
static readonly TRANSIENT_STATUSES: ReadonlySet<number>;
|
|
49
|
+
constructor(delaysMs: readonly number[], wait?: (ms: number) => Promise<void>, budgetMs?: number, now?: () => number);
|
|
50
|
+
run(attempt: () => Promise<PlatformReply>): Promise<PlatformReply>;
|
|
51
|
+
}
|
|
35
52
|
/** The one door every CLI and SDK request to the platform goes through: Basic auth with the project key, a per-request timeout, and a transport failure turned into an `UnreachableError`. */
|
|
36
53
|
declare class PlatformTransport {
|
|
37
54
|
private readonly endpoint;
|
|
@@ -41,7 +58,9 @@ declare class PlatformTransport {
|
|
|
41
58
|
budget(ownMs?: number): number;
|
|
42
59
|
send(method: PlatformMethod, route: string, body?: unknown, opts?: {
|
|
43
60
|
timeoutMs?: number;
|
|
61
|
+
retry?: RetryPolicy;
|
|
44
62
|
}): Promise<PlatformReply>;
|
|
63
|
+
private once;
|
|
45
64
|
}
|
|
46
65
|
|
|
47
66
|
declare const MAX_MEDIA_BYTES: number;
|
|
@@ -67,7 +86,7 @@ declare class MediaUploader {
|
|
|
67
86
|
maxBytes: number;
|
|
68
87
|
constructor(transport: PlatformTransport, put?: PutBytes, maxBytes?: number);
|
|
69
88
|
/** The uploader for `GATEWAY_HOST` / `GATEWAY_PUBLIC_KEY` /
|
|
70
|
-
* `GATEWAY_SECRET_KEY`
|
|
89
|
+
* `GATEWAY_SECRET_KEY` only; null when any is unset, so a run traced with a saved login uploads none. */
|
|
71
90
|
static fromEnv(env?: NodeJS.ProcessEnv): MediaUploader | null;
|
|
72
91
|
/** Store `data` linked to the trace (and observation) and return its reference. */
|
|
73
92
|
upload(data: Buffer, link: {
|
|
@@ -80,4 +99,4 @@ declare class MediaUploader {
|
|
|
80
99
|
private send;
|
|
81
100
|
}
|
|
82
101
|
|
|
83
|
-
export { MAX_MEDIA_BYTES as M, PLATFORM_TIMEOUT_DEFAULT_MS as P, TransportCause as T, UnreachableError as U, PLATFORM_TIMEOUT_ENV as a, type PlatformEndpoint as b, type PlatformMethod as c, type PlatformReply as d, PlatformTransport as e, type MediaField as f, MediaReference as g, MediaUploadError as h, MediaUploader as i, platformTimeoutMs as p };
|
|
102
|
+
export { MAX_MEDIA_BYTES as M, PLATFORM_TIMEOUT_DEFAULT_MS as P, RetryPolicy as R, TransportCause as T, UnreachableError as U, PLATFORM_TIMEOUT_ENV as a, type PlatformEndpoint as b, type PlatformMethod as c, type PlatformReply as d, PlatformTransport as e, type MediaField as f, MediaReference as g, MediaUploadError as h, MediaUploader as i, platformTimeoutMs as p };
|
|
@@ -32,6 +32,23 @@ declare class UnreachableError extends Error {
|
|
|
32
32
|
readonly failure: TransportCause;
|
|
33
33
|
constructor(host: string, method: string, route: string, failure: TransportCause);
|
|
34
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Another attempt after a gateway 5xx (502, 503, 504) or no answer at all, for a request whose repeat is harmless: a
|
|
37
|
+
* keyed filing step, which the platform answers with the first filing. Every other request gets one attempt (`NONE`).
|
|
38
|
+
*/
|
|
39
|
+
declare class RetryPolicy {
|
|
40
|
+
readonly delaysMs: readonly number[];
|
|
41
|
+
private readonly wait;
|
|
42
|
+
readonly budgetMs: number;
|
|
43
|
+
private readonly now;
|
|
44
|
+
static readonly NONE: RetryPolicy;
|
|
45
|
+
/** A platform restart or a short edge outage: no wait starts that would end past five minutes, so a step ends
|
|
46
|
+
* within the budget plus one request timeout. */
|
|
47
|
+
static readonly FILING: RetryPolicy;
|
|
48
|
+
static readonly TRANSIENT_STATUSES: ReadonlySet<number>;
|
|
49
|
+
constructor(delaysMs: readonly number[], wait?: (ms: number) => Promise<void>, budgetMs?: number, now?: () => number);
|
|
50
|
+
run(attempt: () => Promise<PlatformReply>): Promise<PlatformReply>;
|
|
51
|
+
}
|
|
35
52
|
/** The one door every CLI and SDK request to the platform goes through: Basic auth with the project key, a per-request timeout, and a transport failure turned into an `UnreachableError`. */
|
|
36
53
|
declare class PlatformTransport {
|
|
37
54
|
private readonly endpoint;
|
|
@@ -41,7 +58,9 @@ declare class PlatformTransport {
|
|
|
41
58
|
budget(ownMs?: number): number;
|
|
42
59
|
send(method: PlatformMethod, route: string, body?: unknown, opts?: {
|
|
43
60
|
timeoutMs?: number;
|
|
61
|
+
retry?: RetryPolicy;
|
|
44
62
|
}): Promise<PlatformReply>;
|
|
63
|
+
private once;
|
|
45
64
|
}
|
|
46
65
|
|
|
47
66
|
declare const MAX_MEDIA_BYTES: number;
|
|
@@ -67,7 +86,7 @@ declare class MediaUploader {
|
|
|
67
86
|
maxBytes: number;
|
|
68
87
|
constructor(transport: PlatformTransport, put?: PutBytes, maxBytes?: number);
|
|
69
88
|
/** The uploader for `GATEWAY_HOST` / `GATEWAY_PUBLIC_KEY` /
|
|
70
|
-
* `GATEWAY_SECRET_KEY`
|
|
89
|
+
* `GATEWAY_SECRET_KEY` only; null when any is unset, so a run traced with a saved login uploads none. */
|
|
71
90
|
static fromEnv(env?: NodeJS.ProcessEnv): MediaUploader | null;
|
|
72
91
|
/** Store `data` linked to the trace (and observation) and return its reference. */
|
|
73
92
|
upload(data: Buffer, link: {
|
|
@@ -80,4 +99,4 @@ declare class MediaUploader {
|
|
|
80
99
|
private send;
|
|
81
100
|
}
|
|
82
101
|
|
|
83
|
-
export { MAX_MEDIA_BYTES as M, PLATFORM_TIMEOUT_DEFAULT_MS as P, TransportCause as T, UnreachableError as U, PLATFORM_TIMEOUT_ENV as a, type PlatformEndpoint as b, type PlatformMethod as c, type PlatformReply as d, PlatformTransport as e, type MediaField as f, MediaReference as g, MediaUploadError as h, MediaUploader as i, platformTimeoutMs as p };
|
|
102
|
+
export { MAX_MEDIA_BYTES as M, PLATFORM_TIMEOUT_DEFAULT_MS as P, RetryPolicy as R, TransportCause as T, UnreachableError as U, PLATFORM_TIMEOUT_ENV as a, type PlatformEndpoint as b, type PlatformMethod as c, type PlatformReply as d, PlatformTransport as e, type MediaField as f, MediaReference as g, MediaUploadError as h, MediaUploader as i, platformTimeoutMs as p };
|
package/dist/traces/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import '../worlds/index.mjs';
|
|
2
2
|
export { E as ExportOptions, a as ExportSummary, O as Observation, b as ObservationFilters, P as PAGE_LIMIT, c as Page, d as PageMeta, S as SessionFilters, T as Trace, e as TraceDetail, f as TraceFilters, g as TraceSession, h as TraceSessionDetail, j as exportTraces, k as getSession, l as getTrace, m as iterateObservations, n as iterateSessions, o as iterateTraces, p as listObservations, q as listSessions, r as listTraces } from '../index-CiKWoroJ.mjs';
|
|
3
|
-
import '../media-
|
|
3
|
+
import '../media-BIApiPzS.mjs';
|
package/dist/traces/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import '../worlds/index.js';
|
|
2
2
|
export { E as ExportOptions, a as ExportSummary, O as Observation, b as ObservationFilters, P as PAGE_LIMIT, c as Page, d as PageMeta, S as SessionFilters, T as Trace, e as TraceDetail, f as TraceFilters, g as TraceSession, h as TraceSessionDetail, j as exportTraces, k as getSession, l as getTrace, m as iterateObservations, n as iterateSessions, o as iterateTraces, p as listObservations, q as listSessions, r as listTraces } from '../index-BgvvQ3BC.js';
|
|
3
|
-
import '../media-
|
|
3
|
+
import '../media-BIApiPzS.js';
|
package/dist/traces/index.js
CHANGED
|
@@ -35,6 +35,28 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
35
35
|
));
|
|
36
36
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
37
|
|
|
38
|
+
// src/worlds/platformEndpoint.ts
|
|
39
|
+
function platformEndpoint(options) {
|
|
40
|
+
const publicKey = options.publicKey ?? process.env.GATEWAY_PUBLIC_KEY;
|
|
41
|
+
const secretKey = options.secretKey ?? process.env.GATEWAY_SECRET_KEY;
|
|
42
|
+
if (!publicKey || !secretKey) return null;
|
|
43
|
+
const host = options.host ?? process.env.GATEWAY_HOST ?? DEFAULT_HOST;
|
|
44
|
+
return { host: host.replace(/\/+$/, ""), publicKey, secretKey };
|
|
45
|
+
}
|
|
46
|
+
function requirePlatformEndpoint(options) {
|
|
47
|
+
const endpoint = platformEndpoint(options);
|
|
48
|
+
if (!endpoint) throw new Error(GATEWAY_KEYS_MISSING);
|
|
49
|
+
return endpoint;
|
|
50
|
+
}
|
|
51
|
+
var DEFAULT_HOST, GATEWAY_KEYS_MISSING;
|
|
52
|
+
var init_platformEndpoint = __esm({
|
|
53
|
+
"src/worlds/platformEndpoint.ts"() {
|
|
54
|
+
"use strict";
|
|
55
|
+
DEFAULT_HOST = "https://withgateway.ai";
|
|
56
|
+
GATEWAY_KEYS_MISSING = "Gateway keys missing: set GATEWAY_PUBLIC_KEY / GATEWAY_SECRET_KEY (or pass publicKey/secretKey).";
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
38
60
|
// src/worlds/transport.ts
|
|
39
61
|
function platformTimeoutMs(env = process.env) {
|
|
40
62
|
const raw = env[PLATFORM_TIMEOUT_ENV];
|
|
@@ -43,7 +65,7 @@ function platformTimeoutMs(env = process.env) {
|
|
|
43
65
|
if (Number.isInteger(value) && value > 0) return value;
|
|
44
66
|
throw new Error(`${PLATFORM_TIMEOUT_ENV} must be a positive whole number of milliseconds, not \`${raw}\`.`);
|
|
45
67
|
}
|
|
46
|
-
var PLATFORM_TIMEOUT_ENV, PLATFORM_TIMEOUT_DEFAULT_MS, CHECK_HOST, RETRY, CAUSES, UNKNOWN_CAUSE, TransportCause, UnreachableError, PlatformTransport;
|
|
68
|
+
var PLATFORM_TIMEOUT_ENV, PLATFORM_TIMEOUT_DEFAULT_MS, CHECK_HOST, RETRY, CAUSES, UNKNOWN_CAUSE, TransportCause, UnreachableError, sleep, RetryPolicy, Attempt, PlatformTransport;
|
|
47
69
|
var init_transport = __esm({
|
|
48
70
|
"src/worlds/transport.ts"() {
|
|
49
71
|
"use strict";
|
|
@@ -105,6 +127,56 @@ var init_transport = __esm({
|
|
|
105
127
|
route;
|
|
106
128
|
failure;
|
|
107
129
|
};
|
|
130
|
+
sleep = (ms) => new Promise((resolve3) => setTimeout(resolve3, ms));
|
|
131
|
+
RetryPolicy = class _RetryPolicy {
|
|
132
|
+
constructor(delaysMs, wait = sleep, budgetMs = Number.POSITIVE_INFINITY, now = Date.now) {
|
|
133
|
+
this.delaysMs = delaysMs;
|
|
134
|
+
this.wait = wait;
|
|
135
|
+
this.budgetMs = budgetMs;
|
|
136
|
+
this.now = now;
|
|
137
|
+
}
|
|
138
|
+
delaysMs;
|
|
139
|
+
wait;
|
|
140
|
+
budgetMs;
|
|
141
|
+
now;
|
|
142
|
+
static NONE = new _RetryPolicy([]);
|
|
143
|
+
/** A platform restart or a short edge outage: no wait starts that would end past five minutes, so a step ends
|
|
144
|
+
* within the budget plus one request timeout. */
|
|
145
|
+
static FILING = new _RetryPolicy([250, 500, 1e3, 2e3, 4e3, 8e3, 16e3, 3e4], sleep, 3e5);
|
|
146
|
+
static TRANSIENT_STATUSES = /* @__PURE__ */ new Set([502, 503, 504]);
|
|
147
|
+
async run(attempt) {
|
|
148
|
+
const started = this.now();
|
|
149
|
+
for (let tries = 0; ; tries += 1) {
|
|
150
|
+
const outcome = await Attempt.of(attempt);
|
|
151
|
+
const delayMs = this.delaysMs[tries];
|
|
152
|
+
const spent = delayMs === void 0 || this.now() - started + delayMs >= this.budgetMs;
|
|
153
|
+
if (!outcome.transient || spent) return outcome.settle();
|
|
154
|
+
await this.wait(delayMs);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
Attempt = class _Attempt {
|
|
159
|
+
constructor(reply, error, transient) {
|
|
160
|
+
this.reply = reply;
|
|
161
|
+
this.error = error;
|
|
162
|
+
this.transient = transient;
|
|
163
|
+
}
|
|
164
|
+
reply;
|
|
165
|
+
error;
|
|
166
|
+
transient;
|
|
167
|
+
static async of(attempt) {
|
|
168
|
+
try {
|
|
169
|
+
const reply = await attempt();
|
|
170
|
+
return new _Attempt(reply, null, RetryPolicy.TRANSIENT_STATUSES.has(reply.status));
|
|
171
|
+
} catch (error) {
|
|
172
|
+
return new _Attempt(null, error, error instanceof UnreachableError);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
settle() {
|
|
176
|
+
if (this.reply) return this.reply;
|
|
177
|
+
throw this.error;
|
|
178
|
+
}
|
|
179
|
+
};
|
|
108
180
|
PlatformTransport = class {
|
|
109
181
|
constructor(endpoint, timeoutMs = platformTimeoutMs()) {
|
|
110
182
|
this.endpoint = endpoint;
|
|
@@ -118,6 +190,9 @@ var init_transport = __esm({
|
|
|
118
190
|
}
|
|
119
191
|
async send(method, route, body, opts = {}) {
|
|
120
192
|
const timeoutMs = this.budget(opts.timeoutMs);
|
|
193
|
+
return (opts.retry ?? RetryPolicy.NONE).run(() => this.once(method, route, body, timeoutMs));
|
|
194
|
+
}
|
|
195
|
+
async once(method, route, body, timeoutMs) {
|
|
121
196
|
const payload = body === void 0 ? {} : { body: JSON.stringify(body) };
|
|
122
197
|
const controller = new AbortController();
|
|
123
198
|
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
@@ -490,13 +565,13 @@ var init_screen = __esm({
|
|
|
490
565
|
});
|
|
491
566
|
}
|
|
492
567
|
async drag(action) {
|
|
493
|
-
const
|
|
494
|
-
if (
|
|
568
|
+
const path8 = action.args.path ?? [];
|
|
569
|
+
if (path8.length < 2) throw new Error("a drag needs at least two points");
|
|
495
570
|
return this.held(action.args.modifiers ?? [], async () => {
|
|
496
|
-
await this.moveTo(
|
|
571
|
+
await this.moveTo(path8[0]);
|
|
497
572
|
await this.page.mouse.down({ button: "left" });
|
|
498
573
|
try {
|
|
499
|
-
for (const point2 of
|
|
574
|
+
for (const point2 of path8.slice(1)) await this.moveTo(point2, DRAG_STEPS);
|
|
500
575
|
} finally {
|
|
501
576
|
await this.page.mouse.up({ button: "left" });
|
|
502
577
|
}
|
|
@@ -587,7 +662,7 @@ var init_media = __esm({
|
|
|
587
662
|
put;
|
|
588
663
|
maxBytes;
|
|
589
664
|
/** The uploader for `GATEWAY_HOST` / `GATEWAY_PUBLIC_KEY` /
|
|
590
|
-
* `GATEWAY_SECRET_KEY`
|
|
665
|
+
* `GATEWAY_SECRET_KEY` only; null when any is unset, so a run traced with a saved login uploads none. */
|
|
591
666
|
static fromEnv(env = process.env) {
|
|
592
667
|
const host = env.GATEWAY_HOST;
|
|
593
668
|
const publicKey = env.GATEWAY_PUBLIC_KEY;
|
|
@@ -1455,6 +1530,15 @@ var init_sessionContract = __esm({
|
|
|
1455
1530
|
}
|
|
1456
1531
|
});
|
|
1457
1532
|
|
|
1533
|
+
// src/worlds/sessionReadiness.ts
|
|
1534
|
+
var READY_TIMEOUT_MS;
|
|
1535
|
+
var init_sessionReadiness = __esm({
|
|
1536
|
+
"src/worlds/sessionReadiness.ts"() {
|
|
1537
|
+
"use strict";
|
|
1538
|
+
READY_TIMEOUT_MS = 10 * 6e4;
|
|
1539
|
+
}
|
|
1540
|
+
});
|
|
1541
|
+
|
|
1458
1542
|
// src/tracing/session.ts
|
|
1459
1543
|
var import_async_hooks, processStorage, currentSessionStorage, currentWorldSessionStorage;
|
|
1460
1544
|
var init_session = __esm({
|
|
@@ -1479,8 +1563,22 @@ var init_taskRef = __esm({
|
|
|
1479
1563
|
}
|
|
1480
1564
|
});
|
|
1481
1565
|
|
|
1566
|
+
// src/worlds/worldNotice.ts
|
|
1567
|
+
var init_worldNotice = __esm({
|
|
1568
|
+
"src/worlds/worldNotice.ts"() {
|
|
1569
|
+
"use strict";
|
|
1570
|
+
}
|
|
1571
|
+
});
|
|
1572
|
+
|
|
1573
|
+
// src/worlds/grade.ts
|
|
1574
|
+
var init_grade = __esm({
|
|
1575
|
+
"src/worlds/grade.ts"() {
|
|
1576
|
+
"use strict";
|
|
1577
|
+
}
|
|
1578
|
+
});
|
|
1579
|
+
|
|
1482
1580
|
// src/worlds/session.ts
|
|
1483
|
-
var import_node_crypto2,
|
|
1581
|
+
var import_node_crypto2, CALL_TIMEOUT_MS, JUDGED_GRADE_TIMEOUT_MS;
|
|
1484
1582
|
var init_session2 = __esm({
|
|
1485
1583
|
"src/worlds/session.ts"() {
|
|
1486
1584
|
"use strict";
|
|
@@ -1489,10 +1587,13 @@ var init_session2 = __esm({
|
|
|
1489
1587
|
init_browser();
|
|
1490
1588
|
init_nativeComputer();
|
|
1491
1589
|
init_sessionContract();
|
|
1590
|
+
init_sessionReadiness();
|
|
1492
1591
|
init_session();
|
|
1493
1592
|
init_taskRef();
|
|
1593
|
+
init_worldNotice();
|
|
1594
|
+
init_grade();
|
|
1494
1595
|
init_taskRef();
|
|
1495
|
-
|
|
1596
|
+
init_sessionReadiness();
|
|
1496
1597
|
CALL_TIMEOUT_MS = 3 * 6e4;
|
|
1497
1598
|
JUDGED_GRADE_TIMEOUT_MS = 15 * 6e4;
|
|
1498
1599
|
}
|
|
@@ -1514,12 +1615,22 @@ var init_tasks = __esm({
|
|
|
1514
1615
|
}
|
|
1515
1616
|
});
|
|
1516
1617
|
|
|
1618
|
+
// src/worlds/surfaceDescriptor.ts
|
|
1619
|
+
var init_surfaceDescriptor = __esm({
|
|
1620
|
+
"src/worlds/surfaceDescriptor.ts"() {
|
|
1621
|
+
"use strict";
|
|
1622
|
+
init_browser();
|
|
1623
|
+
}
|
|
1624
|
+
});
|
|
1625
|
+
|
|
1517
1626
|
// src/worlds/taskSessions.ts
|
|
1518
1627
|
var init_taskSessions = __esm({
|
|
1519
1628
|
"src/worlds/taskSessions.ts"() {
|
|
1520
1629
|
"use strict";
|
|
1521
1630
|
init_worlds();
|
|
1522
1631
|
init_browser();
|
|
1632
|
+
init_grade();
|
|
1633
|
+
init_surfaceDescriptor();
|
|
1523
1634
|
init_session2();
|
|
1524
1635
|
}
|
|
1525
1636
|
});
|
|
@@ -1529,21 +1640,80 @@ var init_evals = __esm({
|
|
|
1529
1640
|
"src/worlds/evals.ts"() {
|
|
1530
1641
|
"use strict";
|
|
1531
1642
|
init_worlds();
|
|
1643
|
+
init_transport();
|
|
1644
|
+
}
|
|
1645
|
+
});
|
|
1646
|
+
|
|
1647
|
+
// src/worlds/runSignals.ts
|
|
1648
|
+
var import_node_os;
|
|
1649
|
+
var init_runSignals = __esm({
|
|
1650
|
+
"src/worlds/runSignals.ts"() {
|
|
1651
|
+
"use strict";
|
|
1652
|
+
import_node_os = require("os");
|
|
1653
|
+
}
|
|
1654
|
+
});
|
|
1655
|
+
|
|
1656
|
+
// src/worlds/taskRunDir.ts
|
|
1657
|
+
var fs, path;
|
|
1658
|
+
var init_taskRunDir = __esm({
|
|
1659
|
+
"src/worlds/taskRunDir.ts"() {
|
|
1660
|
+
"use strict";
|
|
1661
|
+
fs = __toESM(require("fs"));
|
|
1662
|
+
path = __toESM(require("path"));
|
|
1663
|
+
init_browser();
|
|
1664
|
+
}
|
|
1665
|
+
});
|
|
1666
|
+
|
|
1667
|
+
// src/worlds/taskRunOutcome.ts
|
|
1668
|
+
var init_taskRunOutcome = __esm({
|
|
1669
|
+
"src/worlds/taskRunOutcome.ts"() {
|
|
1670
|
+
"use strict";
|
|
1671
|
+
init_grade();
|
|
1672
|
+
init_taskSessions();
|
|
1673
|
+
}
|
|
1674
|
+
});
|
|
1675
|
+
|
|
1676
|
+
// src/tracing/prerequisites.ts
|
|
1677
|
+
var OPENTELEMETRY_PEERS, PINNED_PEERS;
|
|
1678
|
+
var init_prerequisites = __esm({
|
|
1679
|
+
"src/tracing/prerequisites.ts"() {
|
|
1680
|
+
"use strict";
|
|
1681
|
+
OPENTELEMETRY_PEERS = {
|
|
1682
|
+
"@opentelemetry/api": "1.9.0",
|
|
1683
|
+
"@opentelemetry/exporter-trace-otlp-http": "0.222.0",
|
|
1684
|
+
"@opentelemetry/resources": "2.11.0",
|
|
1685
|
+
"@opentelemetry/sdk-trace-base": "2.11.0",
|
|
1686
|
+
"@opentelemetry/sdk-trace-node": "2.11.0"
|
|
1687
|
+
};
|
|
1688
|
+
PINNED_PEERS = Object.entries(OPENTELEMETRY_PEERS).map(([name, version]) => `${name}@${version}`).join(" ");
|
|
1689
|
+
}
|
|
1690
|
+
});
|
|
1691
|
+
|
|
1692
|
+
// src/worlds/taskTracing.ts
|
|
1693
|
+
var init_taskTracing = __esm({
|
|
1694
|
+
"src/worlds/taskTracing.ts"() {
|
|
1695
|
+
"use strict";
|
|
1696
|
+
init_prerequisites();
|
|
1697
|
+
init_platformEndpoint();
|
|
1532
1698
|
}
|
|
1533
1699
|
});
|
|
1534
1700
|
|
|
1535
1701
|
// src/worlds/taskRun.ts
|
|
1536
|
-
var import_node_crypto3,
|
|
1702
|
+
var import_node_crypto3, path2;
|
|
1537
1703
|
var init_taskRun = __esm({
|
|
1538
1704
|
"src/worlds/taskRun.ts"() {
|
|
1539
1705
|
"use strict";
|
|
1540
1706
|
import_node_crypto3 = require("crypto");
|
|
1541
|
-
|
|
1542
|
-
path = __toESM(require("path"));
|
|
1707
|
+
path2 = __toESM(require("path"));
|
|
1543
1708
|
init_browser();
|
|
1544
1709
|
init_evals();
|
|
1710
|
+
init_runSignals();
|
|
1545
1711
|
init_session2();
|
|
1546
1712
|
init_taskSessions();
|
|
1713
|
+
init_taskRunDir();
|
|
1714
|
+
init_taskRunOutcome();
|
|
1715
|
+
init_taskTracing();
|
|
1716
|
+
init_worldNotice();
|
|
1547
1717
|
}
|
|
1548
1718
|
});
|
|
1549
1719
|
|
|
@@ -1562,28 +1732,36 @@ var init_setRun = __esm({
|
|
|
1562
1732
|
"use strict";
|
|
1563
1733
|
init_worlds();
|
|
1564
1734
|
init_checkoutProvenance();
|
|
1735
|
+
init_runSignals();
|
|
1565
1736
|
init_taskRun();
|
|
1566
1737
|
}
|
|
1567
1738
|
});
|
|
1568
1739
|
|
|
1740
|
+
// src/worlds/requestLog.ts
|
|
1741
|
+
var init_requestLog = __esm({
|
|
1742
|
+
"src/worlds/requestLog.ts"() {
|
|
1743
|
+
"use strict";
|
|
1744
|
+
}
|
|
1745
|
+
});
|
|
1746
|
+
|
|
1569
1747
|
// src/worlds/checkoutTarget.ts
|
|
1570
|
-
var fs2,
|
|
1748
|
+
var fs2, path3;
|
|
1571
1749
|
var init_checkoutTarget = __esm({
|
|
1572
1750
|
"src/worlds/checkoutTarget.ts"() {
|
|
1573
1751
|
"use strict";
|
|
1574
1752
|
fs2 = __toESM(require("fs"));
|
|
1575
|
-
|
|
1753
|
+
path3 = __toESM(require("path"));
|
|
1576
1754
|
}
|
|
1577
1755
|
});
|
|
1578
1756
|
|
|
1579
1757
|
// src/worlds/worldDir.ts
|
|
1580
|
-
var import_node_crypto4, fs3,
|
|
1758
|
+
var import_node_crypto4, fs3, path4, CONNECTOR_SPEC, WORLD_SCHEMA_MARKERS, WORLD_ROOT_MARKERS;
|
|
1581
1759
|
var init_worldDir = __esm({
|
|
1582
1760
|
"src/worlds/worldDir.ts"() {
|
|
1583
1761
|
"use strict";
|
|
1584
1762
|
import_node_crypto4 = require("crypto");
|
|
1585
1763
|
fs3 = __toESM(require("fs"));
|
|
1586
|
-
|
|
1764
|
+
path4 = __toESM(require("path"));
|
|
1587
1765
|
CONNECTOR_SPEC = "connector.toml";
|
|
1588
1766
|
WORLD_SCHEMA_MARKERS = ["schema/world.json", "schema/runtime.json", "schema/lock.json"];
|
|
1589
1767
|
WORLD_ROOT_MARKERS = [CONNECTOR_SPEC, ...WORLD_SCHEMA_MARKERS];
|
|
@@ -1591,30 +1769,30 @@ var init_worldDir = __esm({
|
|
|
1591
1769
|
});
|
|
1592
1770
|
|
|
1593
1771
|
// src/worlds/tar.ts
|
|
1594
|
-
var fs4,
|
|
1772
|
+
var fs4, path5, import_node_zlib;
|
|
1595
1773
|
var init_tar = __esm({
|
|
1596
1774
|
"src/worlds/tar.ts"() {
|
|
1597
1775
|
"use strict";
|
|
1598
1776
|
fs4 = __toESM(require("fs"));
|
|
1599
|
-
|
|
1777
|
+
path5 = __toESM(require("path"));
|
|
1600
1778
|
import_node_zlib = require("zlib");
|
|
1601
1779
|
}
|
|
1602
1780
|
});
|
|
1603
1781
|
|
|
1604
1782
|
// src/worlds/hub.ts
|
|
1605
|
-
var import_node_crypto5, import_node_zlib2, fs5,
|
|
1783
|
+
var import_node_crypto5, import_node_zlib2, fs5, path6, META_RELPATH;
|
|
1606
1784
|
var init_hub = __esm({
|
|
1607
1785
|
"src/worlds/hub.ts"() {
|
|
1608
1786
|
"use strict";
|
|
1609
1787
|
import_node_crypto5 = require("crypto");
|
|
1610
1788
|
import_node_zlib2 = require("zlib");
|
|
1611
1789
|
fs5 = __toESM(require("fs"));
|
|
1612
|
-
|
|
1790
|
+
path6 = __toESM(require("path"));
|
|
1613
1791
|
init_worlds();
|
|
1614
1792
|
init_checkoutTarget();
|
|
1615
1793
|
init_worldDir();
|
|
1616
1794
|
init_tar();
|
|
1617
|
-
META_RELPATH =
|
|
1795
|
+
META_RELPATH = path6.join(".gateway", ".env-metadata.json");
|
|
1618
1796
|
}
|
|
1619
1797
|
});
|
|
1620
1798
|
|
|
@@ -1719,14 +1897,15 @@ var init_migrate = __esm({
|
|
|
1719
1897
|
});
|
|
1720
1898
|
|
|
1721
1899
|
// src/worlds/ingest.ts
|
|
1722
|
-
var fs6, os,
|
|
1900
|
+
var fs6, os, path7;
|
|
1723
1901
|
var init_ingest = __esm({
|
|
1724
1902
|
"src/worlds/ingest.ts"() {
|
|
1725
1903
|
"use strict";
|
|
1726
1904
|
fs6 = __toESM(require("fs"));
|
|
1727
1905
|
os = __toESM(require("os"));
|
|
1728
|
-
|
|
1906
|
+
path7 = __toESM(require("path"));
|
|
1729
1907
|
init_worlds();
|
|
1908
|
+
init_platformEndpoint();
|
|
1730
1909
|
}
|
|
1731
1910
|
});
|
|
1732
1911
|
|
|
@@ -1747,17 +1926,6 @@ var init_dryRun = __esm({
|
|
|
1747
1926
|
});
|
|
1748
1927
|
|
|
1749
1928
|
// src/worlds/index.ts
|
|
1750
|
-
function resolveEnv(options) {
|
|
1751
|
-
const host = options.host ?? process.env.GATEWAY_HOST ?? "https://withgateway.ai";
|
|
1752
|
-
const publicKey = options.publicKey ?? process.env.GATEWAY_PUBLIC_KEY;
|
|
1753
|
-
const secretKey = options.secretKey ?? process.env.GATEWAY_SECRET_KEY;
|
|
1754
|
-
if (!publicKey || !secretKey) {
|
|
1755
|
-
throw new Error(
|
|
1756
|
-
"Gateway keys missing: set GATEWAY_PUBLIC_KEY / GATEWAY_SECRET_KEY (or pass publicKey/secretKey)."
|
|
1757
|
-
);
|
|
1758
|
-
}
|
|
1759
|
-
return { host: host.replace(/\/+$/, ""), publicKey, secretKey };
|
|
1760
|
-
}
|
|
1761
1929
|
function parseErrorBody(text, limit = 600) {
|
|
1762
1930
|
const raw = { detail: text.slice(0, limit), code: null };
|
|
1763
1931
|
let parsed;
|
|
@@ -1777,18 +1945,20 @@ function parseErrorBody(text, limit = 600) {
|
|
|
1777
1945
|
code: stableCode
|
|
1778
1946
|
};
|
|
1779
1947
|
}
|
|
1780
|
-
async function apiRequest(options, method,
|
|
1781
|
-
const reply = await new PlatformTransport(
|
|
1782
|
-
if (!reply.ok) throw new ApiError(reply.status, method,
|
|
1948
|
+
async function apiRequest(options, method, path8, body, init = {}) {
|
|
1949
|
+
const reply = await new PlatformTransport(requirePlatformEndpoint(options)).send(method, path8, body, init);
|
|
1950
|
+
if (!reply.ok) throw new ApiError(reply.status, method, path8, reply.text);
|
|
1783
1951
|
return JSON.parse(reply.text);
|
|
1784
1952
|
}
|
|
1785
1953
|
var ApiError;
|
|
1786
1954
|
var init_worlds = __esm({
|
|
1787
1955
|
"src/worlds/index.ts"() {
|
|
1788
1956
|
"use strict";
|
|
1957
|
+
init_platformEndpoint();
|
|
1789
1958
|
init_transport();
|
|
1790
1959
|
init_transport();
|
|
1791
1960
|
init_session2();
|
|
1961
|
+
init_grade();
|
|
1792
1962
|
init_sessionList();
|
|
1793
1963
|
init_sessionContract();
|
|
1794
1964
|
init_taskRef();
|
|
@@ -1799,6 +1969,8 @@ var init_worlds = __esm({
|
|
|
1799
1969
|
init_checkoutProvenance();
|
|
1800
1970
|
init_evals();
|
|
1801
1971
|
init_browser();
|
|
1972
|
+
init_surfaceDescriptor();
|
|
1973
|
+
init_requestLog();
|
|
1802
1974
|
init_browserReconnect();
|
|
1803
1975
|
init_nativeComputer();
|
|
1804
1976
|
init_hub();
|
|
@@ -1812,10 +1984,11 @@ var init_worlds = __esm({
|
|
|
1812
1984
|
init_sandbox();
|
|
1813
1985
|
init_editSessions();
|
|
1814
1986
|
init_dryRun();
|
|
1987
|
+
init_worldNotice();
|
|
1815
1988
|
ApiError = class extends Error {
|
|
1816
|
-
constructor(status, method,
|
|
1989
|
+
constructor(status, method, path8, text) {
|
|
1817
1990
|
const parsed = parseErrorBody(text);
|
|
1818
|
-
super(`${method} ${
|
|
1991
|
+
super(`${method} ${path8} -> ${status}: ${parsed.detail}`);
|
|
1819
1992
|
this.status = status;
|
|
1820
1993
|
this.text = text;
|
|
1821
1994
|
this.name = "ApiError";
|