@wayai/cli 0.3.176 → 0.3.177
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.js +60 -42
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -23934,7 +23934,9 @@ function guessMimeType(filename) {
|
|
|
23934
23934
|
function computeHash(data) {
|
|
23935
23935
|
return crypto3.createHash("sha256").update(data).digest("hex");
|
|
23936
23936
|
}
|
|
23937
|
-
function scanResourceFiles(dir, prefix = "") {
|
|
23937
|
+
function scanResourceFiles(dir, prefix = "", onOversized = (relPath, reason) => {
|
|
23938
|
+
console.warn(` Warning: skipping ${relPath} (${reason})`);
|
|
23939
|
+
}) {
|
|
23938
23940
|
const files = [];
|
|
23939
23941
|
const entries = fs9.readdirSync(dir, { withFileTypes: true });
|
|
23940
23942
|
for (const entry of entries) {
|
|
@@ -23942,12 +23944,12 @@ function scanResourceFiles(dir, prefix = "") {
|
|
|
23942
23944
|
if (entry.isSymbolicLink()) {
|
|
23943
23945
|
throw symlinkRefusal(relPath, "file or folder");
|
|
23944
23946
|
} else if (entry.isDirectory()) {
|
|
23945
|
-
files.push(...scanResourceFiles(path11.join(dir, entry.name), relPath));
|
|
23947
|
+
files.push(...scanResourceFiles(path11.join(dir, entry.name), relPath, onOversized));
|
|
23946
23948
|
} else if (entry.isFile()) {
|
|
23947
23949
|
const fullPath = path11.join(dir, entry.name);
|
|
23948
23950
|
const stat2 = fs9.statSync(fullPath);
|
|
23949
23951
|
if (stat2.size > MAX_RESOURCE_FILE_SIZE3) {
|
|
23950
|
-
|
|
23952
|
+
onOversized(relPath, `${(stat2.size / 1024 / 1024).toFixed(1)}MB exceeds 10MB limit`);
|
|
23951
23953
|
continue;
|
|
23952
23954
|
}
|
|
23953
23955
|
const fileEntry = {
|
|
@@ -24469,7 +24471,11 @@ function parseHubFolder(hubFolder, opts) {
|
|
|
24469
24471
|
throw expected(`Missing hub_environment in ${yamlPath}`);
|
|
24470
24472
|
}
|
|
24471
24473
|
}
|
|
24472
|
-
const
|
|
24474
|
+
const unreadable = (relPath, reason, unreadableOpts) => {
|
|
24475
|
+
if (opts?.strict) throw expected(`${relPath}: ${reason}`);
|
|
24476
|
+
if (!unreadableOpts?.silent) console.warn(` Warning: skipping ${relPath} (${reason})`);
|
|
24477
|
+
};
|
|
24478
|
+
const agentYamlFiles = scanAgentYamlFiles(hubFolder, unreadable);
|
|
24473
24479
|
const rawAgents = agentYamlFiles.length > 0 ? agentYamlFiles : config.agents;
|
|
24474
24480
|
const agents = rawAgents?.map((agent) => {
|
|
24475
24481
|
const resolved = { ...agent };
|
|
@@ -24496,7 +24502,7 @@ function parseHubFolder(hubFolder, opts) {
|
|
|
24496
24502
|
}
|
|
24497
24503
|
return resolved;
|
|
24498
24504
|
});
|
|
24499
|
-
const resources = parseResources(hubFolder, config.resources || []);
|
|
24505
|
+
const resources = parseResources(hubFolder, config.resources || [], unreadable);
|
|
24500
24506
|
const payload = {
|
|
24501
24507
|
version: config.version || 1,
|
|
24502
24508
|
hub_id: config.hub_id || "",
|
|
@@ -24532,11 +24538,11 @@ function parseHubFolder(hubFolder, opts) {
|
|
|
24532
24538
|
payload.outbound_schedules = config.outbound_schedules;
|
|
24533
24539
|
}
|
|
24534
24540
|
const bytesByHash = /* @__PURE__ */ new Map();
|
|
24535
|
-
const evals = scanEvalYamlFiles(hubFolder, bytesByHash);
|
|
24541
|
+
const evals = scanEvalYamlFiles(hubFolder, bytesByHash, unreadable);
|
|
24536
24542
|
if (evals.length > 0) {
|
|
24537
24543
|
payload.evals = evals;
|
|
24538
24544
|
}
|
|
24539
|
-
const journeys = scanJourneyYamlFiles(hubFolder, bytesByHash);
|
|
24545
|
+
const journeys = scanJourneyYamlFiles(hubFolder, bytesByHash, unreadable);
|
|
24540
24546
|
if (journeys.length > 0) {
|
|
24541
24547
|
payload.journeys = journeys;
|
|
24542
24548
|
}
|
|
@@ -24545,7 +24551,7 @@ function parseHubFolder(hubFolder, opts) {
|
|
|
24545
24551
|
}
|
|
24546
24552
|
return payload;
|
|
24547
24553
|
}
|
|
24548
|
-
function scanEvalYamlFiles(hubFolder, bytesByHash) {
|
|
24554
|
+
function scanEvalYamlFiles(hubFolder, bytesByHash, unreadable) {
|
|
24549
24555
|
const evalsDir = path14.join(hubFolder, "evals");
|
|
24550
24556
|
if (!fs12.existsSync(evalsDir)) return [];
|
|
24551
24557
|
const evals = [];
|
|
@@ -24554,7 +24560,7 @@ function scanEvalYamlFiles(hubFolder, bytesByHash) {
|
|
|
24554
24560
|
for (const entry of topEntries) {
|
|
24555
24561
|
refuseConsumedLink(hubFolder, evalsDir, entry);
|
|
24556
24562
|
if (entry.isFile() && entry.name.endsWith(".yaml")) {
|
|
24557
|
-
collectEval(evals, seen, path14.join(evalsDir, entry.name), `evals/${entry.name}`, null, hubFolder, bytesByHash);
|
|
24563
|
+
collectEval(evals, seen, path14.join(evalsDir, entry.name), `evals/${entry.name}`, null, hubFolder, bytesByHash, unreadable);
|
|
24558
24564
|
} else if (entry.isDirectory()) {
|
|
24559
24565
|
const setName = entry.name;
|
|
24560
24566
|
const setDir = path14.join(evalsDir, setName);
|
|
@@ -24567,16 +24573,19 @@ function scanEvalYamlFiles(hubFolder, bytesByHash) {
|
|
|
24567
24573
|
);
|
|
24568
24574
|
}
|
|
24569
24575
|
if (sub.isFile() && sub.name.endsWith(".yaml")) {
|
|
24570
|
-
collectEval(evals, seen, path14.join(setDir, sub.name), `evals/${setName}/${sub.name}`, setName, hubFolder, bytesByHash);
|
|
24576
|
+
collectEval(evals, seen, path14.join(setDir, sub.name), `evals/${setName}/${sub.name}`, setName, hubFolder, bytesByHash, unreadable);
|
|
24571
24577
|
}
|
|
24572
24578
|
}
|
|
24573
24579
|
}
|
|
24574
24580
|
}
|
|
24575
24581
|
return evals;
|
|
24576
24582
|
}
|
|
24577
|
-
function collectEval(evals, seen, filePath, relPath, setName, hubFolder, bytesByHash) {
|
|
24583
|
+
function collectEval(evals, seen, filePath, relPath, setName, hubFolder, bytesByHash, unreadable) {
|
|
24578
24584
|
const evalEntry = parseEvalYaml(filePath, relPath, setName, hubFolder, bytesByHash);
|
|
24579
|
-
if (!evalEntry)
|
|
24585
|
+
if (!evalEntry) {
|
|
24586
|
+
unreadable(relPath, NOT_A_YAML_OBJECT);
|
|
24587
|
+
return;
|
|
24588
|
+
}
|
|
24580
24589
|
const key = `${evalEntry.name}|${setName ?? ""}`;
|
|
24581
24590
|
if (seen.has(key)) {
|
|
24582
24591
|
const where = setName ? `scenario set "${setName}"` : "root";
|
|
@@ -24598,10 +24607,7 @@ function parseEvalYaml(filePath, relPath, setName, hubFolder, bytesByHash) {
|
|
|
24598
24607
|
}
|
|
24599
24608
|
throw err;
|
|
24600
24609
|
}
|
|
24601
|
-
if (!raw || typeof raw !== "object" || Array.isArray(raw))
|
|
24602
|
-
console.warn(` Warning: skipping ${relPath} (not a YAML object)`);
|
|
24603
|
-
return null;
|
|
24604
|
-
}
|
|
24610
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;
|
|
24605
24611
|
const data = raw;
|
|
24606
24612
|
const fileSlug = path14.basename(filePath, ".yaml");
|
|
24607
24613
|
const evalName = typeof data.name === "string" && data.name.trim().length > 0 ? data.name : fileSlug;
|
|
@@ -24689,7 +24695,7 @@ function parseFixtureField(raw, label, key) {
|
|
|
24689
24695
|
const trimmed = raw.trim();
|
|
24690
24696
|
return trimmed.length > 0 ? trimmed : void 0;
|
|
24691
24697
|
}
|
|
24692
|
-
function scanJourneyYamlFiles(hubFolder, bytesByHash) {
|
|
24698
|
+
function scanJourneyYamlFiles(hubFolder, bytesByHash, unreadable) {
|
|
24693
24699
|
const journeysDir = path14.join(hubFolder, "journeys");
|
|
24694
24700
|
if (!fs12.existsSync(journeysDir)) return [];
|
|
24695
24701
|
const journeys = [];
|
|
@@ -24704,7 +24710,10 @@ function scanJourneyYamlFiles(hubFolder, bytesByHash) {
|
|
|
24704
24710
|
}
|
|
24705
24711
|
if (!entry.isFile() || !entry.name.endsWith(".yaml")) continue;
|
|
24706
24712
|
const journeyEntry = parseJourneyYaml(path14.join(journeysDir, entry.name), `journeys/${entry.name}`, hubFolder, bytesByHash);
|
|
24707
|
-
if (!journeyEntry)
|
|
24713
|
+
if (!journeyEntry) {
|
|
24714
|
+
unreadable(`journeys/${entry.name}`, NOT_A_YAML_OBJECT);
|
|
24715
|
+
continue;
|
|
24716
|
+
}
|
|
24708
24717
|
if (seen.has(journeyEntry.name)) {
|
|
24709
24718
|
throw expected(
|
|
24710
24719
|
`Duplicate journey: "${journeyEntry.name}" (in ${entry.name}). Each journey name must be unique.`
|
|
@@ -24726,10 +24735,7 @@ function parseJourneyYaml(filePath, relPath, hubFolder, bytesByHash) {
|
|
|
24726
24735
|
}
|
|
24727
24736
|
throw err;
|
|
24728
24737
|
}
|
|
24729
|
-
if (!raw || typeof raw !== "object" || Array.isArray(raw))
|
|
24730
|
-
console.warn(` Warning: skipping ${relPath} (not a YAML object)`);
|
|
24731
|
-
return null;
|
|
24732
|
-
}
|
|
24738
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;
|
|
24733
24739
|
const data = raw;
|
|
24734
24740
|
const fileSlug = path14.basename(filePath, ".yaml");
|
|
24735
24741
|
const journeyName = typeof data.name === "string" && data.name.trim().length > 0 ? data.name : fileSlug;
|
|
@@ -24770,7 +24776,7 @@ function parseJourneyYaml(filePath, relPath, hubFolder, bytesByHash) {
|
|
|
24770
24776
|
if (targetBase) journeyEntry.target_base = targetBase;
|
|
24771
24777
|
return journeyEntry;
|
|
24772
24778
|
}
|
|
24773
|
-
function scanAgentYamlFiles(hubFolder) {
|
|
24779
|
+
function scanAgentYamlFiles(hubFolder, unreadable) {
|
|
24774
24780
|
const agentsDir = path14.join(hubFolder, "agents");
|
|
24775
24781
|
if (!fs12.existsSync(agentsDir)) return [];
|
|
24776
24782
|
const yamlFiles = fs12.readdirSync(agentsDir).filter((f) => f.endsWith(".yaml")).sort();
|
|
@@ -24788,16 +24794,19 @@ function scanAgentYamlFiles(hubFolder) {
|
|
|
24788
24794
|
}
|
|
24789
24795
|
throw err;
|
|
24790
24796
|
}
|
|
24791
|
-
if (!agent || typeof agent !== "object")
|
|
24797
|
+
if (!agent || typeof agent !== "object") {
|
|
24798
|
+
unreadable(`agents/${file}`, NOT_A_YAML_OBJECT, { silent: true });
|
|
24799
|
+
continue;
|
|
24800
|
+
}
|
|
24792
24801
|
if (!agent.name) {
|
|
24793
|
-
|
|
24802
|
+
unreadable(`agents/${file}`, "missing 'name' field");
|
|
24794
24803
|
continue;
|
|
24795
24804
|
}
|
|
24796
24805
|
agents.push(agent);
|
|
24797
24806
|
}
|
|
24798
24807
|
return agents;
|
|
24799
24808
|
}
|
|
24800
|
-
function parseResources(hubFolder, configResources) {
|
|
24809
|
+
function parseResources(hubFolder, configResources, unreadable) {
|
|
24801
24810
|
const resourcesDir = path14.join(hubFolder, "resources");
|
|
24802
24811
|
const results = [];
|
|
24803
24812
|
for (const res of configResources) {
|
|
@@ -24815,7 +24824,7 @@ function parseResources(hubFolder, configResources) {
|
|
|
24815
24824
|
const resDir = path14.join(resourcesDir, resSlug);
|
|
24816
24825
|
requireRealSubdirNoSymlink(hubFolder, resDir, false);
|
|
24817
24826
|
if (fs12.existsSync(resDir)) {
|
|
24818
|
-
const files = scanResourceFiles(resDir, "");
|
|
24827
|
+
const files = scanResourceFiles(resDir, "", (relPath, reason) => unreadable(`resources/${resSlug}/${relPath}`, reason));
|
|
24819
24828
|
if (files.length > 0) {
|
|
24820
24829
|
resource.files = files;
|
|
24821
24830
|
}
|
|
@@ -24824,6 +24833,7 @@ function parseResources(hubFolder, configResources) {
|
|
|
24824
24833
|
}
|
|
24825
24834
|
return results;
|
|
24826
24835
|
}
|
|
24836
|
+
var NOT_A_YAML_OBJECT;
|
|
24827
24837
|
var init_parser = __esm({
|
|
24828
24838
|
"src/lib/parser.ts"() {
|
|
24829
24839
|
"use strict";
|
|
@@ -24833,6 +24843,7 @@ var init_parser = __esm({
|
|
|
24833
24843
|
init_call_openings();
|
|
24834
24844
|
init_expected();
|
|
24835
24845
|
init_fs_safety();
|
|
24846
|
+
NOT_A_YAML_OBJECT = "not a YAML object";
|
|
24836
24847
|
}
|
|
24837
24848
|
});
|
|
24838
24849
|
|
|
@@ -27018,17 +27029,16 @@ async function pullCommand(args2) {
|
|
|
27018
27029
|
return;
|
|
27019
27030
|
}
|
|
27020
27031
|
assertInScope("hubs", hubId);
|
|
27021
|
-
|
|
27032
|
+
const hubFolder = existingFolder ?? resolveHubFolder(
|
|
27033
|
+
workspaceDir,
|
|
27034
|
+
hubId,
|
|
27035
|
+
payload.hub.name,
|
|
27036
|
+
payload.hub_environment,
|
|
27037
|
+
payload.preview_label,
|
|
27038
|
+
payload.branch_name
|
|
27039
|
+
);
|
|
27022
27040
|
let wroteFiles = false;
|
|
27023
|
-
if (!hubFolder) {
|
|
27024
|
-
hubFolder = resolveHubFolder(
|
|
27025
|
-
workspaceDir,
|
|
27026
|
-
hubId,
|
|
27027
|
-
payload.hub.name,
|
|
27028
|
-
payload.hub_environment,
|
|
27029
|
-
payload.preview_label,
|
|
27030
|
-
payload.branch_name
|
|
27031
|
-
);
|
|
27041
|
+
if (!existingFolder && !resolveHubYamlPath(hubFolder)) {
|
|
27032
27042
|
fs18.mkdirSync(path24.dirname(hubFolder), { recursive: true });
|
|
27033
27043
|
console.log("Writing hub configuration...");
|
|
27034
27044
|
await materializeHubFolder(hubFolder, payload);
|
|
@@ -27037,18 +27047,23 @@ async function pullCommand(args2) {
|
|
|
27037
27047
|
wroteFiles = true;
|
|
27038
27048
|
} else {
|
|
27039
27049
|
let action = "overwrite";
|
|
27050
|
+
const replaceWithoutDiff = (why, err) => confirmReplaceWithoutDiff(why, err, hubFolder, hubId, autoConfirm);
|
|
27040
27051
|
let localPayload;
|
|
27041
27052
|
try {
|
|
27042
|
-
localPayload = parseHubFolder(hubFolder);
|
|
27053
|
+
localPayload = parseHubFolder(hubFolder, { strict: true });
|
|
27043
27054
|
} catch (err) {
|
|
27044
27055
|
if (isWorkspaceRefusal(err)) throw err;
|
|
27056
|
+
if (!await replaceWithoutDiff(UNREADABLE_LOCAL, err)) {
|
|
27057
|
+
console.log("Cancelled.");
|
|
27058
|
+
return;
|
|
27059
|
+
}
|
|
27045
27060
|
}
|
|
27046
27061
|
let diffResult;
|
|
27047
27062
|
if (localPayload) {
|
|
27048
27063
|
try {
|
|
27049
27064
|
diffResult = await client.diff(hubId, prepareResourcePayload(localPayload, payload), "pull", organizationId);
|
|
27050
27065
|
} catch (err) {
|
|
27051
|
-
if (!await
|
|
27066
|
+
if (!await replaceWithoutDiff(UNCOMPARABLE_LOCAL, err)) {
|
|
27052
27067
|
console.log("Cancelled.");
|
|
27053
27068
|
return;
|
|
27054
27069
|
}
|
|
@@ -27095,8 +27110,9 @@ async function pullCommand(args2) {
|
|
|
27095
27110
|
await mirrorLinkedProduction2(client, workspaceDir, payload.production_hub_id, organizationId);
|
|
27096
27111
|
}
|
|
27097
27112
|
}
|
|
27098
|
-
async function confirmReplaceWithoutDiff(err, hubFolder, hubId, autoConfirm) {
|
|
27099
|
-
console.log(
|
|
27113
|
+
async function confirmReplaceWithoutDiff(why, err, hubFolder, hubId, autoConfirm) {
|
|
27114
|
+
console.log(`
|
|
27115
|
+
${why}`);
|
|
27100
27116
|
console.log(` ${err instanceof Error ? err.message : String(err)}`);
|
|
27101
27117
|
if (!autoConfirm) {
|
|
27102
27118
|
return confirm("Replace the local files with the platform configuration, discarding any local edits?");
|
|
@@ -27147,7 +27163,7 @@ function connectionsEqual(a, b) {
|
|
|
27147
27163
|
}
|
|
27148
27164
|
return true;
|
|
27149
27165
|
}
|
|
27150
|
-
var MIRROR_MARKER_PREFIX2;
|
|
27166
|
+
var UNREADABLE_LOCAL, UNCOMPARABLE_LOCAL, MIRROR_MARKER_PREFIX2;
|
|
27151
27167
|
var init_pull = __esm({
|
|
27152
27168
|
"src/commands/pull.ts"() {
|
|
27153
27169
|
"use strict";
|
|
@@ -27165,6 +27181,8 @@ var init_pull = __esm({
|
|
|
27165
27181
|
init_repo_config();
|
|
27166
27182
|
init_worktree_scope();
|
|
27167
27183
|
init_subtree_routing();
|
|
27184
|
+
UNREADABLE_LOCAL = "The CLI could not read your local files, so the changes cannot be listed:";
|
|
27185
|
+
UNCOMPARABLE_LOCAL = "The platform could not compare your local files, so the changes cannot be listed:";
|
|
27168
27186
|
MIRROR_MARKER_PREFIX2 = "# Read-only mirror of production hub";
|
|
27169
27187
|
}
|
|
27170
27188
|
});
|