@skydiveai/git-cache 0.1.252-beta.26 → 0.1.252-beta.28

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/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { f as startServer } from "./server-DVcqSwOQ.mjs";
2
+ import { f as startServer } from "./server-BEKSCDm3.mjs";
3
3
  //#region src/cli.ts
4
4
  /**
5
5
  * `git-cache` CLI — the published binary for @skydiveai/git-cache.
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { a as isProtocolV2Request, c as parseAdvertisement, d as shouldBackfillAfterPassthrough, f as startServer, i as explainRejection, l as parseUpstream, n as classifyUploadRequest, o as metricsSnapshot, r as copyRequestHeaders, s as mirrorHasObjects, t as SidebandPackExtractor, u as recordColdBuildOutcome } from "./server-DVcqSwOQ.mjs";
1
+ import { a as isProtocolV2Request, c as parseAdvertisement, d as shouldBackfillAfterPassthrough, f as startServer, i as explainRejection, l as parseUpstream, n as classifyUploadRequest, o as metricsSnapshot, r as copyRequestHeaders, s as mirrorHasObjects, t as SidebandPackExtractor, u as recordColdBuildOutcome } from "./server-BEKSCDm3.mjs";
2
2
  export { SidebandPackExtractor, classifyUploadRequest, copyRequestHeaders, explainRejection, isProtocolV2Request, metricsSnapshot, mirrorHasObjects, parseAdvertisement, parseUpstream, recordColdBuildOutcome, shouldBackfillAfterPassthrough, startServer };
@@ -1527,7 +1527,7 @@ function proxyUploadPackWithBody(res, upstreamUrl, reqHeaders, body, credHeader)
1527
1527
  });
1528
1528
  up.end(body);
1529
1529
  }
1530
- function serveUploadPack(req, res, local, advertise, cacheState, body = null) {
1530
+ function serveUploadPack(req, res, local, advertise, cacheState, body = null, detail = null) {
1531
1531
  const args = ["--stateless-rpc"];
1532
1532
  if (advertise) args.push("--advertise-refs");
1533
1533
  args.push(local);
@@ -1555,6 +1555,10 @@ function serveUploadPack(req, res, local, advertise, cacheState, body = null) {
1555
1555
  req.pipe(gunzip).pipe(child.stdin);
1556
1556
  } else req.pipe(child.stdin);
1557
1557
  child.stdout.pipe(res);
1558
+ let bytes = 0;
1559
+ child.stdout.on("data", (d) => {
1560
+ bytes += d.length;
1561
+ });
1558
1562
  let stderr = "";
1559
1563
  let finished = false;
1560
1564
  child.stderr.on("data", (d) => {
@@ -1567,6 +1571,10 @@ function serveUploadPack(req, res, local, advertise, cacheState, body = null) {
1567
1571
  code,
1568
1572
  stderr: stderr.trim()
1569
1573
  });
1574
+ if (detail) log("info", "serve_detail", {
1575
+ ...detail,
1576
+ bytes
1577
+ });
1570
1578
  if (!res.writableEnded) res.end();
1571
1579
  });
1572
1580
  res.on("close", () => {
@@ -1827,6 +1835,7 @@ async function handle(req, res) {
1827
1835
  const host = up.repo.split("/")[0] ?? "";
1828
1836
  let uploadBody = null;
1829
1837
  let uploadWants = [];
1838
+ let uploadVerdict = null;
1830
1839
  if (up.operation === "git-upload-pack") {
1831
1840
  try {
1832
1841
  uploadBody = await readBody(req, 16 * 1024 * 1024);
@@ -1842,7 +1851,8 @@ async function handle(req, res) {
1842
1851
  if (!res.headersSent) res.writeHead(400);
1843
1852
  return res.end("bad gzip body\n");
1844
1853
  }
1845
- uploadWants = classifyUploadRequest(uploadBody).wants;
1854
+ uploadVerdict = classifyUploadRequest(uploadBody);
1855
+ uploadWants = uploadVerdict.wants;
1846
1856
  }
1847
1857
  if (await pathExists(localPath(up.repo))) {
1848
1858
  const warm = await ensureWarm(up.repo, clientCred, up.operation === "info/refs");
@@ -1865,7 +1875,11 @@ async function handle(req, res) {
1865
1875
  });
1866
1876
  if (!await mirrorHasObjects(warm.local, uploadWants)) {
1867
1877
  metrics.passthrough_missing_want++;
1868
- log("info", "passthrough_missing_want", { repo: up.repo });
1878
+ log("info", "passthrough_missing_want", {
1879
+ repo: up.repo,
1880
+ eligibility: uploadVerdict ? uploadVerdict.reason : null,
1881
+ wants: uploadVerdict ? uploadVerdict.wants.length : null
1882
+ });
1869
1883
  const credHeader = clientCred ?? await fetchCredentialHeader(host);
1870
1884
  return proxyUploadPackWithBody(res, up.upstreamUrl, req.headers, uploadBody, credHeader);
1871
1885
  }
@@ -1873,9 +1887,17 @@ async function handle(req, res) {
1873
1887
  log("info", "serve", {
1874
1888
  repo: up.repo,
1875
1889
  op: up.operation,
1876
- state: warm.cacheState
1890
+ state: warm.cacheState,
1891
+ eligibility: uploadVerdict ? uploadVerdict.reason : null,
1892
+ wants: uploadVerdict ? uploadVerdict.wants.length : null
1893
+ });
1894
+ return serveUploadPack(req, res, warm.local, up.operation === "info/refs", warm.cacheState, uploadBody, {
1895
+ repo: up.repo,
1896
+ op: up.operation,
1897
+ state: warm.cacheState,
1898
+ eligibility: uploadVerdict ? uploadVerdict.reason : null,
1899
+ wants: uploadVerdict ? uploadVerdict.wants.length : null
1877
1900
  });
1878
- return serveUploadPack(req, res, warm.local, up.operation === "info/refs", warm.cacheState, uploadBody);
1879
1901
  }
1880
1902
  if (up.operation === "info/refs") return await proxyInfoRefs(req, res, up.repo, up.upstreamUrl, host, clientCred);
1881
1903
  const body = uploadBody ?? Buffer.alloc(0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skydiveai/git-cache",
3
- "version": "0.1.252-beta.26",
3
+ "version": "0.1.252-beta.28",
4
4
  "description": "Sandbox-local Git smart-HTTP clone/fetch cache: a loopback daemon that transparently mirrors HTTPS git reads so repeated clone/fetch/ls-remote skip the origin round-trip. Runs inside an agent sandbox; pushes stay direct.",
5
5
  "homepage": "https://skydive.com",
6
6
  "license": "MIT",