@vostride/agent-qa-core 0.1.18 → 0.1.20
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.cjs +211 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -1
- package/dist/index.d.ts +23 -1
- package/dist/index.js +206 -6
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -1032,6 +1032,8 @@ __export(index_exports, {
|
|
|
1032
1032
|
TransportSchema: () => TransportSchema,
|
|
1033
1033
|
UseSchema: () => UseSchema,
|
|
1034
1034
|
VALID_FILENAME_RE: () => VALID_FILENAME_RE,
|
|
1035
|
+
VERSION_CHECK_CACHE_TTL_MS: () => VERSION_CHECK_CACHE_TTL_MS,
|
|
1036
|
+
VERSION_CHECK_TIMEOUT_MS: () => VERSION_CHECK_TIMEOUT_MS,
|
|
1035
1037
|
VariableStore: () => VariableStore,
|
|
1036
1038
|
VerificationResultSchema: () => VerificationResultSchema,
|
|
1037
1039
|
WEB_ONLY_ACTIONS: () => WEB_ONLY_ACTIONS,
|
|
@@ -1095,7 +1097,9 @@ __export(index_exports, {
|
|
|
1095
1097
|
generatePKCE: () => generatePKCE,
|
|
1096
1098
|
generateRunId: () => generateRunId,
|
|
1097
1099
|
generateState: () => generateState,
|
|
1100
|
+
getAgentQaUpdateStatus: () => getAgentQaUpdateStatus,
|
|
1098
1101
|
getAgentQaVersion: () => getAgentQaVersion,
|
|
1102
|
+
getAgentQaVersionCheckCachePath: () => getAgentQaVersionCheckCachePath,
|
|
1099
1103
|
getAnalyticsIdentityPath: () => getAnalyticsIdentityPath,
|
|
1100
1104
|
getAnalyticsService: () => getAnalyticsService,
|
|
1101
1105
|
getAuthPath: () => getAuthPath,
|
|
@@ -6701,6 +6705,7 @@ var StdoutLiveReporter = class {
|
|
|
6701
6705
|
activeRunId;
|
|
6702
6706
|
activeParentRunId;
|
|
6703
6707
|
activeSuiteIndex;
|
|
6708
|
+
activeSuiteTotal;
|
|
6704
6709
|
redactor;
|
|
6705
6710
|
constructor(options = {}) {
|
|
6706
6711
|
this.active = options.active ?? process.env.AGENT_QA_LIVE_EVENTS === "true";
|
|
@@ -6718,10 +6723,12 @@ var StdoutLiveReporter = class {
|
|
|
6718
6723
|
const runId = context?.runId ?? this.activeRunId;
|
|
6719
6724
|
const parentRunId = context?.parentRunId ?? this.activeParentRunId;
|
|
6720
6725
|
const suiteIndex = context?.suiteIndex ?? this.activeSuiteIndex;
|
|
6726
|
+
const suiteTotal = context?.suiteTotal ?? this.activeSuiteTotal;
|
|
6721
6727
|
return {
|
|
6722
6728
|
...this.withRunId(event, runId),
|
|
6723
6729
|
...parentRunId ? { parentRunId } : {},
|
|
6724
6730
|
...typeof suiteIndex === "number" ? { suiteIndex } : {},
|
|
6731
|
+
...typeof suiteTotal === "number" ? { suiteTotal } : {},
|
|
6725
6732
|
...typeof context?.testIndex === "number" ? { testIndex: context.testIndex } : {},
|
|
6726
6733
|
...typeof context?.stepIndex === "number" ? { stepIndex: context.stepIndex } : {},
|
|
6727
6734
|
...context?.stepId ? { stepId: context.stepId } : {}
|
|
@@ -6731,6 +6738,7 @@ var StdoutLiveReporter = class {
|
|
|
6731
6738
|
this.activeRunId = context?.runId;
|
|
6732
6739
|
this.activeParentRunId = context?.parentRunId;
|
|
6733
6740
|
this.activeSuiteIndex = typeof context?.artifact?.suiteIndex === "number" ? context.artifact.suiteIndex : typeof context?.artifact?.runtime === "object" && context.artifact.runtime !== null && typeof context.artifact.runtime.suiteIndex === "number" ? context.artifact.runtime.suiteIndex : void 0;
|
|
6741
|
+
this.activeSuiteTotal = readSuiteTotal(context);
|
|
6734
6742
|
if (process.env.AGENT_QA_PARENT_RUN_ID) {
|
|
6735
6743
|
this.emit(this.withRunContext({
|
|
6736
6744
|
type: "retry-attempt",
|
|
@@ -6825,17 +6833,31 @@ var StdoutLiveReporter = class {
|
|
|
6825
6833
|
this.heartbeatInterval = null;
|
|
6826
6834
|
}
|
|
6827
6835
|
const runId = result.runId ?? this.activeRunId;
|
|
6828
|
-
this.emit(this.
|
|
6836
|
+
this.emit(this.withRunContext({
|
|
6829
6837
|
type: "test-complete",
|
|
6830
6838
|
testName: result.name,
|
|
6831
6839
|
status: result.status,
|
|
6832
6840
|
duration: result.duration
|
|
6833
|
-
}, runId));
|
|
6841
|
+
}, { runId }));
|
|
6834
6842
|
this.activeRunId = void 0;
|
|
6835
6843
|
this.activeParentRunId = void 0;
|
|
6836
6844
|
this.activeSuiteIndex = void 0;
|
|
6845
|
+
this.activeSuiteTotal = void 0;
|
|
6837
6846
|
}
|
|
6838
6847
|
};
|
|
6848
|
+
function readSuiteTotal(context) {
|
|
6849
|
+
const runtime = context?.artifact?.runtime;
|
|
6850
|
+
if (runtime && typeof runtime === "object") {
|
|
6851
|
+
const total = runtime.suiteTotal;
|
|
6852
|
+
if (typeof total === "number" && Number.isInteger(total) && total > 0) return total;
|
|
6853
|
+
}
|
|
6854
|
+
const source = context?.artifact?.source;
|
|
6855
|
+
if (source && typeof source === "object") {
|
|
6856
|
+
const members = source.members;
|
|
6857
|
+
if (Array.isArray(members) && members.length > 0) return members.length;
|
|
6858
|
+
}
|
|
6859
|
+
return void 0;
|
|
6860
|
+
}
|
|
6839
6861
|
|
|
6840
6862
|
// src/mobile/xml-parser.ts
|
|
6841
6863
|
var import_fast_xml_parser = require("fast-xml-parser");
|
|
@@ -7993,8 +8015,8 @@ function resolveModuleSpecifier(declaration, baseDir) {
|
|
|
7993
8015
|
const resolveImport = import_meta.resolve;
|
|
7994
8016
|
return resolveImport(packageName, parentUrl);
|
|
7995
8017
|
} catch {
|
|
7996
|
-
const
|
|
7997
|
-
return (0, import_node_url.pathToFileURL)(
|
|
8018
|
+
const require5 = (0, import_node_module.createRequire)((0, import_node_path12.resolve)(baseDir, "agent-qa.config.yaml"));
|
|
8019
|
+
return (0, import_node_url.pathToFileURL)(require5.resolve(packageName)).href;
|
|
7998
8020
|
}
|
|
7999
8021
|
}
|
|
8000
8022
|
const pluginPath = pathDeclarationValue(declaration);
|
|
@@ -8341,8 +8363,8 @@ var BROWSER_MAP = {
|
|
|
8341
8363
|
};
|
|
8342
8364
|
function detectPlaywrightVersion() {
|
|
8343
8365
|
try {
|
|
8344
|
-
const
|
|
8345
|
-
const pkg =
|
|
8366
|
+
const require5 = (0, import_node_module2.createRequire)(import_meta2.url);
|
|
8367
|
+
const pkg = require5("playwright-core/package.json");
|
|
8346
8368
|
return pkg.version;
|
|
8347
8369
|
} catch {
|
|
8348
8370
|
return "1.59.1";
|
|
@@ -9346,6 +9368,7 @@ async function runSuite(suite, testEntries, config) {
|
|
|
9346
9368
|
runtime: {
|
|
9347
9369
|
platform: config.platformConfig.platform,
|
|
9348
9370
|
suiteIndex: i,
|
|
9371
|
+
suiteTotal: testEntries.length,
|
|
9349
9372
|
parentSuiteId: suite["suite-id"] ?? suite.name
|
|
9350
9373
|
}
|
|
9351
9374
|
}
|
|
@@ -11658,6 +11681,184 @@ function createAnalyticsRunReporter(options = {}) {
|
|
|
11658
11681
|
return new AnalyticsRunReporter(options);
|
|
11659
11682
|
}
|
|
11660
11683
|
|
|
11684
|
+
// src/version-check/index.ts
|
|
11685
|
+
var import_promises20 = require("fs/promises");
|
|
11686
|
+
var import_node_module5 = require("module");
|
|
11687
|
+
var import_node_os5 = require("os");
|
|
11688
|
+
var import_node_path26 = require("path");
|
|
11689
|
+
var import_meta5 = {};
|
|
11690
|
+
var require4 = (0, import_node_module5.createRequire)(import_meta5.url);
|
|
11691
|
+
var AGENT_QA_NPM_REGISTRY_URL = "https://registry.npmjs.org/agent-qa";
|
|
11692
|
+
var VERSION_CHECK_CACHE_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
11693
|
+
var VERSION_CHECK_TIMEOUT_MS = 5e3;
|
|
11694
|
+
var semverApi;
|
|
11695
|
+
function getAgentQaVersionCheckCachePath(homeDir) {
|
|
11696
|
+
return (0, import_node_path26.join)(homeDir ?? (0, import_node_os5.homedir)(), ".agent-qa", "version-check.json");
|
|
11697
|
+
}
|
|
11698
|
+
async function getAgentQaUpdateStatus(options = {}) {
|
|
11699
|
+
const installedVersion = getInstalledVersion();
|
|
11700
|
+
try {
|
|
11701
|
+
return await getAgentQaUpdateStatusInternal(installedVersion, options);
|
|
11702
|
+
} catch {
|
|
11703
|
+
return createStatus(installedVersion);
|
|
11704
|
+
}
|
|
11705
|
+
}
|
|
11706
|
+
async function getAgentQaUpdateStatusInternal(installedVersion, options) {
|
|
11707
|
+
const semver = getSemverApi();
|
|
11708
|
+
if (!semver) {
|
|
11709
|
+
return createStatus(installedVersion);
|
|
11710
|
+
}
|
|
11711
|
+
const now = getNow(options.now);
|
|
11712
|
+
const nowMs = now.getTime();
|
|
11713
|
+
const nowIso = now.toISOString();
|
|
11714
|
+
const cacheTtlMs = getPositiveNumber(options.cacheTtlMs, VERSION_CHECK_CACHE_TTL_MS);
|
|
11715
|
+
const timeoutMs = getPositiveNumber(options.timeoutMs, VERSION_CHECK_TIMEOUT_MS);
|
|
11716
|
+
const cachePath = options.cachePath ?? getAgentQaVersionCheckCachePath(options.homeDir);
|
|
11717
|
+
const cache = await readVersionCheckCache(cachePath);
|
|
11718
|
+
const cachedLatestVersion = getValidVersion(cache?.latestVersion, semver);
|
|
11719
|
+
const checkedAtMs = getTimestamp(cache?.checkedAt);
|
|
11720
|
+
if (cachedLatestVersion && checkedAtMs !== void 0 && nowMs - checkedAtMs < cacheTtlMs) {
|
|
11721
|
+
return createStatus(installedVersion, semver, cachedLatestVersion, cache?.checkedAt);
|
|
11722
|
+
}
|
|
11723
|
+
const lastAttemptedAtMs = getTimestamp(cache?.lastAttemptedAt);
|
|
11724
|
+
if (lastAttemptedAtMs !== void 0 && nowMs - lastAttemptedAtMs < cacheTtlMs) {
|
|
11725
|
+
if (cachedLatestVersion && checkedAtMs !== void 0) {
|
|
11726
|
+
return createStatus(installedVersion, semver, cachedLatestVersion, cache?.checkedAt);
|
|
11727
|
+
}
|
|
11728
|
+
return createStatus(installedVersion);
|
|
11729
|
+
}
|
|
11730
|
+
const nextCache = { ...cache, lastAttemptedAt: nowIso };
|
|
11731
|
+
const refreshedLatestVersion = await fetchLatestVersion(options.fetchImpl, timeoutMs, semver);
|
|
11732
|
+
if (refreshedLatestVersion) {
|
|
11733
|
+
const refreshedCache = {
|
|
11734
|
+
latestVersion: refreshedLatestVersion,
|
|
11735
|
+
checkedAt: nowIso,
|
|
11736
|
+
lastAttemptedAt: nowIso
|
|
11737
|
+
};
|
|
11738
|
+
await writeVersionCheckCache(cachePath, refreshedCache);
|
|
11739
|
+
return createStatus(installedVersion, semver, refreshedLatestVersion, nowIso);
|
|
11740
|
+
}
|
|
11741
|
+
await writeVersionCheckCache(cachePath, nextCache);
|
|
11742
|
+
if (cachedLatestVersion && checkedAtMs !== void 0) {
|
|
11743
|
+
return createStatus(installedVersion, semver, cachedLatestVersion, cache?.checkedAt);
|
|
11744
|
+
}
|
|
11745
|
+
return createStatus(installedVersion);
|
|
11746
|
+
}
|
|
11747
|
+
function getInstalledVersion() {
|
|
11748
|
+
try {
|
|
11749
|
+
return getAgentQaVersion().trim() || "0.0.0";
|
|
11750
|
+
} catch {
|
|
11751
|
+
return "0.0.0";
|
|
11752
|
+
}
|
|
11753
|
+
}
|
|
11754
|
+
function getSemverApi() {
|
|
11755
|
+
if (semverApi) return semverApi;
|
|
11756
|
+
try {
|
|
11757
|
+
semverApi = require4("semver");
|
|
11758
|
+
return semverApi;
|
|
11759
|
+
} catch {
|
|
11760
|
+
return void 0;
|
|
11761
|
+
}
|
|
11762
|
+
}
|
|
11763
|
+
function getValidVersion(version, semver) {
|
|
11764
|
+
if (typeof version !== "string") return void 0;
|
|
11765
|
+
try {
|
|
11766
|
+
return semver.valid(version) ?? void 0;
|
|
11767
|
+
} catch {
|
|
11768
|
+
return void 0;
|
|
11769
|
+
}
|
|
11770
|
+
}
|
|
11771
|
+
function getTimestamp(value) {
|
|
11772
|
+
if (typeof value !== "string") return void 0;
|
|
11773
|
+
const timestamp = Date.parse(value);
|
|
11774
|
+
return Number.isFinite(timestamp) ? timestamp : void 0;
|
|
11775
|
+
}
|
|
11776
|
+
function getPositiveNumber(value, fallback) {
|
|
11777
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : fallback;
|
|
11778
|
+
}
|
|
11779
|
+
function getNow(now) {
|
|
11780
|
+
try {
|
|
11781
|
+
const candidate = now?.();
|
|
11782
|
+
if (candidate instanceof Date && Number.isFinite(candidate.getTime())) {
|
|
11783
|
+
return candidate;
|
|
11784
|
+
}
|
|
11785
|
+
} catch {
|
|
11786
|
+
}
|
|
11787
|
+
return /* @__PURE__ */ new Date();
|
|
11788
|
+
}
|
|
11789
|
+
function createStatus(installedVersion, semver, latestVersion, checkedAt) {
|
|
11790
|
+
if (!latestVersion) {
|
|
11791
|
+
return {
|
|
11792
|
+
installedVersion,
|
|
11793
|
+
updateAvailable: false
|
|
11794
|
+
};
|
|
11795
|
+
}
|
|
11796
|
+
const installedSemver = semver ? getValidVersion(installedVersion, semver) : void 0;
|
|
11797
|
+
const updateAvailable = Boolean(
|
|
11798
|
+
installedSemver && semver && safeSemverGreaterThan(semver, latestVersion, installedSemver)
|
|
11799
|
+
);
|
|
11800
|
+
return {
|
|
11801
|
+
installedVersion,
|
|
11802
|
+
latestVersion,
|
|
11803
|
+
updateAvailable,
|
|
11804
|
+
checkedAt
|
|
11805
|
+
};
|
|
11806
|
+
}
|
|
11807
|
+
function safeSemverGreaterThan(semver, version, otherVersion) {
|
|
11808
|
+
try {
|
|
11809
|
+
return semver.gt(version, otherVersion);
|
|
11810
|
+
} catch {
|
|
11811
|
+
return false;
|
|
11812
|
+
}
|
|
11813
|
+
}
|
|
11814
|
+
async function readVersionCheckCache(cachePath) {
|
|
11815
|
+
try {
|
|
11816
|
+
const raw = await (0, import_promises20.readFile)(cachePath, "utf-8");
|
|
11817
|
+
const parsed = JSON.parse(raw);
|
|
11818
|
+
if (!isRecord3(parsed)) return void 0;
|
|
11819
|
+
return {
|
|
11820
|
+
latestVersion: typeof parsed.latestVersion === "string" ? parsed.latestVersion : void 0,
|
|
11821
|
+
checkedAt: typeof parsed.checkedAt === "string" ? parsed.checkedAt : void 0,
|
|
11822
|
+
lastAttemptedAt: typeof parsed.lastAttemptedAt === "string" ? parsed.lastAttemptedAt : void 0
|
|
11823
|
+
};
|
|
11824
|
+
} catch {
|
|
11825
|
+
return void 0;
|
|
11826
|
+
}
|
|
11827
|
+
}
|
|
11828
|
+
async function writeVersionCheckCache(cachePath, cache) {
|
|
11829
|
+
try {
|
|
11830
|
+
await (0, import_promises20.mkdir)((0, import_node_path26.dirname)(cachePath), { recursive: true });
|
|
11831
|
+
await (0, import_promises20.writeFile)(cachePath, JSON.stringify(cache, null, 2), {
|
|
11832
|
+
encoding: "utf-8",
|
|
11833
|
+
mode: 384
|
|
11834
|
+
});
|
|
11835
|
+
try {
|
|
11836
|
+
await (0, import_promises20.chmod)(cachePath, 384);
|
|
11837
|
+
} catch {
|
|
11838
|
+
}
|
|
11839
|
+
} catch {
|
|
11840
|
+
}
|
|
11841
|
+
}
|
|
11842
|
+
async function fetchLatestVersion(fetchImpl, timeoutMs, semver) {
|
|
11843
|
+
try {
|
|
11844
|
+
const fetcher = fetchImpl ?? globalThis.fetch?.bind(globalThis);
|
|
11845
|
+
if (typeof fetcher !== "function") return void 0;
|
|
11846
|
+
const response = await fetcher(AGENT_QA_NPM_REGISTRY_URL, {
|
|
11847
|
+
headers: { accept: "application/json" },
|
|
11848
|
+
signal: AbortSignal.timeout(timeoutMs)
|
|
11849
|
+
});
|
|
11850
|
+
if (!response.ok) return void 0;
|
|
11851
|
+
const body = await response.json();
|
|
11852
|
+
if (!isRecord3(body) || !isRecord3(body["dist-tags"])) return void 0;
|
|
11853
|
+
return getValidVersion(body["dist-tags"].latest, semver);
|
|
11854
|
+
} catch {
|
|
11855
|
+
return void 0;
|
|
11856
|
+
}
|
|
11857
|
+
}
|
|
11858
|
+
function isRecord3(value) {
|
|
11859
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
11860
|
+
}
|
|
11861
|
+
|
|
11661
11862
|
// src/index.ts
|
|
11662
11863
|
init_sqlite();
|
|
11663
11864
|
|
|
@@ -11826,6 +12027,8 @@ function isMacPlatform() {
|
|
|
11826
12027
|
TransportSchema,
|
|
11827
12028
|
UseSchema,
|
|
11828
12029
|
VALID_FILENAME_RE,
|
|
12030
|
+
VERSION_CHECK_CACHE_TTL_MS,
|
|
12031
|
+
VERSION_CHECK_TIMEOUT_MS,
|
|
11829
12032
|
VariableStore,
|
|
11830
12033
|
VerificationResultSchema,
|
|
11831
12034
|
WEB_ONLY_ACTIONS,
|
|
@@ -11889,7 +12092,9 @@ function isMacPlatform() {
|
|
|
11889
12092
|
generatePKCE,
|
|
11890
12093
|
generateRunId,
|
|
11891
12094
|
generateState,
|
|
12095
|
+
getAgentQaUpdateStatus,
|
|
11892
12096
|
getAgentQaVersion,
|
|
12097
|
+
getAgentQaVersionCheckCachePath,
|
|
11893
12098
|
getAnalyticsIdentityPath,
|
|
11894
12099
|
getAnalyticsService,
|
|
11895
12100
|
getAuthPath,
|