@withgateway/sdk 0.3.0 → 0.3.1

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.
Files changed (47) hide show
  1. package/README.md +5 -1
  2. package/dist/cli.js +1497 -712
  3. package/dist/cli.js.map +1 -1
  4. package/dist/cli.mjs +1500 -715
  5. package/dist/cli.mjs.map +1 -1
  6. package/dist/files/index.js +34 -0
  7. package/dist/files/index.js.map +1 -1
  8. package/dist/files/index.mjs +34 -0
  9. package/dist/files/index.mjs.map +1 -1
  10. package/dist/{index-DAb-FCMg.d.ts → index-CBqbB_0J.d.ts} +2 -12
  11. package/dist/{index-D6oi1TWE.d.mts → index-D-AMnAMa.d.mts} +2 -12
  12. package/dist/index.d.mts +3 -3
  13. package/dist/index.d.ts +3 -3
  14. package/dist/index.js +173 -50
  15. package/dist/index.js.map +1 -1
  16. package/dist/index.mjs +171 -50
  17. package/dist/index.mjs.map +1 -1
  18. package/dist/traces/index.js +34 -0
  19. package/dist/traces/index.js.map +1 -1
  20. package/dist/traces/index.mjs +34 -0
  21. package/dist/traces/index.mjs.map +1 -1
  22. package/dist/tracing/index.d.mts +1 -1
  23. package/dist/tracing/index.d.ts +1 -1
  24. package/dist/tracing/index.js +39 -20
  25. package/dist/tracing/index.js.map +1 -1
  26. package/dist/tracing/index.mjs +39 -20
  27. package/dist/tracing/index.mjs.map +1 -1
  28. package/dist/worlds/index.d.mts +66 -18
  29. package/dist/worlds/index.d.ts +66 -18
  30. package/dist/worlds/index.js +171 -50
  31. package/dist/worlds/index.js.map +1 -1
  32. package/dist/worlds/index.mjs +171 -50
  33. package/dist/worlds/index.mjs.map +1 -1
  34. package/package.json +1 -1
  35. package/runtime/gatewaysdk/environment/schema/api.py +7 -8
  36. package/runtime/gatewaysdk/environment/schema/cast.py +31 -4
  37. package/runtime/gatewaysdk/environment/schema/platform.py +1 -7
  38. package/runtime/gatewaysdk/environment/schema/skills/connector-schema-authoring/SKILL.md +3 -3
  39. package/runtime/gatewaysdk/environment/schema/skills/world-data-ingestion/SKILL.md +2 -2
  40. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/SKILL.md +6 -6
  41. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/cli-mcp-map.md +1 -1
  42. package/skills/connector-schema-authoring/SKILL.md +3 -3
  43. package/skills/connector-schema-authoring/connector-worlds.md +12 -5
  44. package/skills/connector-schema-authoring/world-schema.md +8 -0
  45. package/skills/world-data-ingestion/SKILL.md +2 -2
  46. package/skills/worlds-getting-started/SKILL.md +6 -6
  47. package/skills/worlds-getting-started/references/cli-mcp-map.md +1 -1
@@ -1,4 +1,4 @@
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-D6oi1TWE.mjs';
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-D-AMnAMa.mjs';
2
2
  export { M as MAX_MEDIA_BYTES, f as MediaField, g as MediaReference, h as MediaUploadError, i as MediaUploader } from '../media-CbcAfQvd.mjs';
3
3
  import '@opentelemetry/api';
4
4
  import '../scores/index.mjs';
@@ -1,4 +1,4 @@
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-DAb-FCMg.js';
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-CBqbB_0J.js';
2
2
  export { M as MAX_MEDIA_BYTES, f as MediaField, g as MediaReference, h as MediaUploadError, i as MediaUploader } from '../media-CbcAfQvd.js';
3
3
  import '@opentelemetry/api';
4
4
  import '../scores/index.js';
@@ -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.0",
32
+ version: "0.3.1",
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",
@@ -1204,22 +1204,49 @@ async function registerBuild(params) {
1204
1204
  }
1205
1205
  }
1206
1206
 
1207
- // src/tracing/init.ts
1208
- var ENV_VARS = {
1207
+ // src/tracing/prerequisites.ts
1208
+ var GATEWAY_ENV = {
1209
1209
  HOST: "GATEWAY_HOST",
1210
1210
  PUBLIC_KEY: "GATEWAY_PUBLIC_KEY",
1211
1211
  SECRET_KEY: "GATEWAY_SECRET_KEY",
1212
1212
  ENDPOINT: "GATEWAY_OTLP_ENDPOINT"
1213
1213
  };
1214
+ var OPENTELEMETRY_PEERS = [
1215
+ "@opentelemetry/api",
1216
+ "@opentelemetry/exporter-trace-otlp-http",
1217
+ "@opentelemetry/resources",
1218
+ "@opentelemetry/sdk-trace-base",
1219
+ "@opentelemetry/sdk-trace-node"
1220
+ ];
1221
+ var MODULE_NOT_FOUND = /* @__PURE__ */ new Set(["MODULE_NOT_FOUND", "ERR_MODULE_NOT_FOUND"]);
1222
+ function getEnv(key) {
1223
+ const value = process.env[key];
1224
+ return value ? value : void 0;
1225
+ }
1226
+ function isGatewayConfigured() {
1227
+ return !!(getEnv(GATEWAY_ENV.HOST) && getEnv(GATEWAY_ENV.PUBLIC_KEY) && getEnv(GATEWAY_ENV.SECRET_KEY));
1228
+ }
1229
+ var OpenTelemetryMissing = class _OpenTelemetryMissing extends Error {
1230
+ constructor() {
1231
+ super(
1232
+ `OpenTelemetry packages not found. Install them with:
1233
+ npm install ${OPENTELEMETRY_PEERS.join(" ")}`
1234
+ );
1235
+ this.name = "OpenTelemetryMissing";
1236
+ }
1237
+ static explains(error) {
1238
+ if (error instanceof _OpenTelemetryMissing) return true;
1239
+ const { code, message } = error ?? {};
1240
+ return MODULE_NOT_FOUND.has(String(code)) && String(message).includes("@opentelemetry/");
1241
+ }
1242
+ };
1243
+
1244
+ // src/tracing/init.ts
1214
1245
  var DEFAULT_OTLP_PATH = "/api/public/otel/v1/traces";
1215
1246
  var state = {
1216
1247
  initialized: false,
1217
1248
  provider: null
1218
1249
  };
1219
- function getEnv(key) {
1220
- const value = process.env[key];
1221
- return value ? value : void 0;
1222
- }
1223
1250
  function log(message, ...args) {
1224
1251
  if (state.debug) {
1225
1252
  console.log(`[gatewaysdk.tracing] ${message}`, ...args);
@@ -1229,10 +1256,10 @@ function warn(message, ...args) {
1229
1256
  console.warn(`[gatewaysdk.tracing] ${message}`, ...args);
1230
1257
  }
1231
1258
  function buildProvider(config, logFn) {
1232
- const host = config.host ?? getEnv(ENV_VARS.HOST);
1233
- const publicKey = config.publicKey ?? getEnv(ENV_VARS.PUBLIC_KEY);
1234
- const secretKey = config.secretKey ?? getEnv(ENV_VARS.SECRET_KEY);
1235
- const endpoint = config.endpoint ?? getEnv(ENV_VARS.ENDPOINT) ?? (host ? `${host.replace(/\/$/, "")}${DEFAULT_OTLP_PATH}` : void 0);
1259
+ const host = config.host ?? getEnv(GATEWAY_ENV.HOST);
1260
+ const publicKey = config.publicKey ?? getEnv(GATEWAY_ENV.PUBLIC_KEY);
1261
+ const secretKey = config.secretKey ?? getEnv(GATEWAY_ENV.SECRET_KEY);
1262
+ const endpoint = config.endpoint ?? getEnv(GATEWAY_ENV.ENDPOINT) ?? (host ? `${host.replace(/\/$/, "")}${DEFAULT_OTLP_PATH}` : void 0);
1236
1263
  const missing = [];
1237
1264
  if (!host) missing.push("host (or GATEWAY_HOST env var)");
1238
1265
  if (!publicKey) missing.push("publicKey (or GATEWAY_PUBLIC_KEY env var)");
@@ -1269,9 +1296,7 @@ function buildProvider(config, logFn) {
1269
1296
  ATTR_SERVICE_NAME = "service.name";
1270
1297
  }
1271
1298
  } catch {
1272
- throw new Error(
1273
- "OpenTelemetry packages not found. Install them with:\nnpm install @opentelemetry/sdk-trace-node @opentelemetry/sdk-trace-base @opentelemetry/exporter-trace-otlp-http @opentelemetry/resources"
1274
- );
1299
+ throw new OpenTelemetryMissing();
1275
1300
  }
1276
1301
  const resourceAttrs = {
1277
1302
  [ATTR_SERVICE_NAME]: config.serviceName ?? "gatewaysdk-tracing"
@@ -1477,12 +1502,6 @@ async function shutdown() {
1477
1502
  function isInitialized() {
1478
1503
  return state.initialized;
1479
1504
  }
1480
- function isGatewayConfigured() {
1481
- const host = getEnv(ENV_VARS.HOST);
1482
- const publicKey = getEnv(ENV_VARS.PUBLIC_KEY);
1483
- const secretKey = getEnv(ENV_VARS.SECRET_KEY);
1484
- return !!(host && publicKey && secretKey);
1485
- }
1486
1505
 
1487
1506
  // src/tracing/observe.ts
1488
1507
  var import_api3 = require("@opentelemetry/api");