@withgateway/sdk 0.3.1 → 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 +4 -3
- package/dist/cli.js +2880 -2032
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +2982 -2135
- 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 +180 -41
- package/dist/files/index.js.map +1 -1
- package/dist/files/index.mjs +172 -35
- package/dist/files/index.mjs.map +1 -1
- package/dist/{index-CBqbB_0J.d.ts → index-DUHmS74p.d.ts} +1 -1
- package/dist/{index-D-AMnAMa.d.mts → index-mJhG3vZU.d.mts} +1 -1
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1309 -540
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1287 -532
- 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 +177 -38
- package/dist/traces/index.js.map +1 -1
- package/dist/traces/index.mjs +169 -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 +69 -13
- package/dist/tracing/index.js.map +1 -1
- package/dist/tracing/index.mjs +69 -13
- package/dist/tracing/index.mjs.map +1 -1
- package/dist/worlds/index.d.mts +249 -120
- package/dist/worlds/index.d.ts +249 -120
- package/dist/worlds/index.js +1240 -484
- package/dist/worlds/index.js.map +1 -1
- package/dist/worlds/index.mjs +1231 -476
- 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 -514
- 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/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 +123 -171
- 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 +19 -11
- package/runtime/gatewaysdk/environment/schema/skills/world-data-ingestion/ROWS.md +29 -3
- package/runtime/gatewaysdk/environment/schema/skills/world-data-ingestion/SKILL.md +14 -14
- package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/SKILL.md +12 -12
- 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 +19 -11
- package/skills/connector-schema-authoring/connector-worlds.md +13 -4
- package/skills/connector-schema-authoring/world-schema.md +103 -51
- package/skills/world-data-ingestion/ROWS.md +29 -3
- package/skills/world-data-ingestion/SKILL.md +14 -14
- package/skills/worlds-getting-started/SKILL.md +12 -12
- 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
package/dist/tracing/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { I as IdentifyOptions, a as IdentitySpanProcessor, O as ObservationKind, b as ObserveClaudeOptions, c as ObserveOptions, S as SECRET_KEYS, d as SESSION_ID_ATTRIBUTE, e as SecretRedactingSpanProcessor, f as SessionSpanProcessor, g as SpanSecrets, T as TracingConfig, h as TracingHandle, j as TracingState, U as USER_ID_ATTRIBUTE, W as WORLD_SESSION_ID_ATTRIBUTE, k as flush, l as getAmbientSessionId, m as getCurrentWorldSessionId, i as identify, n as init, o as initIsolated, p as isGatewayConfigured, q as isInitialized, s as observe, t as observeAnthropic, u as observeClaude, v as observeOpenAI, w as resetAmbientUser, r as resolveUserId, x as shutdown, y as withSession, z as withWorldSession } from '../index-
|
|
2
|
-
export { M as MAX_MEDIA_BYTES, f as MediaField, g as MediaReference, h as MediaUploadError, i as MediaUploader } from '../media-
|
|
1
|
+
export { I as IdentifyOptions, a as IdentitySpanProcessor, O as ObservationKind, b as ObserveClaudeOptions, c as ObserveOptions, S as SECRET_KEYS, d as SESSION_ID_ATTRIBUTE, e as SecretRedactingSpanProcessor, f as SessionSpanProcessor, g as SpanSecrets, T as TracingConfig, h as TracingHandle, j as TracingState, U as USER_ID_ATTRIBUTE, W as WORLD_SESSION_ID_ATTRIBUTE, k as flush, l as getAmbientSessionId, m as getCurrentWorldSessionId, i as identify, n as init, o as initIsolated, p as isGatewayConfigured, q as isInitialized, s as observe, t as observeAnthropic, u as observeClaude, v as observeOpenAI, w as resetAmbientUser, r as resolveUserId, x as shutdown, y as withSession, z as withWorldSession } from '../index-mJhG3vZU.mjs';
|
|
2
|
+
export { M as MAX_MEDIA_BYTES, f as MediaField, g as MediaReference, h as MediaUploadError, i as MediaUploader } from '../media-BIApiPzS.mjs';
|
|
3
3
|
import '@opentelemetry/api';
|
|
4
4
|
import '../scores/index.mjs';
|
|
5
5
|
import '@opentelemetry/sdk-trace-base';
|
package/dist/tracing/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { I as IdentifyOptions, a as IdentitySpanProcessor, O as ObservationKind, b as ObserveClaudeOptions, c as ObserveOptions, S as SECRET_KEYS, d as SESSION_ID_ATTRIBUTE, e as SecretRedactingSpanProcessor, f as SessionSpanProcessor, g as SpanSecrets, T as TracingConfig, h as TracingHandle, j as TracingState, U as USER_ID_ATTRIBUTE, W as WORLD_SESSION_ID_ATTRIBUTE, k as flush, l as getAmbientSessionId, m as getCurrentWorldSessionId, i as identify, n as init, o as initIsolated, p as isGatewayConfigured, q as isInitialized, s as observe, t as observeAnthropic, u as observeClaude, v as observeOpenAI, w as resetAmbientUser, r as resolveUserId, x as shutdown, y as withSession, z as withWorldSession } from '../index-
|
|
2
|
-
export { M as MAX_MEDIA_BYTES, f as MediaField, g as MediaReference, h as MediaUploadError, i as MediaUploader } from '../media-
|
|
1
|
+
export { I as IdentifyOptions, a as IdentitySpanProcessor, O as ObservationKind, b as ObserveClaudeOptions, c as ObserveOptions, S as SECRET_KEYS, d as SESSION_ID_ATTRIBUTE, e as SecretRedactingSpanProcessor, f as SessionSpanProcessor, g as SpanSecrets, T as TracingConfig, h as TracingHandle, j as TracingState, U as USER_ID_ATTRIBUTE, W as WORLD_SESSION_ID_ATTRIBUTE, k as flush, l as getAmbientSessionId, m as getCurrentWorldSessionId, i as identify, n as init, o as initIsolated, p as isGatewayConfigured, q as isInitialized, s as observe, t as observeAnthropic, u as observeClaude, v as observeOpenAI, w as resetAmbientUser, r as resolveUserId, x as shutdown, y as withSession, z as withWorldSession } from '../index-DUHmS74p.js';
|
|
2
|
+
export { M as MAX_MEDIA_BYTES, f as MediaField, g as MediaReference, h as MediaUploadError, i as MediaUploader } from '../media-BIApiPzS.js';
|
|
3
3
|
import '@opentelemetry/api';
|
|
4
4
|
import '../scores/index.js';
|
|
5
5
|
import '@opentelemetry/sdk-trace-base';
|
package/dist/tracing/index.js
CHANGED
|
@@ -29,7 +29,7 @@ var require_package = __commonJS({
|
|
|
29
29
|
"package.json"(exports2, module2) {
|
|
30
30
|
module2.exports = {
|
|
31
31
|
name: "@withgateway/sdk",
|
|
32
|
-
version: "0.3.
|
|
32
|
+
version: "0.3.3",
|
|
33
33
|
description: "Gateway SDK for TypeScript - A/B experiments, tracing, and observability",
|
|
34
34
|
main: "./dist/index.js",
|
|
35
35
|
module: "./dist/index.mjs",
|
|
@@ -1209,15 +1209,18 @@ var GATEWAY_ENV = {
|
|
|
1209
1209
|
HOST: "GATEWAY_HOST",
|
|
1210
1210
|
PUBLIC_KEY: "GATEWAY_PUBLIC_KEY",
|
|
1211
1211
|
SECRET_KEY: "GATEWAY_SECRET_KEY",
|
|
1212
|
+
API_KEY: "GATEWAY_API_KEY",
|
|
1212
1213
|
ENDPOINT: "GATEWAY_OTLP_ENDPOINT"
|
|
1213
1214
|
};
|
|
1214
|
-
var
|
|
1215
|
-
|
|
1216
|
-
"@opentelemetry/
|
|
1217
|
-
"@opentelemetry/
|
|
1218
|
-
"@opentelemetry/
|
|
1219
|
-
"@opentelemetry/sdk-trace-
|
|
1220
|
-
|
|
1215
|
+
var OTLP_TRACES_PATH = "/api/public/otel/v1/traces";
|
|
1216
|
+
var OPENTELEMETRY_PEERS = {
|
|
1217
|
+
"@opentelemetry/api": "1.9.0",
|
|
1218
|
+
"@opentelemetry/exporter-trace-otlp-http": "0.222.0",
|
|
1219
|
+
"@opentelemetry/resources": "2.11.0",
|
|
1220
|
+
"@opentelemetry/sdk-trace-base": "2.11.0",
|
|
1221
|
+
"@opentelemetry/sdk-trace-node": "2.11.0"
|
|
1222
|
+
};
|
|
1223
|
+
var PINNED_PEERS = Object.entries(OPENTELEMETRY_PEERS).map(([name, version]) => `${name}@${version}`).join(" ");
|
|
1221
1224
|
var MODULE_NOT_FOUND = /* @__PURE__ */ new Set(["MODULE_NOT_FOUND", "ERR_MODULE_NOT_FOUND"]);
|
|
1222
1225
|
function getEnv(key) {
|
|
1223
1226
|
const value = process.env[key];
|
|
@@ -1229,8 +1232,9 @@ function isGatewayConfigured() {
|
|
|
1229
1232
|
var OpenTelemetryMissing = class _OpenTelemetryMissing extends Error {
|
|
1230
1233
|
constructor() {
|
|
1231
1234
|
super(
|
|
1232
|
-
`OpenTelemetry packages not found. Install them with:
|
|
1233
|
-
npm install ${
|
|
1235
|
+
`OpenTelemetry packages not found. Install them next to @withgateway/sdk, at the versions it is tested with:
|
|
1236
|
+
npm install ${PINNED_PEERS}
|
|
1237
|
+
npm install -g ${PINNED_PEERS} (the gateway CLI, when it was installed with npm install -g)`
|
|
1234
1238
|
);
|
|
1235
1239
|
this.name = "OpenTelemetryMissing";
|
|
1236
1240
|
}
|
|
@@ -1242,7 +1246,6 @@ npm install ${OPENTELEMETRY_PEERS.join(" ")}`
|
|
|
1242
1246
|
};
|
|
1243
1247
|
|
|
1244
1248
|
// src/tracing/init.ts
|
|
1245
|
-
var DEFAULT_OTLP_PATH = "/api/public/otel/v1/traces";
|
|
1246
1249
|
var state = {
|
|
1247
1250
|
initialized: false,
|
|
1248
1251
|
provider: null
|
|
@@ -1259,7 +1262,7 @@ function buildProvider(config, logFn) {
|
|
|
1259
1262
|
const host = config.host ?? getEnv(GATEWAY_ENV.HOST);
|
|
1260
1263
|
const publicKey = config.publicKey ?? getEnv(GATEWAY_ENV.PUBLIC_KEY);
|
|
1261
1264
|
const secretKey = config.secretKey ?? getEnv(GATEWAY_ENV.SECRET_KEY);
|
|
1262
|
-
const endpoint = config.endpoint ?? getEnv(GATEWAY_ENV.ENDPOINT) ?? (host ? `${host.replace(/\/$/, "")}${
|
|
1265
|
+
const endpoint = config.endpoint ?? getEnv(GATEWAY_ENV.ENDPOINT) ?? (host ? `${host.replace(/\/$/, "")}${OTLP_TRACES_PATH}` : void 0);
|
|
1263
1266
|
const missing = [];
|
|
1264
1267
|
if (!host) missing.push("host (or GATEWAY_HOST env var)");
|
|
1265
1268
|
if (!publicKey) missing.push("publicKey (or GATEWAY_PUBLIC_KEY env var)");
|
|
@@ -1829,6 +1832,56 @@ var UnreachableError = class extends Error {
|
|
|
1829
1832
|
route;
|
|
1830
1833
|
failure;
|
|
1831
1834
|
};
|
|
1835
|
+
var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
1836
|
+
var RetryPolicy = class _RetryPolicy {
|
|
1837
|
+
constructor(delaysMs, wait = sleep, budgetMs = Number.POSITIVE_INFINITY, now = Date.now) {
|
|
1838
|
+
this.delaysMs = delaysMs;
|
|
1839
|
+
this.wait = wait;
|
|
1840
|
+
this.budgetMs = budgetMs;
|
|
1841
|
+
this.now = now;
|
|
1842
|
+
}
|
|
1843
|
+
delaysMs;
|
|
1844
|
+
wait;
|
|
1845
|
+
budgetMs;
|
|
1846
|
+
now;
|
|
1847
|
+
static NONE = new _RetryPolicy([]);
|
|
1848
|
+
/** A platform restart or a short edge outage: no wait starts that would end past five minutes, so a step ends
|
|
1849
|
+
* within the budget plus one request timeout. */
|
|
1850
|
+
static FILING = new _RetryPolicy([250, 500, 1e3, 2e3, 4e3, 8e3, 16e3, 3e4], sleep, 3e5);
|
|
1851
|
+
static TRANSIENT_STATUSES = /* @__PURE__ */ new Set([502, 503, 504]);
|
|
1852
|
+
async run(attempt) {
|
|
1853
|
+
const started = this.now();
|
|
1854
|
+
for (let tries = 0; ; tries += 1) {
|
|
1855
|
+
const outcome = await Attempt.of(attempt);
|
|
1856
|
+
const delayMs = this.delaysMs[tries];
|
|
1857
|
+
const spent = delayMs === void 0 || this.now() - started + delayMs >= this.budgetMs;
|
|
1858
|
+
if (!outcome.transient || spent) return outcome.settle();
|
|
1859
|
+
await this.wait(delayMs);
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1862
|
+
};
|
|
1863
|
+
var Attempt = class _Attempt {
|
|
1864
|
+
constructor(reply, error, transient) {
|
|
1865
|
+
this.reply = reply;
|
|
1866
|
+
this.error = error;
|
|
1867
|
+
this.transient = transient;
|
|
1868
|
+
}
|
|
1869
|
+
reply;
|
|
1870
|
+
error;
|
|
1871
|
+
transient;
|
|
1872
|
+
static async of(attempt) {
|
|
1873
|
+
try {
|
|
1874
|
+
const reply = await attempt();
|
|
1875
|
+
return new _Attempt(reply, null, RetryPolicy.TRANSIENT_STATUSES.has(reply.status));
|
|
1876
|
+
} catch (error) {
|
|
1877
|
+
return new _Attempt(null, error, error instanceof UnreachableError);
|
|
1878
|
+
}
|
|
1879
|
+
}
|
|
1880
|
+
settle() {
|
|
1881
|
+
if (this.reply) return this.reply;
|
|
1882
|
+
throw this.error;
|
|
1883
|
+
}
|
|
1884
|
+
};
|
|
1832
1885
|
var PlatformTransport = class {
|
|
1833
1886
|
constructor(endpoint, timeoutMs = platformTimeoutMs()) {
|
|
1834
1887
|
this.endpoint = endpoint;
|
|
@@ -1842,6 +1895,9 @@ var PlatformTransport = class {
|
|
|
1842
1895
|
}
|
|
1843
1896
|
async send(method, route, body, opts = {}) {
|
|
1844
1897
|
const timeoutMs = this.budget(opts.timeoutMs);
|
|
1898
|
+
return (opts.retry ?? RetryPolicy.NONE).run(() => this.once(method, route, body, timeoutMs));
|
|
1899
|
+
}
|
|
1900
|
+
async once(method, route, body, timeoutMs) {
|
|
1845
1901
|
const payload = body === void 0 ? {} : { body: JSON.stringify(body) };
|
|
1846
1902
|
const controller = new AbortController();
|
|
1847
1903
|
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
@@ -1924,7 +1980,7 @@ var MediaUploader = class _MediaUploader {
|
|
|
1924
1980
|
put;
|
|
1925
1981
|
maxBytes;
|
|
1926
1982
|
/** The uploader for `GATEWAY_HOST` / `GATEWAY_PUBLIC_KEY` /
|
|
1927
|
-
* `GATEWAY_SECRET_KEY`
|
|
1983
|
+
* `GATEWAY_SECRET_KEY` only; null when any is unset, so a run traced with a saved login uploads none. */
|
|
1928
1984
|
static fromEnv(env = process.env) {
|
|
1929
1985
|
const host = env.GATEWAY_HOST;
|
|
1930
1986
|
const publicKey = env.GATEWAY_PUBLIC_KEY;
|