@withgateway/sdk 0.1.16 → 0.1.18

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/dist/index.js CHANGED
@@ -339,7 +339,7 @@ function isIncludedInContentHash(relPath, includeAllRootFiles) {
339
339
  if (name.startsWith(".")) return false;
340
340
  if (parts.includes("__pycache__")) return false;
341
341
  if (dirParts.length === 0) {
342
- return includeAllRootFiles || name === "README.md" || name === "pyproject.toml" || name === "gateway-env.toml" || name.endsWith(".py");
342
+ return includeAllRootFiles || name === "README.md" || name === "pyproject.toml" || BROAD_ROOT_MARKERS.includes(name) || name.endsWith(".py");
343
343
  }
344
344
  return !dirParts.some(isExcludedDirComponent);
345
345
  }
@@ -350,7 +350,9 @@ function collectArchiveRelPaths(dir) {
350
350
  );
351
351
  }
352
352
  const out = [];
353
- const includeAllRootFiles = fs.existsSync(path.join(dir, "gateway-env.toml"));
353
+ const includeAllRootFiles = BROAD_ROOT_MARKERS.some(
354
+ (marker) => fs.existsSync(path.join(dir, marker))
355
+ );
354
356
  const walk = (rel) => {
355
357
  const abs = rel ? path.join(dir, rel) : dir;
356
358
  for (const entry of fs.readdirSync(abs, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
@@ -664,7 +666,7 @@ async function createRef(slug, name, kind, versionId, options = {}) {
664
666
  ...versionId ? { versionId } : {}
665
667
  });
666
668
  }
667
- var import_node_crypto, import_node_zlib, fs, path, DEFAULT_BRANCH, META_RELPATH, SKIP_DIRS, ROOT_EXCLUDED_DIRS, sha256b64;
669
+ var import_node_crypto, import_node_zlib, fs, path, DEFAULT_BRANCH, META_RELPATH, SKIP_DIRS, ROOT_EXCLUDED_DIRS, BROAD_ROOT_MARKERS, sha256b64;
668
670
  var init_hub = __esm({
669
671
  "src/worlds/hub.ts"() {
670
672
  "use strict";
@@ -686,6 +688,7 @@ var init_hub = __esm({
686
688
  "outputs"
687
689
  ]);
688
690
  ROOT_EXCLUDED_DIRS = /* @__PURE__ */ new Set(["dist", "build", "outputs", "__pycache__"]);
691
+ BROAD_ROOT_MARKERS = ["gateway-env.toml", "gateway-api-world.toml"];
689
692
  sha256b64 = (data) => (0, import_node_crypto.createHash)("sha256").update(data).digest("base64");
690
693
  }
691
694
  });
@@ -771,6 +774,23 @@ async function validateWorld(dir, opts) {
771
774
  versionId: pushed.versionId,
772
775
  ...provenance
773
776
  });
777
+ const host = (options.host ?? process.env.GATEWAY_HOST ?? "https://withgateway.ai").replace(/\/+$/, "");
778
+ let projectId = null;
779
+ try {
780
+ const projects = await apiRequest(
781
+ options,
782
+ "GET",
783
+ "/api/public/projects"
784
+ );
785
+ projectId = projects.data?.[0]?.id ?? null;
786
+ } catch {
787
+ projectId = null;
788
+ }
789
+ const fallbackUrl = (report) => {
790
+ if (report.url) return report.url;
791
+ const evaluationId = report.evaluations[0]?.id;
792
+ return projectId && evaluationId ? `${host}/project/${projectId}/environment/runs/${encodeURIComponent(evaluationId)}` : null;
793
+ };
774
794
  const runs = [];
775
795
  for (const run of dispatched.runs) {
776
796
  if (!run.ok) {
@@ -793,6 +813,7 @@ async function validateWorld(dir, opts) {
793
813
  `\u2026${run.model}: ${r.status.toLowerCase()} (${r.shardsCompleted ?? 0}/${r.parallelism} shards)`
794
814
  )
795
815
  });
816
+ report = { ...report, url: fallbackUrl(report) };
796
817
  if (report.status.toUpperCase() !== "COMPLETED") {
797
818
  failure = report.status;
798
819
  } else if (minScore !== null) {
@@ -1090,7 +1111,7 @@ var require_package = __commonJS({
1090
1111
  "package.json"(exports2, module2) {
1091
1112
  module2.exports = {
1092
1113
  name: "@withgateway/sdk",
1093
- version: "0.1.16",
1114
+ version: "0.1.18",
1094
1115
  description: "Gateway SDK for TypeScript - A/B experiments, tracing, and observability",
1095
1116
  main: "./dist/index.js",
1096
1117
  module: "./dist/index.mjs",