replicas-engine 0.1.574 → 0.1.575

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 (2) hide show
  1. package/dist/src/index.js +49 -8
  2. package/package.json +1 -1
package/dist/src/index.js CHANGED
@@ -785,10 +785,39 @@ function parsePosixEnvFile(content) {
785
785
 
786
786
  // ../shared/src/git.ts
787
787
  var GIT_CREDENTIAL_HELPER_FILENAME = ".git-credential-replicas";
788
+ var GITLAB_CREDENTIAL_REFRESH_PATH = "/git-credentials/gitlab/refresh";
788
789
  function buildGitCredentialHelperScript(credentialsPath) {
789
790
  return `#!/bin/sh
791
+ request=$(cat)
792
+
793
+ get_credential() {
794
+ printf '%s
795
+ ' "$request" | git credential-store --file=${shellQuotePosix(credentialsPath)} get
796
+ }
797
+
798
+ refresh_gitlab_credential() {
799
+ [ -n "\${REPLICAS_ENGINE_SECRET:-}" ] || return 1
800
+ command -v curl >/dev/null 2>&1 || return 1
801
+ curl --silent --fail --connect-timeout 1 --max-time 5 -X POST -H "X-Replicas-Engine-Secret: $REPLICAS_ENGINE_SECRET" "http://127.0.0.1:\${REPLICAS_ENGINE_PORT:-3737}${GITLAB_CREDENTIAL_REFRESH_PATH}" >/dev/null 2>&1
802
+ }
803
+
790
804
  if [ "$1" = "get" ]; then
791
- exec git credential-store --file=${shellQuotePosix(credentialsPath)} get
805
+ credential=$(get_credential)
806
+ if printf '%s
807
+ %s
808
+ ' "$request" "$credential" | grep -q '^username=oauth2$'; then
809
+ if refresh_gitlab_credential; then
810
+ refreshed_credential=$(get_credential)
811
+ if [ -n "$refreshed_credential" ]; then
812
+ credential=$refreshed_credential
813
+ fi
814
+ fi
815
+ fi
816
+ printf '%s
817
+ ' "$credential"
818
+ elif [ "$1" = "erase" ] && printf '%s
819
+ ' "$request" | grep -q '^username=oauth2$'; then
820
+ refresh_gitlab_credential || true
792
821
  fi
793
822
  exit 0
794
823
  `;
@@ -5756,21 +5785,23 @@ var BaseRefreshManager = class {
5756
5785
  }
5757
5786
  async refreshOnce() {
5758
5787
  if (this.getSkipReason()) {
5759
- return;
5788
+ return createSuccessResult();
5760
5789
  }
5761
5790
  const config = this.getRuntimeConfig();
5762
- if (!config) return;
5791
+ if (!config) return createSuccessResult();
5763
5792
  this.health.lastAttemptAt = (/* @__PURE__ */ new Date()).toISOString();
5764
5793
  try {
5765
5794
  await this.doRefresh(config);
5766
5795
  this.health.lastSuccessAt = (/* @__PURE__ */ new Date()).toISOString();
5767
5796
  this.health.lastErrorAt = null;
5768
5797
  this.health.lastErrorMessage = null;
5798
+ return createSuccessResult();
5769
5799
  } catch (error) {
5770
5800
  const message = error instanceof Error ? error.message : "Unknown error";
5771
5801
  this.health.lastErrorAt = (/* @__PURE__ */ new Date()).toISOString();
5772
5802
  this.health.lastErrorMessage = message;
5773
5803
  console.error(`[${this.managerName}] Failed to refresh credentials:`, error);
5804
+ return createErrorResult({ message });
5774
5805
  }
5775
5806
  }
5776
5807
  };
@@ -10823,7 +10854,7 @@ var DEFAULT_CODEX_ARGS = ["app-server", "--listen", "stdio://"];
10823
10854
  var MIN_CODEX_CLI_VERSION = "0.144.6";
10824
10855
  var CODEX_UPGRADE_TIMEOUT_MS = 12e4;
10825
10856
  var codexCliVersionEnsured = null;
10826
- var ENGINE_PACKAGE_VERSION = "0.1.574";
10857
+ var ENGINE_PACKAGE_VERSION = "0.1.575";
10827
10858
  var INITIALIZE_METHOD = "initialize";
10828
10859
  var INITIALIZED_NOTIFICATION = "initialized";
10829
10860
  var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
@@ -18100,14 +18131,14 @@ data: ${JSON.stringify("Terminal session not found")}
18100
18131
  });
18101
18132
  app2.post("/codex/refresh-now", async (c) => {
18102
18133
  try {
18103
- await codexTokenManager.refreshOnce();
18104
- const status = codexTokenManager.getHealthStatus();
18105
- if (status.lastErrorAt && (!status.lastSuccessAt || status.lastErrorAt > status.lastSuccessAt)) {
18134
+ const result = await codexTokenManager.refreshOnce();
18135
+ if (!result.ok) {
18106
18136
  return c.json(
18107
- jsonError("Failed to refresh Codex credentials", status.lastErrorMessage ?? "Unknown error"),
18137
+ jsonError("Failed to refresh Codex credentials", result.error.message),
18108
18138
  502
18109
18139
  );
18110
18140
  }
18141
+ const status = codexTokenManager.getHealthStatus();
18111
18142
  return c.json({ success: true, lastSuccessAt: status.lastSuccessAt });
18112
18143
  } catch (error) {
18113
18144
  return c.json(
@@ -18658,6 +18689,16 @@ app.get("/token-refresh/health", async (c) => {
18658
18689
  infisical: infisicalTokenManager.getHealthStatus()
18659
18690
  });
18660
18691
  });
18692
+ app.post(GITLAB_CREDENTIAL_REFRESH_PATH, async (c) => {
18693
+ const result = await gitlabTokenManager.refreshOnce();
18694
+ if (!result.ok) {
18695
+ return c.json({
18696
+ error: "Failed to refresh GitLab credentials",
18697
+ details: result.error.message
18698
+ }, 502);
18699
+ }
18700
+ return c.body(null, 204);
18701
+ });
18661
18702
  var repoFileService = new RepoFileService(gitService);
18662
18703
  app.route("/", createV1Routes({ chatService, repoFileService }));
18663
18704
  var port = ENGINE_ENV.REPLICAS_ENGINE_PORT;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.574",
3
+ "version": "0.1.575",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",