agent-qa 0.1.1 → 0.1.3
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.cjs +73 -7
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +68 -3
- package/dist/cli.js.map +1 -1
- package/package.json +9 -9
package/dist/cli.js
CHANGED
|
@@ -616,6 +616,7 @@ import { DEFAULT_AGENT_QA_CACHE_DIR as DEFAULT_AGENT_QA_CACHE_DIR2, DEFAULT_AGEN
|
|
|
616
616
|
var INIT_CACHE_DIR = DEFAULT_AGENT_QA_CACHE_DIR2 || ".agent-qa/cache";
|
|
617
617
|
var INIT_RUNTIME_DIR = DEFAULT_AGENT_QA_RUNTIME_DIR || ".agent-qa";
|
|
618
618
|
var SUBSCRIPTION_AUTH_PACKAGE = "@vostride/agent-qa-subscription-auth";
|
|
619
|
+
var PACKAGE_JSON_FILE = "package.json";
|
|
619
620
|
var DEFAULT_SCREENSHOT_SIZE = "50kb";
|
|
620
621
|
var DEFAULT_EFFECTIVE_RESOLUTION = 500;
|
|
621
622
|
var OPENAI_SUBSCRIPTION_CONFIG = {
|
|
@@ -829,6 +830,61 @@ steps:
|
|
|
829
830
|
function isSubscriptionProvider(provider) {
|
|
830
831
|
return provider === "openai-subscription" || provider === "anthropic-subscription";
|
|
831
832
|
}
|
|
833
|
+
function readAgentQaPackageVersion() {
|
|
834
|
+
try {
|
|
835
|
+
const manifest = JSON.parse(readFileSync(new URL("../../package.json", import.meta.url), "utf-8"));
|
|
836
|
+
return typeof manifest.version === "string" && manifest.version.trim() ? manifest.version.trim() : null;
|
|
837
|
+
} catch {
|
|
838
|
+
return null;
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
function subscriptionAuthDependencyRange() {
|
|
842
|
+
return readAgentQaPackageVersion() ?? "*";
|
|
843
|
+
}
|
|
844
|
+
function objectRecord(value) {
|
|
845
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
846
|
+
}
|
|
847
|
+
function configUsesSubscriptionAuth(config) {
|
|
848
|
+
const plugins = objectRecord(config.plugins);
|
|
849
|
+
const authPlugins = plugins?.auth;
|
|
850
|
+
if (!Array.isArray(authPlugins)) return false;
|
|
851
|
+
return authPlugins.some((plugin) => objectRecord(plugin)?.package === SUBSCRIPTION_AUTH_PACKAGE);
|
|
852
|
+
}
|
|
853
|
+
function upsertSubscriptionAuthPackageDependency(dir) {
|
|
854
|
+
const packageJsonPath = join3(dir, PACKAGE_JSON_FILE);
|
|
855
|
+
const created = !existsSync(packageJsonPath);
|
|
856
|
+
const pkg = created ? { private: true } : JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
857
|
+
if (!objectRecord(pkg)) {
|
|
858
|
+
throw new Error(`${PACKAGE_JSON_FILE} must contain a JSON object to add ${SUBSCRIPTION_AUTH_PACKAGE}`);
|
|
859
|
+
}
|
|
860
|
+
const dependencyBlocks = ["devDependencies", "dependencies", "optionalDependencies", "peerDependencies"];
|
|
861
|
+
const existingBlock = dependencyBlocks.find((blockName) => {
|
|
862
|
+
const block = objectRecord(pkg[blockName]);
|
|
863
|
+
return block && Object.prototype.hasOwnProperty.call(block, SUBSCRIPTION_AUTH_PACKAGE);
|
|
864
|
+
});
|
|
865
|
+
const targetBlock = existingBlock ?? "devDependencies";
|
|
866
|
+
const targetDependencies = {
|
|
867
|
+
...objectRecord(pkg[targetBlock]) ?? {},
|
|
868
|
+
[SUBSCRIPTION_AUTH_PACKAGE]: subscriptionAuthDependencyRange()
|
|
869
|
+
};
|
|
870
|
+
pkg[targetBlock] = targetDependencies;
|
|
871
|
+
for (const blockName of dependencyBlocks) {
|
|
872
|
+
if (blockName === targetBlock) continue;
|
|
873
|
+
const block = objectRecord(pkg[blockName]);
|
|
874
|
+
if (!block || !Object.prototype.hasOwnProperty.call(block, SUBSCRIPTION_AUTH_PACKAGE)) continue;
|
|
875
|
+
const nextBlock = { ...block };
|
|
876
|
+
delete nextBlock[SUBSCRIPTION_AUTH_PACKAGE];
|
|
877
|
+
if (Object.keys(nextBlock).length > 0) pkg[blockName] = nextBlock;
|
|
878
|
+
else delete pkg[blockName];
|
|
879
|
+
}
|
|
880
|
+
writeFileSync(packageJsonPath, `${JSON.stringify(pkg, null, 2)}
|
|
881
|
+
`);
|
|
882
|
+
return {
|
|
883
|
+
path: packageJsonPath,
|
|
884
|
+
created,
|
|
885
|
+
range: String(targetDependencies[SUBSCRIPTION_AUTH_PACKAGE])
|
|
886
|
+
};
|
|
887
|
+
}
|
|
832
888
|
function toLLMEntry(config) {
|
|
833
889
|
const llmEntry = {
|
|
834
890
|
name: config.name,
|
|
@@ -1201,10 +1257,16 @@ function createInitCommand() {
|
|
|
1201
1257
|
mkdirSync(testsDir, { recursive: true });
|
|
1202
1258
|
}
|
|
1203
1259
|
const config = buildDefaultConfig(platform, llmConfigs ?? provider, model, baseURL);
|
|
1260
|
+
const usesSubscriptionAuth = configUsesSubscriptionAuth(config);
|
|
1204
1261
|
const yamlStr = stringify(config);
|
|
1205
1262
|
const configContent = addYamlComments(yamlStr);
|
|
1206
1263
|
writeFileSync(configPath, configContent);
|
|
1207
1264
|
console.log(pc4.green(`\u2713 Created ${configPath}`));
|
|
1265
|
+
const subscriptionAuthDependency = usesSubscriptionAuth ? upsertSubscriptionAuthPackageDependency(dir) : null;
|
|
1266
|
+
if (subscriptionAuthDependency) {
|
|
1267
|
+
const action = subscriptionAuthDependency.created ? "Created" : "Updated";
|
|
1268
|
+
console.log(pc4.green(`\u2713 ${action} ${subscriptionAuthDependency.path}`));
|
|
1269
|
+
}
|
|
1208
1270
|
const secretsPath = join3(dir, DEFAULT_SECRETS_FILE);
|
|
1209
1271
|
if (force || !existsSync(secretsPath)) {
|
|
1210
1272
|
writeFileSync(secretsPath, "");
|
|
@@ -1275,6 +1337,9 @@ function createInitCommand() {
|
|
|
1275
1337
|
console.log("");
|
|
1276
1338
|
console.log(" Created:");
|
|
1277
1339
|
console.log(` ${pc4.dim("\u2022")} agent-qa.config.yaml`);
|
|
1340
|
+
if (subscriptionAuthDependency) {
|
|
1341
|
+
console.log(` ${pc4.dim("\u2022")} ${PACKAGE_JSON_FILE} dependency for ${SUBSCRIPTION_AUTH_PACKAGE}@${subscriptionAuthDependency.range}`);
|
|
1342
|
+
}
|
|
1278
1343
|
console.log(` ${pc4.dim("\u2022")} ${DEFAULT_HOOKS_FILE}`);
|
|
1279
1344
|
console.log(` ${pc4.dim("\u2022")} ${DEFAULT_AGENT_RULES_FILE}`);
|
|
1280
1345
|
console.log(` ${pc4.dim("\u2022")} ${DEFAULT_ENV_FILE}`);
|
|
@@ -1306,7 +1371,7 @@ function createInitCommand() {
|
|
|
1306
1371
|
console.log(` ${pc4.dim("\u2022")} Bearer tokens use ${pc4.cyan("agent-qa auth set --config default --type bearer-token")}`);
|
|
1307
1372
|
}
|
|
1308
1373
|
} else {
|
|
1309
|
-
console.log(` ${pc4.dim("\u2022")}
|
|
1374
|
+
console.log(` ${pc4.dim("\u2022")} Fetch ${SUBSCRIPTION_AUTH_PACKAGE} with your package manager install command`);
|
|
1310
1375
|
for (const llm of subscriptionLLMs) {
|
|
1311
1376
|
console.log(` ${pc4.dim("\u2022")} Authenticate ${pc4.cyan(String(llm.name))} from ${pc4.cyan("agent-qa dashboard")}`);
|
|
1312
1377
|
}
|
|
@@ -4698,8 +4763,8 @@ function printMissingSubscriptionPluginGuidance(configName, provider) {
|
|
|
4698
4763
|
console.log(pc11.red(`Provider "${provider}" is configured for "${configName}", but no auth plugin is registered.`));
|
|
4699
4764
|
console.log(pc11.dim(`Config: ${configName}`));
|
|
4700
4765
|
console.log(pc11.dim(`Provider: ${provider}`));
|
|
4701
|
-
console.log(pc11.dim("
|
|
4702
|
-
console.log(pc11.dim("
|
|
4766
|
+
console.log(pc11.dim("Add the subscription auth plugin to package.json and install with your package manager:"));
|
|
4767
|
+
console.log(pc11.dim(' "devDependencies": { "@vostride/agent-qa-subscription-auth": "<agent-qa version>" }'));
|
|
4703
4768
|
console.log(pc11.dim("Declare it in agent-qa.config.yaml under plugins.auth:"));
|
|
4704
4769
|
console.log(pc11.dim(" plugins:"));
|
|
4705
4770
|
console.log(pc11.dim(" auth:"));
|