@withgateway/sdk 0.1.14 → 0.1.17

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
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __esm = (fn, res) => function __init() {
7
9
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
@@ -21,6 +23,14 @@ var __copyProps = (to, from, except, desc) => {
21
23
  }
22
24
  return to;
23
25
  };
26
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
27
+ // If the importer is in node compatibility mode or this is not an ESM
28
+ // file that has been converted to a CommonJS file using a Babel-
29
+ // compatible transform (i.e. "__esModule" has not been set), then set
30
+ // "default" to the CommonJS "module.exports" for node compatibility.
31
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
32
+ mod
33
+ ));
24
34
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
35
 
26
36
  // src/worlds/session.ts
@@ -318,9 +328,524 @@ var init_session = __esm({
318
328
  }
319
329
  });
320
330
 
331
+ // src/worlds/hub.ts
332
+ function isExcludedDirComponent(component) {
333
+ return component.startsWith(".") || ROOT_EXCLUDED_DIRS.has(component) || component.endsWith(".egg-info");
334
+ }
335
+ function isIncludedInContentHash(relPath, includeAllRootFiles) {
336
+ const parts = relPath.split("/");
337
+ const name = parts[parts.length - 1];
338
+ const dirParts = parts.slice(0, -1);
339
+ if (name.startsWith(".")) return false;
340
+ if (parts.includes("__pycache__")) return false;
341
+ if (dirParts.length === 0) {
342
+ return includeAllRootFiles || name === "README.md" || name === "pyproject.toml" || name === "gateway-env.toml" || name.endsWith(".py");
343
+ }
344
+ return !dirParts.some(isExcludedDirComponent);
345
+ }
346
+ function collectArchiveRelPaths(dir) {
347
+ if (fs.existsSync(path.join(dir, ".gitignore"))) {
348
+ throw new Error(
349
+ "This bundle has a root .gitignore, which the Python CLI honors via gitignore_parser. Reimplementing that imperfectly here would silently produce a different content hash, so the TS CLI refuses. Remove the .gitignore (or bake its effect into the tree) and retry."
350
+ );
351
+ }
352
+ const out = [];
353
+ const includeAllRootFiles = fs.existsSync(path.join(dir, "gateway-env.toml"));
354
+ const walk = (rel) => {
355
+ const abs = rel ? path.join(dir, rel) : dir;
356
+ for (const entry of fs.readdirSync(abs, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
357
+ const childRel = rel ? `${rel}/${entry.name}` : entry.name;
358
+ if (entry.isDirectory()) {
359
+ if (!isExcludedDirComponent(entry.name)) walk(childRel);
360
+ } else if (entry.isFile()) {
361
+ if (isIncludedInContentHash(childRel, includeAllRootFiles)) {
362
+ out.push(childRel);
363
+ }
364
+ }
365
+ }
366
+ };
367
+ walk("");
368
+ return out.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
369
+ }
370
+ function computeContentHash(dir) {
371
+ const hasher = (0, import_node_crypto.createHash)("sha256");
372
+ for (const relPath of collectArchiveRelPaths(dir)) {
373
+ hasher.update(Buffer.from(`file:${relPath}`, "utf-8"));
374
+ hasher.update(fs.readFileSync(path.join(dir, relPath)));
375
+ }
376
+ return hasher.digest("hex");
377
+ }
378
+ function octal(value, length) {
379
+ return Buffer.from(value.toString(8).padStart(length - 1, "0") + "\0", "ascii");
380
+ }
381
+ function tarHeader(name, size) {
382
+ const header = Buffer.alloc(512);
383
+ header.write(name, 0, 100, "utf-8");
384
+ octal(420, 8).copy(header, 100);
385
+ octal(0, 8).copy(header, 108);
386
+ octal(0, 8).copy(header, 116);
387
+ octal(size, 12).copy(header, 124);
388
+ octal(0, 12).copy(header, 136);
389
+ header.write(" ", 148, "ascii");
390
+ header.write("0", 156, "ascii");
391
+ header.write("ustar", 257, "ascii");
392
+ header.write("00", 263, "ascii");
393
+ let sum = 0;
394
+ for (const byte of header) sum += byte;
395
+ header.write(sum.toString(8).padStart(6, "0") + "\0 ", 148, "ascii");
396
+ return header;
397
+ }
398
+ function tarMember(name, payload) {
399
+ const parts = [];
400
+ const nameBytes = Buffer.byteLength(name, "utf-8");
401
+ if (nameBytes > 100) {
402
+ const body = Buffer.from(name + "\0", "utf-8");
403
+ const lHeader = tarHeader("././@LongLink", body.length);
404
+ lHeader.write("L", 156, "ascii");
405
+ let sum = 0;
406
+ lHeader.write(" ", 148, "ascii");
407
+ for (const byte of lHeader) sum += byte;
408
+ lHeader.write(sum.toString(8).padStart(6, "0") + "\0 ", 148, "ascii");
409
+ parts.push(lHeader, body);
410
+ const pad2 = body.length % 512 === 0 ? 0 : 512 - body.length % 512;
411
+ if (pad2) parts.push(Buffer.alloc(pad2));
412
+ parts.push(tarHeader(name.slice(0, 100), payload.length));
413
+ } else {
414
+ parts.push(tarHeader(name, payload.length));
415
+ }
416
+ parts.push(payload);
417
+ const pad = payload.length % 512 === 0 ? 0 : 512 - payload.length % 512;
418
+ if (pad) parts.push(Buffer.alloc(pad));
419
+ return parts;
420
+ }
421
+ function buildSourceTarball(dir) {
422
+ const parts = [];
423
+ for (const relPath of collectArchiveRelPaths(dir)) {
424
+ parts.push(...tarMember(relPath, fs.readFileSync(path.join(dir, relPath))));
425
+ }
426
+ parts.push(Buffer.alloc(1024));
427
+ return (0, import_node_zlib.gzipSync)(Buffer.concat(parts), { level: 9 });
428
+ }
429
+ function readLocalMeta(dir) {
430
+ try {
431
+ const raw = fs.readFileSync(path.join(dir, META_RELPATH), "utf-8");
432
+ const parsed = JSON.parse(raw);
433
+ return parsed && typeof parsed === "object" ? parsed : null;
434
+ } catch {
435
+ return null;
436
+ }
437
+ }
438
+ function writeLocalMeta(dir, meta) {
439
+ fs.mkdirSync(path.join(dir, ".gateway"), { recursive: true });
440
+ fs.writeFileSync(path.join(dir, META_RELPATH), JSON.stringify(meta, null, 2));
441
+ }
442
+ function snapshotTreeHashes(dir) {
443
+ const out = {};
444
+ for (const relPath of collectArchiveRelPaths(dir)) {
445
+ out[relPath] = (0, import_node_crypto.createHash)("sha256").update(fs.readFileSync(path.join(dir, relPath))).digest("hex");
446
+ }
447
+ return out;
448
+ }
449
+ function localTreeState(dir) {
450
+ const meta = readLocalMeta(dir);
451
+ const base = meta?.baseFiles;
452
+ if (!base || typeof base !== "object") {
453
+ return { meta, dirty: [], clean: false };
454
+ }
455
+ const now = snapshotTreeHashes(dir);
456
+ const dirty = /* @__PURE__ */ new Set();
457
+ for (const [p, h] of Object.entries(now)) if (base[p] !== h) dirty.add(p);
458
+ for (const p of Object.keys(base)) if (!(p in now)) dirty.add(p);
459
+ return { meta, dirty: [...dirty].sort(), clean: dirty.size === 0 };
460
+ }
461
+ function readPyproject(dir) {
462
+ try {
463
+ const text = fs.readFileSync(path.join(dir, "pyproject.toml"), "utf-8");
464
+ const section = /\[project\]([\s\S]*?)(\n\[|$)/.exec(text)?.[1] ?? "";
465
+ const name = /\bname\s*=\s*"([^"]+)"/.exec(section)?.[1];
466
+ const version = /\bversion\s*=\s*"([^"]+)"/.exec(section)?.[1];
467
+ return { name, version };
468
+ } catch {
469
+ return {};
470
+ }
471
+ }
472
+ function buildFileManifest(dir) {
473
+ const entries = [];
474
+ const walk = (rel) => {
475
+ const abs = rel ? path.join(dir, rel) : dir;
476
+ for (const entry of fs.readdirSync(abs, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
477
+ const childRel = rel ? `${rel}/${entry.name}` : entry.name;
478
+ if (entry.isDirectory()) {
479
+ if (!SKIP_DIRS.has(entry.name) && !entry.name.endsWith(".egg-info")) {
480
+ walk(childRel);
481
+ }
482
+ } else if (entry.isFile()) {
483
+ const payload = fs.readFileSync(path.join(dir, childRel));
484
+ entries.push({
485
+ path: childRel,
486
+ isDirectory: false,
487
+ size: payload.length,
488
+ sha256: (0, import_node_crypto.createHash)("sha256").update(payload).digest("hex")
489
+ });
490
+ }
491
+ }
492
+ };
493
+ walk("");
494
+ return entries;
495
+ }
496
+ async function putObject(url, data, shaB64) {
497
+ const resp = await fetch(url, {
498
+ method: "PUT",
499
+ headers: {
500
+ "Content-Type": "application/gzip",
501
+ "x-amz-checksum-sha256": shaB64
502
+ },
503
+ body: new Uint8Array(data)
504
+ });
505
+ if (!resp.ok) {
506
+ throw new Error(`object PUT -> ${resp.status}: ${(await resp.text()).slice(0, 300)}`);
507
+ }
508
+ }
509
+ async function push(dir, opts = {}) {
510
+ const options = opts.options ?? {};
511
+ if (!fs.statSync(dir).isDirectory()) throw new Error(`Not a directory: ${dir}`);
512
+ const localMeta = readLocalMeta(dir) ?? {};
513
+ const branch = opts.branch ?? localMeta.branch ?? DEFAULT_BRANCH;
514
+ const baseVersionId = localMeta.versionId ?? null;
515
+ const contentHash = computeContentHash(dir);
516
+ const pyproject = readPyproject(dir);
517
+ const slug = opts.slug ?? pyproject.name ?? path.basename(path.resolve(dir));
518
+ const resolve2 = await apiRequest(
519
+ options,
520
+ "POST",
521
+ "/api/public/benchmark-containers/resolve",
522
+ { slug, name: pyproject.name ?? slug }
523
+ );
524
+ const tarball = buildSourceTarball(dir);
525
+ const bundleSha256 = sha256b64(tarball);
526
+ const version = await apiRequest(options, "POST", "/api/public/benchmark-containers/versions", {
527
+ containerId: resolve2.containerId,
528
+ contentHash,
529
+ bundleSha256,
530
+ bundleSizeBytes: tarball.length,
531
+ ...pyproject.version ? { semanticVersion: pyproject.version } : {},
532
+ pyprojectMeta: pyproject,
533
+ fileManifest: buildFileManifest(dir),
534
+ branch,
535
+ baseVersionId,
536
+ ...opts.force ? { force: true } : {},
537
+ ...opts.message ? { changeReason: opts.message } : {},
538
+ ...opts.author ? { author: opts.author } : {}
539
+ });
540
+ if (version.uploadUrl) await putObject(version.uploadUrl, tarball, bundleSha256);
541
+ await apiRequest(
542
+ options,
543
+ "POST",
544
+ `/api/public/benchmark-containers/versions/${version.versionId}/finalize`,
545
+ { branch, baseVersionId, ...opts.force ? { force: true } : {} }
546
+ );
547
+ writeLocalMeta(dir, {
548
+ ...localMeta,
549
+ slug,
550
+ ref: branch,
551
+ branch,
552
+ versionId: version.versionId,
553
+ contentHash,
554
+ semanticVersion: pyproject.version,
555
+ forkedFromVersionId: baseVersionId,
556
+ baseFiles: snapshotTreeHashes(dir)
557
+ });
558
+ return { slug, versionId: version.versionId, contentHash, branch };
559
+ }
560
+ function extractBundle(bundle, dir) {
561
+ const tar = (0, import_node_zlib.gunzipSync)(bundle);
562
+ let offset = 0;
563
+ let longName = null;
564
+ let written = 0;
565
+ while (offset + 512 <= tar.length) {
566
+ const header = tar.subarray(offset, offset + 512);
567
+ offset += 512;
568
+ if (header.every((b) => b === 0)) break;
569
+ const rawName = header.subarray(0, 100).toString("utf-8").replace(/\0.*$/, "");
570
+ const size = parseInt(header.subarray(124, 136).toString("ascii").replace(/\0.*$/, "").trim(), 8) || 0;
571
+ const typeflag = header.subarray(156, 157).toString("ascii");
572
+ const body = tar.subarray(offset, offset + size);
573
+ offset += size + (size % 512 === 0 ? 0 : 512 - size % 512);
574
+ if (typeflag === "L") {
575
+ longName = body.toString("utf-8").replace(/\0.*$/, "");
576
+ continue;
577
+ }
578
+ const name = (longName ?? rawName).replace(/^\.\//, "");
579
+ longName = null;
580
+ if (typeflag !== "0" && typeflag !== "") continue;
581
+ if (name.startsWith("/") || name.split("/").includes("..")) continue;
582
+ const target = path.join(dir, name);
583
+ fs.mkdirSync(path.dirname(target), { recursive: true });
584
+ fs.writeFileSync(target, body);
585
+ written++;
586
+ }
587
+ return written;
588
+ }
589
+ async function pull(slugRef, target, options = {}) {
590
+ const at = slugRef.indexOf("@");
591
+ const slug = at === -1 ? slugRef : slugRef.slice(0, at);
592
+ const ref = at === -1 ? "latest" : slugRef.slice(at + 1);
593
+ const details = await apiRequest(options, "POST", "/api/public/benchmark-containers/resolve-version", {
594
+ slug,
595
+ ref
596
+ });
597
+ if (!details.downloadUrl) {
598
+ throw new Error(`${slug}@${ref} resolved but has no uploaded bundle`);
599
+ }
600
+ let dir = target ?? path.join(process.cwd(), slug);
601
+ if (!target) {
602
+ let i = 1;
603
+ const base = dir;
604
+ while (fs.existsSync(dir)) dir = `${base}-${i++}`;
605
+ }
606
+ fs.mkdirSync(dir, { recursive: true });
607
+ const resp = await fetch(details.downloadUrl);
608
+ if (!resp.ok) throw new Error(`bundle download -> ${resp.status}`);
609
+ const bundle = Buffer.from(await resp.arrayBuffer());
610
+ if (details.bundleSha256 && sha256b64(bundle) !== details.bundleSha256) {
611
+ throw new Error(
612
+ `bundle integrity check failed for ${slug}@${ref}: downloaded sha256 != recorded bundleSha256`
613
+ );
614
+ }
615
+ const files = extractBundle(bundle, dir);
616
+ const branch = ref === "latest" || /^\d|^[0-9a-f]{8,}$/.test(ref) ? DEFAULT_BRANCH : ref;
617
+ writeLocalMeta(dir, {
618
+ slug,
619
+ ref,
620
+ branch,
621
+ versionId: details.versionId,
622
+ contentHash: details.contentHash,
623
+ semanticVersion: details.semanticVersion ?? void 0,
624
+ baseFiles: snapshotTreeHashes(dir)
625
+ });
626
+ return { slug, dir, versionId: details.versionId, files };
627
+ }
628
+ async function propose(dir, opts) {
629
+ const meta = readLocalMeta(dir);
630
+ if (!meta?.slug || !meta.baseFiles) {
631
+ throw new Error("This dir has no pull/push base \u2014 run pull first, then edit, then propose.");
632
+ }
633
+ const state2 = localTreeState(dir);
634
+ if (state2.clean) throw new Error("Nothing to propose \u2014 the tree matches its base.");
635
+ const changes = state2.dirty.map((relPath) => {
636
+ const abs = path.join(dir, relPath);
637
+ if (!fs.existsSync(abs)) return { path: relPath, action: "delete" };
638
+ return {
639
+ path: relPath,
640
+ action: "write",
641
+ newContent: fs.readFileSync(abs, "utf-8")
642
+ };
643
+ });
644
+ const res = await apiRequest(
645
+ opts.options ?? {},
646
+ "POST",
647
+ "/api/public/benchmark-containers/proposals",
648
+ {
649
+ slug: meta.slug,
650
+ title: opts.title,
651
+ changeReason: opts.reason,
652
+ baseVersionId: meta.versionId,
653
+ ...opts.targetBranch ? { targetBranch: opts.targetBranch } : {},
654
+ changes
655
+ }
656
+ );
657
+ return res;
658
+ }
659
+ async function createRef(slug, name, kind, versionId, options = {}) {
660
+ return apiRequest(options, "POST", "/api/public/benchmark-containers/refs", {
661
+ slug,
662
+ name,
663
+ kind,
664
+ ...versionId ? { versionId } : {}
665
+ });
666
+ }
667
+ var import_node_crypto, import_node_zlib, fs, path, DEFAULT_BRANCH, META_RELPATH, SKIP_DIRS, ROOT_EXCLUDED_DIRS, sha256b64;
668
+ var init_hub = __esm({
669
+ "src/worlds/hub.ts"() {
670
+ "use strict";
671
+ import_node_crypto = require("crypto");
672
+ import_node_zlib = require("zlib");
673
+ fs = __toESM(require("fs"));
674
+ path = __toESM(require("path"));
675
+ init_worlds();
676
+ DEFAULT_BRANCH = "main";
677
+ META_RELPATH = path.join(".gateway", ".env-metadata.json");
678
+ SKIP_DIRS = /* @__PURE__ */ new Set([
679
+ ".git",
680
+ "__pycache__",
681
+ "node_modules",
682
+ ".venv",
683
+ ".mypy_cache",
684
+ "dist",
685
+ "build",
686
+ "outputs"
687
+ ]);
688
+ ROOT_EXCLUDED_DIRS = /* @__PURE__ */ new Set(["dist", "build", "outputs", "__pycache__"]);
689
+ sha256b64 = (data) => (0, import_node_crypto.createHash)("sha256").update(data).digest("base64");
690
+ }
691
+ });
692
+
693
+ // src/worlds/validate.ts
694
+ function fmtScore(score) {
695
+ return score === null ? "no score" : score.toFixed(3);
696
+ }
697
+ function buildMarkdown(report, minScore) {
698
+ const lines = [];
699
+ lines.push(
700
+ `### World validation ${report.ok ? "passed" : "failed"} \u2014 \`${report.slug}@${report.branch}\``
701
+ );
702
+ lines.push("");
703
+ lines.push(
704
+ `Ran the pull request's own world source (version \`${report.contentHash.slice(0, 12)}\`) through run config **${report.runConfig.name}**` + (minScore !== null ? `, gating at score \u2265 ${minScore}.` : ".")
705
+ );
706
+ lines.push("");
707
+ lines.push("| Model | Status | Score | Run |");
708
+ lines.push("| --- | --- | ---: | --- |");
709
+ for (const run of report.runs) {
710
+ const r = run.report;
711
+ const link = r?.url ? `[open](${r.url})` : "\u2014";
712
+ const status = run.failure ? `\u274C ${run.failure}` : `\u2705 ${r?.status ?? "COMPLETED"}`;
713
+ lines.push(
714
+ `| \`${run.model}\` | ${status} | ${fmtScore(r?.score ?? null)} | ${link} |`
715
+ );
716
+ }
717
+ const taskRows = report.runs.flatMap(
718
+ (run) => (run.report?.samples ?? []).map((sample) => ({
719
+ model: run.model,
720
+ task: sample.task ?? "?",
721
+ reward: sample.reward
722
+ }))
723
+ );
724
+ if (taskRows.length > 0 && taskRows.length <= 40) {
725
+ lines.push("");
726
+ lines.push("<details><summary>Per-task rewards</summary>");
727
+ lines.push("");
728
+ lines.push("| Task | Model | Reward |");
729
+ lines.push("| --- | --- | ---: |");
730
+ for (const row of taskRows) {
731
+ lines.push(
732
+ `| ${row.task} | \`${row.model}\` | ${row.reward === null ? "no score" : row.reward.toFixed(2)} |`
733
+ );
734
+ }
735
+ lines.push("");
736
+ lines.push("</details>");
737
+ }
738
+ return lines.join("\n");
739
+ }
740
+ async function validateWorld(dir, opts) {
741
+ const options = opts.options ?? {};
742
+ const progress = opts.onProgress ?? (() => {
743
+ });
744
+ const minScore = opts.minScore ?? null;
745
+ const provenance = detectProvenance();
746
+ const branch = opts.branch ?? provenance.branch;
747
+ if (!branch)
748
+ throw new Error(
749
+ "No branch to validate on: pass --branch or run inside a git checkout / GitHub Actions."
750
+ );
751
+ progress(`pushing ${dir} as ${opts.slug ?? "(pyproject name)"}@${branch}\u2026`);
752
+ const pushed = await push(dir, {
753
+ slug: opts.slug,
754
+ branch,
755
+ message: `PR validation push (${provenance.commit?.slice(0, 12) ?? "local"})`,
756
+ ...provenance.actor?.name ? { author: provenance.actor.name } : {},
757
+ options
758
+ });
759
+ progress(`pushed version ${pushed.versionId} (${pushed.contentHash.slice(0, 12)})`);
760
+ const configs = await listRunConfigs(options);
761
+ const runConfig = configs.find((c) => c.id === opts.runConfig) ?? configs.find((c) => c.name === opts.runConfig);
762
+ if (!runConfig) {
763
+ const known = configs.map((c) => c.name).join(", ") || "(none)";
764
+ throw new Error(
765
+ `Run config "${opts.runConfig}" not found in this project. Have: ${known}`
766
+ );
767
+ }
768
+ progress(`dispatching run config "${runConfig.name}" (${runConfig.models.join(", ")})\u2026`);
769
+ const dispatched = await apiRequest(options, "POST", "/api/public/benchmark-containers/run-configs/dispatch", {
770
+ runConfigId: runConfig.id,
771
+ versionId: pushed.versionId,
772
+ ...provenance
773
+ });
774
+ const host = (options.host ?? process.env.GATEWAY_HOST ?? "https://withgateway.ai").replace(/\/+$/, "");
775
+ let projectId = null;
776
+ try {
777
+ const projects = await apiRequest(
778
+ options,
779
+ "GET",
780
+ "/api/public/projects"
781
+ );
782
+ projectId = projects.data?.[0]?.id ?? null;
783
+ } catch {
784
+ projectId = null;
785
+ }
786
+ const fallbackUrl = (report) => {
787
+ if (report.url) return report.url;
788
+ const evaluationId = report.evaluations[0]?.id;
789
+ return projectId && evaluationId ? `${host}/project/${projectId}/environment/runs/${encodeURIComponent(evaluationId)}` : null;
790
+ };
791
+ const runs = [];
792
+ for (const run of dispatched.runs) {
793
+ if (!run.ok) {
794
+ runs.push({
795
+ model: run.model,
796
+ runId: run.runId,
797
+ report: null,
798
+ failure: `dispatch failed: ${run.error ?? "unknown error"}`
799
+ });
800
+ continue;
801
+ }
802
+ progress(`waiting on ${run.model} (run ${run.runId})\u2026`);
803
+ let report = null;
804
+ let failure = null;
805
+ try {
806
+ report = await waitForRun(run.runId, {
807
+ timeoutMinutes: opts.timeoutMinutes ?? 45,
808
+ options,
809
+ onTick: (r) => progress(
810
+ `\u2026${run.model}: ${r.status.toLowerCase()} (${r.shardsCompleted ?? 0}/${r.parallelism} shards)`
811
+ )
812
+ });
813
+ report = { ...report, url: fallbackUrl(report) };
814
+ if (report.status.toUpperCase() !== "COMPLETED") {
815
+ failure = report.status;
816
+ } else if (minScore !== null) {
817
+ if (report.score === null) failure = "completed without a score";
818
+ else if (report.score < minScore)
819
+ failure = `score ${fmtScore(report.score)} < ${minScore}`;
820
+ }
821
+ } catch (error) {
822
+ failure = error instanceof Error ? error.message : String(error);
823
+ }
824
+ runs.push({ model: run.model, runId: run.runId, report, failure });
825
+ }
826
+ const base = {
827
+ ok: runs.length > 0 && runs.every((r) => r.failure === null),
828
+ slug: pushed.slug,
829
+ branch,
830
+ versionId: pushed.versionId,
831
+ contentHash: pushed.contentHash,
832
+ runConfig: { id: runConfig.id, name: runConfig.name },
833
+ runs
834
+ };
835
+ return { ...base, markdown: buildMarkdown(base, minScore) };
836
+ }
837
+ var init_validate = __esm({
838
+ "src/worlds/validate.ts"() {
839
+ "use strict";
840
+ init_worlds();
841
+ init_hub();
842
+ }
843
+ });
844
+
321
845
  // src/worlds/index.ts
322
846
  var worlds_exports = {};
323
847
  __export(worlds_exports, {
848
+ DEFAULT_BRANCH: () => DEFAULT_BRANCH,
324
849
  WorldSession: () => WorldSession,
325
850
  WorldSessionCallError: () => WorldSessionCallError,
326
851
  WorldSessionTimeout: () => WorldSessionTimeout,
@@ -328,17 +853,30 @@ __export(worlds_exports, {
328
853
  WorldTask: () => WorldTask,
329
854
  apiRequest: () => apiRequest,
330
855
  attachSession: () => attachSession,
856
+ buildSourceTarball: () => buildSourceTarball,
857
+ collectArchiveRelPaths: () => collectArchiveRelPaths,
858
+ computeContentHash: () => computeContentHash,
859
+ createRef: () => createRef,
331
860
  deleteEnvSecret: () => deleteEnvSecret,
332
861
  detectProvenance: () => detectProvenance,
333
862
  getRun: () => getRun,
863
+ isIncludedInContentHash: () => isIncludedInContentHash,
334
864
  listEnvSecretKeys: () => listEnvSecretKeys,
335
865
  listRunConfigs: () => listRunConfigs,
866
+ localTreeState: () => localTreeState,
336
867
  openSession: () => openSession,
337
868
  openWorld: () => openWorld,
869
+ propose: () => propose,
870
+ pull: () => pull,
871
+ push: () => push,
872
+ readLocalMeta: () => readLocalMeta,
338
873
  runSessions: () => runSessions,
339
874
  schemaFromSignature: () => schemaFromSignature,
340
875
  setEnvSecret: () => setEnvSecret,
341
- waitForRun: () => waitForRun
876
+ snapshotTreeHashes: () => snapshotTreeHashes,
877
+ validateWorld: () => validateWorld,
878
+ waitForRun: () => waitForRun,
879
+ writeLocalMeta: () => writeLocalMeta
342
880
  });
343
881
  function resolveEnv(options) {
344
882
  const host = options.host ?? process.env.GATEWAY_HOST ?? "https://withgateway.ai";
@@ -351,9 +889,9 @@ function resolveEnv(options) {
351
889
  }
352
890
  return { host: host.replace(/\/+$/, ""), publicKey, secretKey };
353
891
  }
354
- async function apiRequest(options, method, path, body) {
892
+ async function apiRequest(options, method, path2, body) {
355
893
  const { host, publicKey, secretKey } = resolveEnv(options);
356
- const res = await fetch(`${host}${path}`, {
894
+ const res = await fetch(`${host}${path2}`, {
357
895
  method,
358
896
  headers: {
359
897
  "content-type": "application/json",
@@ -364,7 +902,7 @@ async function apiRequest(options, method, path, body) {
364
902
  const text = await res.text();
365
903
  if (!res.ok) {
366
904
  throw new Error(
367
- `${method} ${path} -> ${res.status}: ${text.slice(0, 400)}`
905
+ `${method} ${path2} -> ${res.status}: ${text.slice(0, 400)}`
368
906
  );
369
907
  }
370
908
  return JSON.parse(text);
@@ -426,7 +964,7 @@ async function waitForRun(runId, opts = {}) {
426
964
  );
427
965
  opts.onTick?.(run);
428
966
  await new Promise(
429
- (resolve) => setTimeout(resolve, (opts.intervalSeconds ?? 20) * 1e3)
967
+ (resolve2) => setTimeout(resolve2, (opts.intervalSeconds ?? 20) * 1e3)
430
968
  );
431
969
  }
432
970
  }
@@ -501,6 +1039,8 @@ var init_worlds = __esm({
501
1039
  "src/worlds/index.ts"() {
502
1040
  "use strict";
503
1041
  init_session();
1042
+ init_hub();
1043
+ init_validate();
504
1044
  WorldTask = class {
505
1045
  constructor(world, name, variant) {
506
1046
  this.world = world;
@@ -568,7 +1108,7 @@ var require_package = __commonJS({
568
1108
  "package.json"(exports2, module2) {
569
1109
  module2.exports = {
570
1110
  name: "@withgateway/sdk",
571
- version: "0.1.14",
1111
+ version: "0.1.17",
572
1112
  description: "Gateway SDK for TypeScript - A/B experiments, tracing, and observability",
573
1113
  main: "./dist/index.js",
574
1114
  module: "./dist/index.mjs",
@@ -739,6 +1279,7 @@ var require_package = __commonJS({
739
1279
  var src_exports = {};
740
1280
  __export(src_exports, {
741
1281
  AGENT_ID_KEY: () => AGENT_ID_KEY,
1282
+ DEFAULT_BRANCH: () => DEFAULT_BRANCH,
742
1283
  DEFAULT_TIMEOUT_SECONDS: () => DEFAULT_TIMEOUT_SECONDS,
743
1284
  DriftError: () => DriftError,
744
1285
  ENV_GATEWAY_HOST: () => ENV_GATEWAY_HOST,
@@ -791,11 +1332,15 @@ __export(src_exports, {
791
1332
  assignVariant: () => assignVariant,
792
1333
  attachSession: () => attachSession,
793
1334
  basicAuthHeader: () => basicAuthHeader,
1335
+ buildSourceTarball: () => buildSourceTarball,
794
1336
  canonicalJson: () => canonicalJson,
795
1337
  clearExperimentContext: () => clearExperimentContext,
1338
+ collectArchiveRelPaths: () => collectArchiveRelPaths,
796
1339
  computeBuildHash: () => computeBuildHash,
1340
+ computeContentHash: () => computeContentHash,
797
1341
  computeHash: () => computeHash,
798
1342
  context: () => context,
1343
+ createRef: () => createRef,
799
1344
  currentTraceId: () => currentTraceId,
800
1345
  defineTool: () => defineTool,
801
1346
  deleteEnvSecret: () => deleteEnvSecret,
@@ -810,13 +1355,19 @@ __export(src_exports, {
810
1355
  getRegisteredTools: () => getRegisteredTools,
811
1356
  getRun: () => getRun,
812
1357
  identify: () => identify,
1358
+ isIncludedInContentHash: () => isIncludedInContentHash,
813
1359
  listEnvSecretKeys: () => listEnvSecretKeys,
814
1360
  listRunConfigs: () => listRunConfigs,
815
1361
  loadSession: () => loadSession,
1362
+ localTreeState: () => localTreeState,
816
1363
  memory: () => memory,
817
1364
  openSession: () => openSession,
818
1365
  openWorld: () => openWorld,
819
1366
  personas: () => personas,
1367
+ propose: () => propose,
1368
+ pull: () => pull,
1369
+ push: () => push,
1370
+ readLocalMeta: () => readLocalMeta,
820
1371
  registerArtifact: () => registerArtifact,
821
1372
  registerPrompt: () => registerPrompt,
822
1373
  registerSkill: () => registerSkill,
@@ -833,11 +1384,14 @@ __export(src_exports, {
833
1384
  sessions: () => sessions,
834
1385
  setEnvSecret: () => setEnvSecret,
835
1386
  setExperimentContext: () => setExperimentContext,
1387
+ snapshotTreeHashes: () => snapshotTreeHashes,
836
1388
  success: () => success,
837
1389
  suite: () => suite,
838
1390
  tracing: () => tracing,
839
1391
  users: () => users,
840
- waitForRun: () => waitForRun
1392
+ validateWorld: () => validateWorld,
1393
+ waitForRun: () => waitForRun,
1394
+ writeLocalMeta: () => writeLocalMeta
841
1395
  });
842
1396
  module.exports = __toCommonJS(src_exports);
843
1397
 
@@ -1411,8 +1965,8 @@ var GatewayContext = class _GatewayContext {
1411
1965
  }
1412
1966
  return resolved;
1413
1967
  }
1414
- async requestJson(method, path, payload) {
1415
- const response = await fetch(`${this.host}${path}`, {
1968
+ async requestJson(method, path2, payload) {
1969
+ const response = await fetch(`${this.host}${path2}`, {
1416
1970
  method,
1417
1971
  headers: {
1418
1972
  Authorization: this.authHeader(),
@@ -1423,7 +1977,7 @@ var GatewayContext = class _GatewayContext {
1423
1977
  const text = await response.text();
1424
1978
  const body = text ? safeJson(text) : {};
1425
1979
  if (!response.ok) {
1426
- const message = typeof body.message === "string" ? body.message : `Gateway API ${response.status} on ${path}`;
1980
+ const message = typeof body.message === "string" ? body.message : `Gateway API ${response.status} on ${path2}`;
1427
1981
  if (response.status === 409) {
1428
1982
  throw new GatewayContextConflictError(
1429
1983
  message,
@@ -1432,7 +1986,7 @@ var GatewayContext = class _GatewayContext {
1432
1986
  }
1433
1987
  throw new GatewayContextError(message);
1434
1988
  }
1435
- this.log("%s %s -> %s", method, path, response.status);
1989
+ this.log("%s %s -> %s", method, path2, response.status);
1436
1990
  return body;
1437
1991
  }
1438
1992
  authHeader() {
@@ -1539,11 +2093,11 @@ function primaryPathForKind(kind, snapshot) {
1539
2093
  const preferred = kind === "agent" ? "AGENTS.md" : kind === "prompt" ? "PROMPT.md" : kind === "skill" ? "SKILL.md" : "MEMORY.md";
1540
2094
  if (readFile(snapshot, preferred)) return preferred;
1541
2095
  return Object.entries(snapshot.files).find(
1542
- ([path, entry]) => entry.type === "file" && path.endsWith(".md")
2096
+ ([path2, entry]) => entry.type === "file" && path2.endsWith(".md")
1543
2097
  )?.[0] ?? null;
1544
2098
  }
1545
- function parseJsonFile(snapshot, path) {
1546
- const content = readFile(snapshot, path);
2099
+ function parseJsonFile(snapshot, path2) {
2100
+ const content = readFile(snapshot, path2);
1547
2101
  if (!content) return {};
1548
2102
  try {
1549
2103
  const parsed = JSON.parse(content);
@@ -1552,8 +2106,8 @@ function parseJsonFile(snapshot, path) {
1552
2106
  return {};
1553
2107
  }
1554
2108
  }
1555
- function readFile(snapshot, path) {
1556
- const entry = snapshot.files[path];
2109
+ function readFile(snapshot, path2) {
2110
+ const entry = snapshot.files[path2];
1557
2111
  return entry?.type === "file" ? entry.content : null;
1558
2112
  }
1559
2113
  function provenanceFor(snapshot, label) {
@@ -1655,16 +2209,16 @@ var GatewayMemory = class _GatewayMemory {
1655
2209
  `/api/public/context/memory/${encodeIdentifier2(identifier)}${suffix}`
1656
2210
  );
1657
2211
  }
1658
- async read(target, path, options = {}) {
2212
+ async read(target, path2, options = {}) {
1659
2213
  const snapshot = typeof target === "string" ? await this.pull(target, options) : target;
1660
- const file = snapshot.files[path];
2214
+ const file = snapshot.files[path2];
1661
2215
  return file?.type === "file" ? file.content : null;
1662
2216
  }
1663
- async write(target, path, content, options = {}) {
2217
+ async write(target, path2, content, options = {}) {
1664
2218
  const snapshot = typeof target === "string" ? await this.pull(target) : target;
1665
2219
  return this.push(snapshot.repo.repoHandle, {
1666
2220
  files: {
1667
- [path]: {
2221
+ [path2]: {
1668
2222
  content,
1669
2223
  ...options.mimeType ? { mimeType: options.mimeType } : {}
1670
2224
  }
@@ -1674,10 +2228,10 @@ var GatewayMemory = class _GatewayMemory {
1674
2228
  ...runtimeContextPayload2(options)
1675
2229
  });
1676
2230
  }
1677
- async delete(target, path, options = {}) {
2231
+ async delete(target, path2, options = {}) {
1678
2232
  const snapshot = typeof target === "string" ? await this.pull(target) : target;
1679
2233
  return this.push(snapshot.repo.repoHandle, {
1680
- files: { [path]: null },
2234
+ files: { [path2]: null },
1681
2235
  parentCommit: options.parentCommit ?? snapshot.commit.commitHash,
1682
2236
  message: options.message,
1683
2237
  ...runtimeContextPayload2(options)
@@ -1690,8 +2244,8 @@ var GatewayMemory = class _GatewayMemory {
1690
2244
  payload
1691
2245
  );
1692
2246
  }
1693
- async requestJson(method, path, payload) {
1694
- const response = await fetch(`${this.host}${path}`, {
2247
+ async requestJson(method, path2, payload) {
2248
+ const response = await fetch(`${this.host}${path2}`, {
1695
2249
  method,
1696
2250
  headers: {
1697
2251
  Authorization: this.authHeader(),
@@ -1702,7 +2256,7 @@ var GatewayMemory = class _GatewayMemory {
1702
2256
  const text = await response.text();
1703
2257
  const body = text ? safeJson2(text) : {};
1704
2258
  if (!response.ok) {
1705
- const message = typeof body.message === "string" ? body.message : `Gateway API ${response.status} on ${path}`;
2259
+ const message = typeof body.message === "string" ? body.message : `Gateway API ${response.status} on ${path2}`;
1706
2260
  if (response.status === 409) {
1707
2261
  throw new GatewayMemoryConflictError(
1708
2262
  message,
@@ -1711,7 +2265,7 @@ var GatewayMemory = class _GatewayMemory {
1711
2265
  }
1712
2266
  throw new GatewayMemoryError(message);
1713
2267
  }
1714
- this.log("%s %s -> %s", method, path, response.status);
2268
+ this.log("%s %s -> %s", method, path2, response.status);
1715
2269
  return body;
1716
2270
  }
1717
2271
  authHeader() {
@@ -1873,10 +2427,10 @@ var PersonasClient = class _PersonasClient {
1873
2427
  done: Boolean(payload.done)
1874
2428
  };
1875
2429
  }
1876
- async requestJson(method, path, payload) {
2430
+ async requestJson(method, path2, payload) {
1877
2431
  let response;
1878
2432
  try {
1879
- response = await fetch(`${this.host}${path}`, {
2433
+ response = await fetch(`${this.host}${path2}`, {
1880
2434
  method,
1881
2435
  headers: {
1882
2436
  Authorization: this.authHeader(),
@@ -1887,7 +2441,7 @@ var PersonasClient = class _PersonasClient {
1887
2441
  });
1888
2442
  } catch (error) {
1889
2443
  const reason = error instanceof Error ? error.message : String(error);
1890
- throw new PersonaError(`${method} ${path} failed: ${reason}`, {
2444
+ throw new PersonaError(`${method} ${path2} failed: ${reason}`, {
1891
2445
  cause: error
1892
2446
  });
1893
2447
  }
@@ -1895,10 +2449,10 @@ var PersonasClient = class _PersonasClient {
1895
2449
  if (!response.ok) {
1896
2450
  const detail = text.slice(0, 500);
1897
2451
  throw new PersonaError(
1898
- `${method} ${path} failed (${response.status}): ${detail}`
2452
+ `${method} ${path2} failed (${response.status}): ${detail}`
1899
2453
  );
1900
2454
  }
1901
- this.log("%s %s -> %s", method, path, response.status);
2455
+ this.log("%s %s -> %s", method, path2, response.status);
1902
2456
  return safeJson3(text);
1903
2457
  }
1904
2458
  authHeader() {
@@ -2123,10 +2677,10 @@ var SessionRecording = class _SessionRecording {
2123
2677
  };
2124
2678
  }
2125
2679
  /** Dump the full session as a JSON fixture (for regression tests). */
2126
- toFixture(path) {
2127
- (0, import_node_fs.mkdirSync)((0, import_node_path.dirname)(path), { recursive: true });
2128
- (0, import_node_fs.writeFileSync)(path, JSON.stringify(this.toJSON(), null, 2), "utf-8");
2129
- return path;
2680
+ toFixture(path2) {
2681
+ (0, import_node_fs.mkdirSync)((0, import_node_path.dirname)(path2), { recursive: true });
2682
+ (0, import_node_fs.writeFileSync)(path2, JSON.stringify(this.toJSON(), null, 2), "utf-8");
2683
+ return path2;
2130
2684
  }
2131
2685
  static fromApi(raw) {
2132
2686
  return new _SessionRecording({
@@ -2961,7 +3515,7 @@ function randomHex() {
2961
3515
  return crypto.randomUUID().replace(/-/g, "");
2962
3516
  }
2963
3517
  function sleep(ms) {
2964
- return new Promise((resolve) => setTimeout(resolve, ms));
3518
+ return new Promise((resolve2) => setTimeout(resolve2, ms));
2965
3519
  }
2966
3520
  var replay = {
2967
3521
  suite,
@@ -3048,7 +3602,7 @@ var GatewaySecurity = class _GatewaySecurity {
3048
3602
  const descriptors = entries.map(
3049
3603
  ([key, tool]) => this.describeTool(key, tool, options)
3050
3604
  );
3051
- const resolve = await this.resolveToolset({
3605
+ const resolve2 = await this.resolveToolset({
3052
3606
  agent: this.agent,
3053
3607
  toolsetId: options.toolsetId,
3054
3608
  toolsetName: options.toolsetName,
@@ -3058,8 +3612,8 @@ var GatewaySecurity = class _GatewaySecurity {
3058
3612
  });
3059
3613
  const securedEntries = entries.flatMap(([key, tool]) => {
3060
3614
  const descriptor = descriptors.find((item) => item.name === key);
3061
- if (!this.shouldExposeTool(resolve, descriptor.id)) {
3062
- this.log("Hiding tool %s in %s mode", descriptor.id, resolve.mode);
3615
+ if (!this.shouldExposeTool(resolve2, descriptor.id)) {
3616
+ this.log("Hiding tool %s in %s mode", descriptor.id, resolve2.mode);
3063
3617
  return [];
3064
3618
  }
3065
3619
  return [
@@ -3069,7 +3623,7 @@ var GatewaySecurity = class _GatewaySecurity {
3069
3623
  toolId: descriptor.id,
3070
3624
  toolsetId: options.toolsetId,
3071
3625
  context: this.normalizeContext(options.context),
3072
- resolve
3626
+ resolve: resolve2
3073
3627
  })
3074
3628
  ]
3075
3629
  ];
@@ -3157,8 +3711,8 @@ var GatewaySecurity = class _GatewaySecurity {
3157
3711
  );
3158
3712
  }
3159
3713
  }
3160
- async postJson(path, payload) {
3161
- const response = await fetch(`${this.host}${path}`, {
3714
+ async postJson(path2, payload) {
3715
+ const response = await fetch(`${this.host}${path2}`, {
3162
3716
  method: "POST",
3163
3717
  headers: {
3164
3718
  Authorization: this.authHeader(),
@@ -3169,7 +3723,7 @@ var GatewaySecurity = class _GatewaySecurity {
3169
3723
  if (!response.ok) {
3170
3724
  const body = await response.text();
3171
3725
  throw new GatewaySecurityError(
3172
- `Gateway API ${response.status} on ${path}: ${body || response.statusText}`
3726
+ `Gateway API ${response.status} on ${path2}: ${body || response.statusText}`
3173
3727
  );
3174
3728
  }
3175
3729
  return await response.json();
@@ -3184,9 +3738,9 @@ var GatewaySecurity = class _GatewaySecurity {
3184
3738
  metadata: options.toolMetadata?.[key] ?? {}
3185
3739
  };
3186
3740
  }
3187
- shouldExposeTool(resolve, toolId) {
3188
- if (resolve.mode === "observe") return true;
3189
- if (resolve.blockedToolIds.includes(toolId)) return false;
3741
+ shouldExposeTool(resolve2, toolId) {
3742
+ if (resolve2.mode === "observe") return true;
3743
+ if (resolve2.blockedToolIds.includes(toolId)) return false;
3190
3744
  return true;
3191
3745
  }
3192
3746
  normalizeContext(context4) {
@@ -3350,10 +3904,10 @@ var UsersClient = class _UsersClient {
3350
3904
  totalItems: Number(meta.totalItems ?? rows.length)
3351
3905
  };
3352
3906
  }
3353
- async requestJson(method, path, payload) {
3907
+ async requestJson(method, path2, payload) {
3354
3908
  let response;
3355
3909
  try {
3356
- response = await fetch(`${this.host}${path}`, {
3910
+ response = await fetch(`${this.host}${path2}`, {
3357
3911
  method,
3358
3912
  headers: {
3359
3913
  Authorization: this.authHeader(),
@@ -3364,17 +3918,17 @@ var UsersClient = class _UsersClient {
3364
3918
  });
3365
3919
  } catch (error) {
3366
3920
  throw new UserProfileError(
3367
- `${method} ${path} failed: ${error instanceof Error ? error.message : String(error)}`,
3921
+ `${method} ${path2} failed: ${error instanceof Error ? error.message : String(error)}`,
3368
3922
  { cause: error }
3369
3923
  );
3370
3924
  }
3371
3925
  const text = await response.text();
3372
3926
  if (!response.ok) {
3373
3927
  throw new UserProfileError(
3374
- `${method} ${path} failed (${response.status}): ${text.slice(0, 500)}`
3928
+ `${method} ${path2} failed (${response.status}): ${text.slice(0, 500)}`
3375
3929
  );
3376
3930
  }
3377
- this.log("%s %s -> %s", method, path, response.status);
3931
+ this.log("%s %s -> %s", method, path2, response.status);
3378
3932
  return safeJson4(text);
3379
3933
  }
3380
3934
  authHeader() {
@@ -3578,10 +4132,10 @@ var ScoresClient = class _ScoresClient {
3578
4132
  metadata: signalMetadata
3579
4133
  });
3580
4134
  }
3581
- async request(method, path, payload) {
4135
+ async request(method, path2, payload) {
3582
4136
  let response;
3583
4137
  try {
3584
- response = await fetch(`${this.host}${path}`, {
4138
+ response = await fetch(`${this.host}${path2}`, {
3585
4139
  method,
3586
4140
  headers: {
3587
4141
  Authorization: this.authHeader(),
@@ -3592,17 +4146,17 @@ var ScoresClient = class _ScoresClient {
3592
4146
  });
3593
4147
  } catch (error) {
3594
4148
  throw new ScoreError(
3595
- `${method} ${path} failed: ${error instanceof Error ? error.message : String(error)}`,
4149
+ `${method} ${path2} failed: ${error instanceof Error ? error.message : String(error)}`,
3596
4150
  { cause: error }
3597
4151
  );
3598
4152
  }
3599
4153
  const text = await response.text();
3600
4154
  if (!response.ok) {
3601
4155
  throw new ScoreError(
3602
- `${method} ${path} failed (${response.status}): ${text.slice(0, 500)}`
4156
+ `${method} ${path2} failed (${response.status}): ${text.slice(0, 500)}`
3603
4157
  );
3604
4158
  }
3605
- this.log("%s %s -> %s", method, path, response.status);
4159
+ this.log("%s %s -> %s", method, path2, response.status);
3606
4160
  }
3607
4161
  authHeader() {
3608
4162
  return `Basic ${Buffer.from(`${this.publicKey}:${this.secretKey}`).toString(
@@ -3644,7 +4198,7 @@ init_worlds();
3644
4198
  init_session();
3645
4199
 
3646
4200
  // src/build/index.ts
3647
- var import_node_crypto = require("crypto");
4201
+ var import_node_crypto2 = require("crypto");
3648
4202
  function canonicalJson(value) {
3649
4203
  if (value === null || typeof value !== "object") {
3650
4204
  return JSON.stringify(value);
@@ -3656,7 +4210,7 @@ function canonicalJson(value) {
3656
4210
  return `{${entries.map(([k, v]) => `${JSON.stringify(k)}:${canonicalJson(v)}`).join(",")}}`;
3657
4211
  }
3658
4212
  function sha256(text) {
3659
- return `sha256:${(0, import_node_crypto.createHash)("sha256").update(text).digest("hex")}`;
4213
+ return `sha256:${(0, import_node_crypto2.createHash)("sha256").update(text).digest("hex")}`;
3660
4214
  }
3661
4215
  var registeredTools = /* @__PURE__ */ new Map();
3662
4216
  var registeredPrompts = /* @__PURE__ */ new Map();
@@ -4525,6 +5079,7 @@ var tracing = {
4525
5079
  // Annotate the CommonJS export names for ESM import in node:
4526
5080
  0 && (module.exports = {
4527
5081
  AGENT_ID_KEY,
5082
+ DEFAULT_BRANCH,
4528
5083
  DEFAULT_TIMEOUT_SECONDS,
4529
5084
  DriftError,
4530
5085
  ENV_GATEWAY_HOST,
@@ -4577,11 +5132,15 @@ var tracing = {
4577
5132
  assignVariant,
4578
5133
  attachSession,
4579
5134
  basicAuthHeader,
5135
+ buildSourceTarball,
4580
5136
  canonicalJson,
4581
5137
  clearExperimentContext,
5138
+ collectArchiveRelPaths,
4582
5139
  computeBuildHash,
5140
+ computeContentHash,
4583
5141
  computeHash,
4584
5142
  context,
5143
+ createRef,
4585
5144
  currentTraceId,
4586
5145
  defineTool,
4587
5146
  deleteEnvSecret,
@@ -4596,13 +5155,19 @@ var tracing = {
4596
5155
  getRegisteredTools,
4597
5156
  getRun,
4598
5157
  identify,
5158
+ isIncludedInContentHash,
4599
5159
  listEnvSecretKeys,
4600
5160
  listRunConfigs,
4601
5161
  loadSession,
5162
+ localTreeState,
4602
5163
  memory,
4603
5164
  openSession,
4604
5165
  openWorld,
4605
5166
  personas,
5167
+ propose,
5168
+ pull,
5169
+ push,
5170
+ readLocalMeta,
4606
5171
  registerArtifact,
4607
5172
  registerPrompt,
4608
5173
  registerSkill,
@@ -4619,10 +5184,13 @@ var tracing = {
4619
5184
  sessions,
4620
5185
  setEnvSecret,
4621
5186
  setExperimentContext,
5187
+ snapshotTreeHashes,
4622
5188
  success,
4623
5189
  suite,
4624
5190
  tracing,
4625
5191
  users,
4626
- waitForRun
5192
+ validateWorld,
5193
+ waitForRun,
5194
+ writeLocalMeta
4627
5195
  });
4628
5196
  //# sourceMappingURL=index.js.map