replicas-engine 0.1.574 → 0.1.576
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/src/index.js +58 -17
- 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
|
-
|
|
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
|
`;
|
|
@@ -5516,6 +5545,14 @@ var MAX_ENGINE_LOG_BYTES = 50 * 1024 * 1024;
|
|
|
5516
5545
|
|
|
5517
5546
|
// ../shared/src/skill-registry.ts
|
|
5518
5547
|
var SKILL_REGISTRY_MANIFEST_VERSION = 1;
|
|
5548
|
+
function isSkillRegistryManifest(value) {
|
|
5549
|
+
if (typeof value !== "object" || value === null) return false;
|
|
5550
|
+
if (!("version" in value) || value.version !== SKILL_REGISTRY_MANIFEST_VERSION) return false;
|
|
5551
|
+
if (!("registries" in value) || !Array.isArray(value.registries)) return false;
|
|
5552
|
+
return value.registries.every(
|
|
5553
|
+
(entry) => typeof entry === "object" && entry !== null && "index" in entry && typeof entry.index === "number" && "name" in entry && typeof entry.name === "string" && "url" in entry && typeof entry.url === "string" && "checkoutPath" in entry && typeof entry.checkoutPath === "string"
|
|
5554
|
+
);
|
|
5555
|
+
}
|
|
5519
5556
|
|
|
5520
5557
|
// src/index.ts
|
|
5521
5558
|
import { randomUUID as randomUUID8 } from "crypto";
|
|
@@ -5756,21 +5793,23 @@ var BaseRefreshManager = class {
|
|
|
5756
5793
|
}
|
|
5757
5794
|
async refreshOnce() {
|
|
5758
5795
|
if (this.getSkipReason()) {
|
|
5759
|
-
return;
|
|
5796
|
+
return createSuccessResult();
|
|
5760
5797
|
}
|
|
5761
5798
|
const config = this.getRuntimeConfig();
|
|
5762
|
-
if (!config) return;
|
|
5799
|
+
if (!config) return createSuccessResult();
|
|
5763
5800
|
this.health.lastAttemptAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
5764
5801
|
try {
|
|
5765
5802
|
await this.doRefresh(config);
|
|
5766
5803
|
this.health.lastSuccessAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
5767
5804
|
this.health.lastErrorAt = null;
|
|
5768
5805
|
this.health.lastErrorMessage = null;
|
|
5806
|
+
return createSuccessResult();
|
|
5769
5807
|
} catch (error) {
|
|
5770
5808
|
const message = error instanceof Error ? error.message : "Unknown error";
|
|
5771
5809
|
this.health.lastErrorAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
5772
5810
|
this.health.lastErrorMessage = message;
|
|
5773
5811
|
console.error(`[${this.managerName}] Failed to refresh credentials:`, error);
|
|
5812
|
+
return createErrorResult({ message });
|
|
5774
5813
|
}
|
|
5775
5814
|
}
|
|
5776
5815
|
};
|
|
@@ -9248,7 +9287,7 @@ async function readManifest(homeDir) {
|
|
|
9248
9287
|
try {
|
|
9249
9288
|
const raw = await readFile8(getManifestPath(homeDir), "utf8");
|
|
9250
9289
|
const parsed = JSON.parse(raw);
|
|
9251
|
-
if (!
|
|
9290
|
+
if (!isSkillRegistryManifest(parsed)) {
|
|
9252
9291
|
console.warn("[SkillRegistry] Ignoring invalid skill registry manifest.");
|
|
9253
9292
|
return null;
|
|
9254
9293
|
}
|
|
@@ -9258,14 +9297,6 @@ async function readManifest(homeDir) {
|
|
|
9258
9297
|
throw error;
|
|
9259
9298
|
}
|
|
9260
9299
|
}
|
|
9261
|
-
function isManifest(value) {
|
|
9262
|
-
if (typeof value !== "object" || value === null) return false;
|
|
9263
|
-
return "version" in value && value.version === SKILL_REGISTRY_MANIFEST_VERSION && "registries" in value && Array.isArray(value.registries) && value.registries.every(isSkillRegistryEntry);
|
|
9264
|
-
}
|
|
9265
|
-
function isSkillRegistryEntry(value) {
|
|
9266
|
-
if (typeof value !== "object" || value === null) return false;
|
|
9267
|
-
return "index" in value && typeof value.index === "number" && "name" in value && typeof value.name === "string" && "url" in value && typeof value.url === "string" && "checkoutPath" in value && typeof value.checkoutPath === "string";
|
|
9268
|
-
}
|
|
9269
9300
|
function getRegistryRoot(homeDir) {
|
|
9270
9301
|
return join15(homeDir, REGISTRY_ROOT_DIR);
|
|
9271
9302
|
}
|
|
@@ -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.
|
|
10857
|
+
var ENGINE_PACKAGE_VERSION = "0.1.576";
|
|
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
|
-
|
|
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",
|
|
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;
|