@wayai/cli 0.3.163 → 0.3.164

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 CHANGED
@@ -20449,6 +20449,16 @@ function writeFileNoFollow(root, abs, data) {
20449
20449
  fs9.writeFileSync(abs, data);
20450
20450
  return true;
20451
20451
  }
20452
+ function createFileNoFollow(root, abs, data) {
20453
+ if (!ensureRealSubdirNoSymlink(root, path10.dirname(abs), true)) return "refused";
20454
+ try {
20455
+ fs9.writeFileSync(abs, data, { flag: "wx" });
20456
+ } catch (err) {
20457
+ if (err.code === "EEXIST") return "exists";
20458
+ throw err;
20459
+ }
20460
+ return "created";
20461
+ }
20452
20462
  var init_fs_safety = __esm({
20453
20463
  "src/lib/fs-safety.ts"() {
20454
20464
  "use strict";
@@ -21295,7 +21305,6 @@ var init_diff_display = __esm({
21295
21305
  });
21296
21306
 
21297
21307
  // src/lib/workspace-files.ts
21298
- import * as fs13 from "fs";
21299
21308
  import * as path14 from "path";
21300
21309
  function perHubAgentsMd(hubFolderName) {
21301
21310
  return [
@@ -21311,19 +21320,18 @@ function perHubAgentsMd(hubFolderName) {
21311
21320
  ""
21312
21321
  ].join("\n");
21313
21322
  }
21314
- function writeIfAbsent(filePath, content) {
21315
- if (fs13.existsSync(filePath)) return null;
21316
- fs13.writeFileSync(filePath, content, "utf-8");
21317
- return path14.basename(filePath);
21323
+ function writeIfAbsent(root, filePath, content) {
21324
+ return createFileNoFollow(root, filePath, Buffer.from(content, "utf-8")) === "created" ? path14.basename(filePath) : null;
21318
21325
  }
21319
21326
  var init_workspace_files = __esm({
21320
21327
  "src/lib/workspace-files.ts"() {
21321
21328
  "use strict";
21329
+ init_fs_safety();
21322
21330
  }
21323
21331
  });
21324
21332
 
21325
21333
  // src/lib/yaml-writer.ts
21326
- import * as fs14 from "fs";
21334
+ import * as fs13 from "fs";
21327
21335
  import * as path15 from "path";
21328
21336
  import * as yaml7 from "js-yaml";
21329
21337
  function writeFileIfChanged(hubFolder, absPath, content, log) {
@@ -21374,11 +21382,11 @@ function buildEvalYamlObject(evalEntry, slug) {
21374
21382
  function writeHubFolder(hubFolder, payload, options = {}) {
21375
21383
  const log = { changed: [], removed: [] };
21376
21384
  const agentsDir = path15.join(hubFolder, "agents");
21377
- if (!fs14.existsSync(hubFolder)) {
21378
- fs14.mkdirSync(hubFolder, { recursive: true });
21385
+ if (!fs13.existsSync(hubFolder)) {
21386
+ fs13.mkdirSync(hubFolder, { recursive: true });
21379
21387
  }
21380
- if (!fs14.existsSync(agentsDir)) {
21381
- fs14.mkdirSync(agentsDir, { recursive: true });
21388
+ if (!fs13.existsSync(agentsDir)) {
21389
+ fs13.mkdirSync(agentsDir, { recursive: true });
21382
21390
  }
21383
21391
  const yamlPayload = buildYamlPayload(payload);
21384
21392
  const agentFiles = extractAgentFiles(payload);
@@ -21386,14 +21394,15 @@ function writeHubFolder(hubFolder, payload, options = {}) {
21386
21394
  writeFileIfChanged(hubFolder, path15.join(hubFolder, "hub.yaml"), yamlContent, log);
21387
21395
  if (options.seedAgentContext ?? true) {
21388
21396
  const seeded = writeIfAbsent(
21397
+ hubFolder,
21389
21398
  path15.join(hubFolder, "AGENTS.md"),
21390
21399
  perHubAgentsMd(path15.basename(hubFolder))
21391
21400
  );
21392
21401
  if (seeded) log.changed.push(seeded);
21393
21402
  }
21394
21403
  const oldYamlPath = path15.join(hubFolder, "wayai.yaml");
21395
- if (fs14.existsSync(oldYamlPath)) {
21396
- fs14.unlinkSync(oldYamlPath);
21404
+ if (fs13.existsSync(oldYamlPath)) {
21405
+ fs13.unlinkSync(oldYamlPath);
21397
21406
  log.removed.push(path15.relative(hubFolder, oldYamlPath));
21398
21407
  }
21399
21408
  const yamlSlugs = writeAgentYamlFiles(hubFolder, agentsDir, payload.agents || [], log);
@@ -21402,20 +21411,20 @@ function writeHubFolder(hubFolder, payload, options = {}) {
21402
21411
  mdSlugs.add(slug);
21403
21412
  writeFileIfChanged(hubFolder, path15.join(agentsDir, `${slug}.md`), content, log);
21404
21413
  }
21405
- const existingFiles = fs14.readdirSync(agentsDir);
21414
+ const existingFiles = fs13.readdirSync(agentsDir);
21406
21415
  for (const file of existingFiles) {
21407
21416
  if (file.endsWith(".yaml")) {
21408
21417
  const slug = file.slice(0, -5);
21409
21418
  if (!yamlSlugs.has(slug)) {
21410
21419
  const orphan = path15.join(agentsDir, file);
21411
- fs14.unlinkSync(orphan);
21420
+ fs13.unlinkSync(orphan);
21412
21421
  log.removed.push(path15.relative(hubFolder, orphan));
21413
21422
  }
21414
21423
  } else if (file.endsWith(".md")) {
21415
21424
  const slug = file.slice(0, -3);
21416
21425
  if (!mdSlugs.has(slug)) {
21417
21426
  const orphan = path15.join(agentsDir, file);
21418
- fs14.unlinkSync(orphan);
21427
+ fs13.unlinkSync(orphan);
21419
21428
  log.removed.push(path15.relative(hubFolder, orphan));
21420
21429
  }
21421
21430
  }
@@ -21428,10 +21437,10 @@ function writeHubFolder(hubFolder, payload, options = {}) {
21428
21437
  function setPreviewLabelInHubYaml(hubFolder, label) {
21429
21438
  const yamlPath = resolveHubYamlPath(hubFolder);
21430
21439
  if (!yamlPath) return;
21431
- const obj = yaml7.load(fs14.readFileSync(yamlPath, "utf-8")) ?? {};
21440
+ const obj = yaml7.load(fs13.readFileSync(yamlPath, "utf-8")) ?? {};
21432
21441
  if (label) obj.preview_label = label;
21433
21442
  else delete obj.preview_label;
21434
- fs14.writeFileSync(yamlPath, yaml7.dump(obj, YAML_DUMP_OPTIONS), "utf-8");
21443
+ fs13.writeFileSync(yamlPath, yaml7.dump(obj, YAML_DUMP_OPTIONS), "utf-8");
21435
21444
  }
21436
21445
  function buildYamlPayload(payload) {
21437
21446
  const result = {
@@ -21496,17 +21505,17 @@ function extractAgentFiles(payload) {
21496
21505
  function writeEvalYamlFiles(hubFolder, evals, log) {
21497
21506
  const evalsDir = path15.join(hubFolder, "evals");
21498
21507
  if (evals.length === 0) {
21499
- if (fs14.existsSync(evalsDir)) {
21508
+ if (fs13.existsSync(evalsDir)) {
21500
21509
  cleanEvalOrphans(hubFolder, evalsDir, /* @__PURE__ */ new Set(), log);
21501
21510
  try {
21502
- if (fs14.readdirSync(evalsDir).length === 0) fs14.rmdirSync(evalsDir);
21511
+ if (fs13.readdirSync(evalsDir).length === 0) fs13.rmdirSync(evalsDir);
21503
21512
  } catch {
21504
21513
  }
21505
21514
  }
21506
21515
  return;
21507
21516
  }
21508
- if (!fs14.existsSync(evalsDir)) {
21509
- fs14.mkdirSync(evalsDir, { recursive: true });
21517
+ if (!fs13.existsSync(evalsDir)) {
21518
+ fs13.mkdirSync(evalsDir, { recursive: true });
21510
21519
  }
21511
21520
  const writtenRelPaths = /* @__PURE__ */ new Set();
21512
21521
  for (const evalEntry of evals) {
@@ -21520,8 +21529,8 @@ function writeEvalYamlFiles(hubFolder, evals, log) {
21520
21529
  }
21521
21530
  if (setName) {
21522
21531
  const setDir = path15.join(evalsDir, setName);
21523
- if (!fs14.existsSync(setDir)) {
21524
- fs14.mkdirSync(setDir, { recursive: true });
21532
+ if (!fs13.existsSync(setDir)) {
21533
+ fs13.mkdirSync(setDir, { recursive: true });
21525
21534
  }
21526
21535
  }
21527
21536
  const yamlContent = yaml7.dump(buildEvalYamlObject(evalEntry, slug), YAML_DUMP_OPTIONS);
@@ -21531,31 +21540,31 @@ function writeEvalYamlFiles(hubFolder, evals, log) {
21531
21540
  cleanEvalOrphans(hubFolder, evalsDir, writtenRelPaths, log);
21532
21541
  }
21533
21542
  function cleanEvalOrphans(hubFolder, evalsDir, writtenRelPaths, log) {
21534
- const entries = fs14.readdirSync(evalsDir, { withFileTypes: true });
21543
+ const entries = fs13.readdirSync(evalsDir, { withFileTypes: true });
21535
21544
  for (const entry of entries) {
21536
21545
  const fullPath = path15.join(evalsDir, entry.name);
21537
21546
  if (entry.isFile()) {
21538
21547
  if (entry.name.endsWith(".yaml") && !writtenRelPaths.has(entry.name)) {
21539
- fs14.unlinkSync(fullPath);
21548
+ fs13.unlinkSync(fullPath);
21540
21549
  log.removed.push(path15.relative(hubFolder, fullPath));
21541
21550
  }
21542
21551
  continue;
21543
21552
  }
21544
21553
  if (entry.isDirectory()) {
21545
21554
  const setName = entry.name;
21546
- const subEntries = fs14.readdirSync(fullPath, { withFileTypes: true });
21555
+ const subEntries = fs13.readdirSync(fullPath, { withFileTypes: true });
21547
21556
  for (const sub of subEntries) {
21548
21557
  if (sub.isFile() && sub.name.endsWith(".yaml")) {
21549
21558
  const relPath = `${setName}/${sub.name}`;
21550
21559
  if (!writtenRelPaths.has(relPath)) {
21551
21560
  const orphan = path15.join(fullPath, sub.name);
21552
- fs14.unlinkSync(orphan);
21561
+ fs13.unlinkSync(orphan);
21553
21562
  log.removed.push(path15.relative(hubFolder, orphan));
21554
21563
  }
21555
21564
  }
21556
21565
  }
21557
21566
  try {
21558
- if (fs14.readdirSync(fullPath).length === 0) fs14.rmdirSync(fullPath);
21567
+ if (fs13.readdirSync(fullPath).length === 0) fs13.rmdirSync(fullPath);
21559
21568
  } catch {
21560
21569
  }
21561
21570
  }
@@ -21594,17 +21603,17 @@ function buildJourneyYamlObject(journeyEntry, slug) {
21594
21603
  function writeJourneyYamlFiles(hubFolder, journeys, log) {
21595
21604
  const journeysDir = path15.join(hubFolder, "journeys");
21596
21605
  if (journeys.length === 0) {
21597
- if (fs14.existsSync(journeysDir)) {
21606
+ if (fs13.existsSync(journeysDir)) {
21598
21607
  cleanJourneyOrphans(hubFolder, journeysDir, /* @__PURE__ */ new Set(), log);
21599
21608
  try {
21600
- if (fs14.readdirSync(journeysDir).length === 0) fs14.rmdirSync(journeysDir);
21609
+ if (fs13.readdirSync(journeysDir).length === 0) fs13.rmdirSync(journeysDir);
21601
21610
  } catch {
21602
21611
  }
21603
21612
  }
21604
21613
  return;
21605
21614
  }
21606
- if (!fs14.existsSync(journeysDir)) {
21607
- fs14.mkdirSync(journeysDir, { recursive: true });
21615
+ if (!fs13.existsSync(journeysDir)) {
21616
+ fs13.mkdirSync(journeysDir, { recursive: true });
21608
21617
  }
21609
21618
  const writtenFiles = /* @__PURE__ */ new Set();
21610
21619
  const usedSlugs = /* @__PURE__ */ new Set();
@@ -21618,11 +21627,11 @@ function writeJourneyYamlFiles(hubFolder, journeys, log) {
21618
21627
  cleanJourneyOrphans(hubFolder, journeysDir, writtenFiles, log);
21619
21628
  }
21620
21629
  function cleanJourneyOrphans(hubFolder, journeysDir, writtenFiles, log) {
21621
- const entries = fs14.readdirSync(journeysDir, { withFileTypes: true });
21630
+ const entries = fs13.readdirSync(journeysDir, { withFileTypes: true });
21622
21631
  for (const entry of entries) {
21623
21632
  if (entry.isFile() && entry.name.endsWith(".yaml") && !writtenFiles.has(entry.name)) {
21624
21633
  const orphan = path15.join(journeysDir, entry.name);
21625
- fs14.unlinkSync(orphan);
21634
+ fs13.unlinkSync(orphan);
21626
21635
  log.removed.push(path15.relative(hubFolder, orphan));
21627
21636
  }
21628
21637
  }
@@ -21636,12 +21645,12 @@ function writeResourceFiles(hubFolder, resources, log) {
21636
21645
  const resDir = path15.join(resourcesDir, resSlug);
21637
21646
  writeResourceFileTree(resDir, resource.files || [], hubFolder, log);
21638
21647
  }
21639
- if (fs14.existsSync(resourcesDir)) {
21640
- const existingDirs = fs14.readdirSync(resourcesDir, { withFileTypes: true });
21648
+ if (fs13.existsSync(resourcesDir)) {
21649
+ const existingDirs = fs13.readdirSync(resourcesDir, { withFileTypes: true });
21641
21650
  for (const entry of existingDirs) {
21642
21651
  if (entry.isDirectory() && !currentSlugs.has(entry.name)) {
21643
21652
  const orphanDir = path15.join(resourcesDir, entry.name);
21644
- fs14.rmSync(orphanDir, { recursive: true, force: true });
21653
+ fs13.rmSync(orphanDir, { recursive: true, force: true });
21645
21654
  log.removed.push(`${path15.relative(hubFolder, orphanDir)}/`);
21646
21655
  }
21647
21656
  }
@@ -21730,7 +21739,7 @@ var init_terminal_output = __esm({
21730
21739
  });
21731
21740
 
21732
21741
  // src/lib/base-workspace.ts
21733
- import * as fs15 from "fs";
21742
+ import * as fs14 from "fs";
21734
21743
  import * as path17 from "path";
21735
21744
  import * as yaml8 from "js-yaml";
21736
21745
  function readBaseMeta(folder) {
@@ -21748,7 +21757,7 @@ function readBaseMeta(folder) {
21748
21757
  function listBaseFolders(basesDir) {
21749
21758
  let entries;
21750
21759
  try {
21751
- entries = fs15.readdirSync(basesDir).filter((entry) => !entry.startsWith("."));
21760
+ entries = fs14.readdirSync(basesDir).filter((entry) => !entry.startsWith("."));
21752
21761
  } catch {
21753
21762
  return [];
21754
21763
  }
@@ -21835,7 +21844,7 @@ function resolveBaseSelectorToId(gitRoot, selector) {
21835
21844
  }
21836
21845
  function hasBaseMetaFile(folder) {
21837
21846
  try {
21838
- return fs15.lstatSync(path17.join(folder, BASE_META_FILE)).isFile();
21847
+ return fs14.lstatSync(path17.join(folder, BASE_META_FILE)).isFile();
21839
21848
  } catch {
21840
21849
  return false;
21841
21850
  }
@@ -22301,7 +22310,7 @@ var init_types2 = __esm({
22301
22310
  });
22302
22311
 
22303
22312
  // src/data/config-as-code/config-writer.ts
22304
- import * as fs16 from "fs";
22313
+ import * as fs15 from "fs";
22305
22314
  import * as path19 from "path";
22306
22315
  import * as yaml9 from "js-yaml";
22307
22316
  function dump5(value) {
@@ -22336,14 +22345,14 @@ function pruneOrphans(folder, dir, keep, log) {
22336
22345
  if (!ensureRealSubdirNoSymlink(folder, dir, false)) return;
22337
22346
  let entries;
22338
22347
  try {
22339
- entries = fs16.readdirSync(dir);
22348
+ entries = fs15.readdirSync(dir);
22340
22349
  } catch {
22341
22350
  return;
22342
22351
  }
22343
22352
  for (const file of entries) {
22344
22353
  if (!file.endsWith(".yaml") || keep.has(file)) continue;
22345
22354
  const abs = path19.join(dir, file);
22346
- fs16.rmSync(abs);
22355
+ fs15.rmSync(abs);
22347
22356
  log.removed.push(path19.relative(folder, abs));
22348
22357
  }
22349
22358
  }
@@ -22357,7 +22366,7 @@ function metaFileObject(meta) {
22357
22366
  function writeBaseFolder(folder, meta, config) {
22358
22367
  const delta = { changed: [], removed: [] };
22359
22368
  const parent = path19.dirname(folder);
22360
- fs16.mkdirSync(parent, { recursive: true });
22369
+ fs15.mkdirSync(parent, { recursive: true });
22361
22370
  if (!ensureRealSubdirNoSymlink(parent, folder, true)) {
22362
22371
  throw expected(
22363
22372
  `Refusing to write ${folder}: the path crosses a symlink. Remove it and pull again.`
@@ -22384,7 +22393,7 @@ function writeBaseFolder(folder, meta, config) {
22384
22393
  for (const deprecated of DEPRECATED_ENTITY_DIRS) {
22385
22394
  const dir = path19.join(folder, deprecated);
22386
22395
  if (ensureRealSubdirNoSymlink(folder, dir, false)) {
22387
- fs16.rmSync(dir, { recursive: true, force: true });
22396
+ fs15.rmSync(dir, { recursive: true, force: true });
22388
22397
  }
22389
22398
  }
22390
22399
  return delta;
@@ -22536,7 +22545,7 @@ var init_api = __esm({
22536
22545
  });
22537
22546
 
22538
22547
  // src/data/config-as-code/config-parser.ts
22539
- import * as fs17 from "fs";
22548
+ import * as fs16 from "fs";
22540
22549
  import * as path20 from "path";
22541
22550
  import * as yaml10 from "js-yaml";
22542
22551
  function readEntityDir(folder, dir) {
@@ -22545,7 +22554,7 @@ function readEntityDir(folder, dir) {
22545
22554
  }
22546
22555
  if (!isDirectory(dir)) return [];
22547
22556
  const out = [];
22548
- for (const file of fs17.readdirSync(dir).sort()) {
22557
+ for (const file of fs16.readdirSync(dir).sort()) {
22549
22558
  if (!file.endsWith(".yaml")) continue;
22550
22559
  const abs = path20.join(dir, file);
22551
22560
  const bytes = readFileNoFollow(folder, abs);
@@ -22932,7 +22941,7 @@ __export(push_exports, {
22932
22941
  shouldWarnIgnoredPreviewLabel: () => shouldWarnIgnoredPreviewLabel,
22933
22942
  syncAfterPush: () => syncAfterPush
22934
22943
  });
22935
- import * as fs18 from "fs";
22944
+ import * as fs17 from "fs";
22936
22945
  import * as path22 from "path";
22937
22946
  import * as yaml11 from "js-yaml";
22938
22947
  function parseArgs5(args2) {
@@ -23043,11 +23052,11 @@ function printLocalFileChanges(delta) {
23043
23052
  async function autoRenameAgentFiles(client, hubId, hubFolder, organizationId, remoteConfig) {
23044
23053
  const agentsDir = path22.join(hubFolder, "agents");
23045
23054
  let agentsWithIds = [];
23046
- if (fs18.existsSync(agentsDir)) {
23047
- const yamlFiles = fs18.readdirSync(agentsDir).filter((f) => f.endsWith(".yaml"));
23055
+ if (fs17.existsSync(agentsDir)) {
23056
+ const yamlFiles = fs17.readdirSync(agentsDir).filter((f) => f.endsWith(".yaml"));
23048
23057
  for (const file of yamlFiles) {
23049
23058
  try {
23050
- const content = fs18.readFileSync(path22.join(agentsDir, file), "utf-8");
23059
+ const content = fs17.readFileSync(path22.join(agentsDir, file), "utf-8");
23051
23060
  const agent = yaml11.load(content);
23052
23061
  if (agent?.id && agent.name) {
23053
23062
  agentsWithIds.push({ id: agent.id, name: agent.name });
@@ -23060,7 +23069,7 @@ async function autoRenameAgentFiles(client, hubId, hubFolder, organizationId, re
23060
23069
  if (agentsWithIds.length === 0) {
23061
23070
  const yamlPath = resolveHubYamlPath(hubFolder);
23062
23071
  if (!yamlPath) return;
23063
- const yamlContent = fs18.readFileSync(yamlPath, "utf-8");
23072
+ const yamlContent = fs17.readFileSync(yamlPath, "utf-8");
23064
23073
  const config = yaml11.load(yamlContent);
23065
23074
  agentsWithIds = (config.agents || []).filter((a) => !!a.id && !!a.name);
23066
23075
  }
@@ -23092,18 +23101,18 @@ async function autoRenameAgentFiles(client, hubId, hubFolder, organizationId, re
23092
23101
  }
23093
23102
  }
23094
23103
  if (renames.length === 0) return;
23095
- if (!fs18.existsSync(agentsDir)) return;
23096
- for (const file of fs18.readdirSync(agentsDir)) {
23104
+ if (!fs17.existsSync(agentsDir)) return;
23105
+ for (const file of fs17.readdirSync(agentsDir)) {
23097
23106
  if (file.startsWith("__rename_temp_") && (file.endsWith(".md") || file.endsWith(".yaml"))) {
23098
23107
  console.warn(` Warning: removing orphaned temp file agents/${file}`);
23099
- fs18.unlinkSync(path22.join(agentsDir, file));
23108
+ fs17.unlinkSync(path22.join(agentsDir, file));
23100
23109
  }
23101
23110
  }
23102
23111
  const renameFileIfExists = (dir, oldName, newName) => {
23103
23112
  const oldPath = path22.join(dir, oldName);
23104
23113
  const newPath = path22.join(dir, newName);
23105
- if (!fs18.existsSync(oldPath)) return false;
23106
- fs18.renameSync(oldPath, newPath);
23114
+ if (!fs17.existsSync(oldPath)) return false;
23115
+ fs17.renameSync(oldPath, newPath);
23107
23116
  return true;
23108
23117
  };
23109
23118
  const oldSlugs = new Set(renames.map((r) => r.oldSlug));
@@ -23136,9 +23145,9 @@ async function autoRenameAgentFiles(client, hubId, hubFolder, organizationId, re
23136
23145
  }
23137
23146
  } else {
23138
23147
  for (const { oldSlug, newSlug } of renames) {
23139
- const hasOldFile = extensions.some((ext) => fs18.existsSync(path22.join(agentsDir, `${oldSlug}${ext}`)));
23148
+ const hasOldFile = extensions.some((ext) => fs17.existsSync(path22.join(agentsDir, `${oldSlug}${ext}`)));
23140
23149
  if (!hasOldFile) continue;
23141
- const hasNewFile = extensions.some((ext) => fs18.existsSync(path22.join(agentsDir, `${newSlug}${ext}`)));
23150
+ const hasNewFile = extensions.some((ext) => fs17.existsSync(path22.join(agentsDir, `${newSlug}${ext}`)));
23142
23151
  if (hasNewFile) {
23143
23152
  console.warn(` Warning: skipping rename agents/${oldSlug}.* \u2192 agents/${newSlug}.* (target already exists)`);
23144
23153
  continue;
@@ -23153,7 +23162,7 @@ async function autoRenameAgentFiles(client, hubId, hubFolder, organizationId, re
23153
23162
  if (completedRenames.length === 0) return;
23154
23163
  const mainYamlPath = resolveHubYamlPath(hubFolder);
23155
23164
  if (mainYamlPath) {
23156
- const mainYamlContent = fs18.readFileSync(mainYamlPath, "utf-8");
23165
+ const mainYamlContent = fs17.readFileSync(mainYamlPath, "utf-8");
23157
23166
  const substitutionMap = /* @__PURE__ */ new Map();
23158
23167
  for (const { oldSlug, newSlug } of completedRenames) {
23159
23168
  substitutionMap.set(`agents/${oldSlug}.md`, `agents/${newSlug}.md`);
@@ -23164,7 +23173,7 @@ async function autoRenameAgentFiles(client, hubId, hubFolder, organizationId, re
23164
23173
  (_match, prefix, pathMatch) => `${prefix}${substitutionMap.get(pathMatch) ?? pathMatch}`
23165
23174
  );
23166
23175
  if (updatedYaml !== mainYamlContent) {
23167
- fs18.writeFileSync(mainYamlPath, updatedYaml, "utf-8");
23176
+ fs17.writeFileSync(mainYamlPath, updatedYaml, "utf-8");
23168
23177
  console.log(` Updated instructions paths in ${path22.basename(mainYamlPath)}`);
23169
23178
  }
23170
23179
  }
@@ -23276,7 +23285,7 @@ New hub: "${newHub.hubName}" (${hubType})`);
23276
23285
  process.exit(1);
23277
23286
  }
23278
23287
  console.log(`Hub created: ${createdHub.hub_name} (${hubId})`);
23279
- const content = fs18.readFileSync(hubYamlPath, "utf-8");
23288
+ const content = fs17.readFileSync(hubYamlPath, "utf-8");
23280
23289
  const hasVersion = content.match(/^version:\s/m);
23281
23290
  let updated;
23282
23291
  if (hasVersion) {
@@ -23292,7 +23301,7 @@ hub_id: "${hubId}"
23292
23301
  hub_environment: preview
23293
23302
  ${content}`;
23294
23303
  }
23295
- fs18.writeFileSync(hubYamlPath, updated, "utf-8");
23304
+ fs17.writeFileSync(hubYamlPath, updated, "utf-8");
23296
23305
  seedScopeIfEmpty("hubs", hubId);
23297
23306
  await pushSingleHub(client, hubId, newHub.hubFolder, opts.autoConfirm, opts.organizationId, { skipAgentRename: true });
23298
23307
  }
@@ -23338,7 +23347,7 @@ async function pushCommand(args2) {
23338
23347
  const client = new ApiClient({ apiUrl: config.api_url, accessToken });
23339
23348
  const workspaceDir = resolveWorkspaceDir();
23340
23349
  const wsLabel = hubsDirLabel(gitRoot);
23341
- if (!fs18.existsSync(workspaceDir)) {
23350
+ if (!fs17.existsSync(workspaceDir)) {
23342
23351
  console.error(`No ${wsLabel}/ directory found. Run \`wayai pull\` first or create hub files in ${wsLabel}/<hub>/hub.yaml.`);
23343
23352
  process.exit(1);
23344
23353
  }
@@ -23394,7 +23403,7 @@ __export(pull_exports, {
23394
23403
  resolveHubTarget: () => resolveHubTarget,
23395
23404
  writeProductionMirror: () => writeProductionMirror2
23396
23405
  });
23397
- import * as fs19 from "fs";
23406
+ import * as fs18 from "fs";
23398
23407
  import * as path23 from "path";
23399
23408
  function parseArgs6(args2) {
23400
23409
  return { autoConfirm: args2.includes("--yes") || args2.includes("-y") };
@@ -23461,7 +23470,7 @@ async function pullCommand(args2) {
23461
23470
  payload.preview_label,
23462
23471
  payload.branch_name
23463
23472
  );
23464
- fs19.mkdirSync(path23.dirname(hubFolder), { recursive: true });
23473
+ fs18.mkdirSync(path23.dirname(hubFolder), { recursive: true });
23465
23474
  console.log("Writing hub configuration...");
23466
23475
  await materializeHubFolder(hubFolder, payload);
23467
23476
  const finalFolder = autoRenameHubFolder(hubFolder, payload.hub.name, payload.hub_environment, payload.hub_id, payload.preview_label, payload.branch_name);
@@ -23515,7 +23524,7 @@ async function pullCommand(args2) {
23515
23524
  }
23516
23525
  async function writeProductionMirror2(workspaceDir, prodPayload) {
23517
23526
  const folder = resolveHubFolder(workspaceDir, prodPayload.hub_id, prodPayload.hub.name, "production", null, null);
23518
- fs19.mkdirSync(path23.dirname(folder), { recursive: true });
23527
+ fs18.mkdirSync(path23.dirname(folder), { recursive: true });
23519
23528
  await materializeHubFolder(folder, prodPayload, { seedAgentContext: false });
23520
23529
  const finalFolder = autoRenameHubFolder(folder, prodPayload.hub.name, "production", prodPayload.hub_id, null, null);
23521
23530
  prependMirrorMarker(finalFolder, prodPayload.hub_id);
@@ -23533,11 +23542,11 @@ async function mirrorLinkedProduction2(client, workspaceDir, productionHubId, or
23533
23542
  function prependMirrorMarker(hubFolder, productionHubId) {
23534
23543
  const hubYaml = path23.join(hubFolder, "hub.yaml");
23535
23544
  try {
23536
- const content = fs19.readFileSync(hubYaml, "utf-8");
23545
+ const content = fs18.readFileSync(hubYaml, "utf-8");
23537
23546
  if (content.startsWith(MIRROR_MARKER_PREFIX2)) return;
23538
23547
  const marker = `${MIRROR_MARKER_PREFIX2} ${productionHubId}. Edits are ignored; push is blocked. Edit the linked preview hub instead.
23539
23548
  `;
23540
- fs19.writeFileSync(hubYaml, marker + content, "utf-8");
23549
+ fs18.writeFileSync(hubYaml, marker + content, "utf-8");
23541
23550
  } catch {
23542
23551
  }
23543
23552
  }
@@ -23581,7 +23590,7 @@ __export(create_exports, {
23581
23590
  createCommand: () => createCommand
23582
23591
  });
23583
23592
  import * as path24 from "path";
23584
- import * as fs20 from "fs";
23593
+ import * as fs19 from "fs";
23585
23594
  function parseArgs7(args2) {
23586
23595
  let autoConfirm = false;
23587
23596
  let folderSelector;
@@ -23608,7 +23617,7 @@ async function createCommand(args2) {
23608
23617
  const gitRoot = findGitRoot();
23609
23618
  const wsLabel = hubsDirLabel(gitRoot);
23610
23619
  if (gitRoot) warnLayoutOnce(gitRoot);
23611
- if (!fs20.existsSync(workspaceDir)) {
23620
+ if (!fs19.existsSync(workspaceDir)) {
23612
23621
  console.error(`No ${wsLabel}/ directory found. Create hub files in ${wsLabel}/<hub>/hub.yaml with \`hub: { name: ... }\` first.`);
23613
23622
  process.exit(1);
23614
23623
  }
@@ -23742,7 +23751,7 @@ var replicate_exports = {};
23742
23751
  __export(replicate_exports, {
23743
23752
  replicateCommand: () => replicateCommand
23744
23753
  });
23745
- import * as fs21 from "fs";
23754
+ import * as fs20 from "fs";
23746
23755
  import * as path25 from "path";
23747
23756
  function parseArgs9(args2) {
23748
23757
  let label;
@@ -23789,8 +23798,8 @@ async function replicateCommand(args2) {
23789
23798
  payload.preview_label,
23790
23799
  payload.branch_name
23791
23800
  );
23792
- const folderPreExisted = fs21.existsSync(hubFolder);
23793
- fs21.mkdirSync(path25.dirname(hubFolder), { recursive: true });
23801
+ const folderPreExisted = fs20.existsSync(hubFolder);
23802
+ fs20.mkdirSync(path25.dirname(hubFolder), { recursive: true });
23794
23803
  const delta = await materializeHubFolder(hubFolder, payload);
23795
23804
  hubFolder = autoRenameHubFolder(
23796
23805
  hubFolder,
@@ -24217,7 +24226,7 @@ __export(migrate_exports, {
24217
24226
  migrateCommand: () => migrateCommand
24218
24227
  });
24219
24228
  import { execFileSync as execFileSync3 } from "child_process";
24220
- import * as fs22 from "fs";
24229
+ import * as fs21 from "fs";
24221
24230
  import * as path29 from "path";
24222
24231
  function isTracked(gitRoot, p) {
24223
24232
  try {
@@ -24231,7 +24240,7 @@ function isTracked(gitRoot, p) {
24231
24240
  }
24232
24241
  }
24233
24242
  function moveDir(gitRoot, from, to) {
24234
- fs22.mkdirSync(path29.dirname(to), { recursive: true });
24243
+ fs21.mkdirSync(path29.dirname(to), { recursive: true });
24235
24244
  if (isTracked(gitRoot, from)) {
24236
24245
  try {
24237
24246
  execFileSync3("git", ["mv", path29.relative(gitRoot, from), path29.relative(gitRoot, to)], {
@@ -24242,7 +24251,7 @@ function moveDir(gitRoot, from, to) {
24242
24251
  } catch {
24243
24252
  }
24244
24253
  }
24245
- fs22.renameSync(from, to);
24254
+ fs21.renameSync(from, to);
24246
24255
  return "fs";
24247
24256
  }
24248
24257
  async function migrateCommand(_args) {
@@ -24405,12 +24414,12 @@ var send_message_exports = {};
24405
24414
  __export(send_message_exports, {
24406
24415
  sendMessageCommand: () => sendMessageCommand
24407
24416
  });
24408
- import * as fs23 from "fs";
24417
+ import * as fs22 from "fs";
24409
24418
  import * as path30 from "path";
24410
24419
  function statAttachment(filePath) {
24411
24420
  let stat2;
24412
24421
  try {
24413
- stat2 = fs23.statSync(filePath);
24422
+ stat2 = fs22.statSync(filePath);
24414
24423
  } catch {
24415
24424
  console.error(`Error: file not found: ${filePath}`);
24416
24425
  process.exit(1);
@@ -24426,7 +24435,7 @@ function readAttachment(filePath, size) {
24426
24435
  const ext = path30.extname(fileName).replace(/^\./, "");
24427
24436
  return {
24428
24437
  file_name: fileName,
24429
- file_binary: fs23.readFileSync(filePath).toString("base64"),
24438
+ file_binary: fs22.readFileSync(filePath).toString("base64"),
24430
24439
  file_size: size,
24431
24440
  ...ext && { file_extension: ext }
24432
24441
  };
@@ -26625,7 +26634,7 @@ var eval_capture_exports = {};
26625
26634
  __export(eval_capture_exports, {
26626
26635
  evalCaptureCommand: () => evalCaptureCommand
26627
26636
  });
26628
- import * as fs24 from "fs";
26637
+ import * as fs23 from "fs";
26629
26638
  import * as path31 from "path";
26630
26639
  import * as yaml12 from "js-yaml";
26631
26640
  function isValidSetName(name) {
@@ -26699,7 +26708,7 @@ async function evalCaptureCommand(args2) {
26699
26708
  console.error(`Resolved path "${path31.relative(hubFolder, targetPath)}" escapes evals/. Aborting.`);
26700
26709
  process.exit(1);
26701
26710
  }
26702
- if (fs24.existsSync(targetPath)) {
26711
+ if (fs23.existsSync(targetPath)) {
26703
26712
  console.error(`File already exists: ${path31.relative(hubFolder, targetPath)}. Use --name to choose a different name.`);
26704
26713
  process.exit(1);
26705
26714
  }
@@ -26732,8 +26741,8 @@ async function evalCaptureCommand(args2) {
26732
26741
  ...captured.evaluator_instructions ? { evaluator_instructions: captured.evaluator_instructions } : {}
26733
26742
  };
26734
26743
  const yamlObj = buildEvalYamlObject(evalEntry, slug);
26735
- fs24.mkdirSync(targetDir, { recursive: true });
26736
- fs24.writeFileSync(targetPath, yaml12.dump(yamlObj, YAML_DUMP_OPTIONS), "utf-8");
26744
+ fs23.mkdirSync(targetDir, { recursive: true });
26745
+ fs23.writeFileSync(targetPath, yaml12.dump(yamlObj, YAML_DUMP_OPTIONS), "utf-8");
26737
26746
  const relPath = path31.relative(process.cwd(), targetPath);
26738
26747
  console.log(`
26739
26748
  Wrote ${relPath}`);
@@ -28105,20 +28114,20 @@ var init_set_connection_credential = __esm({
28105
28114
  });
28106
28115
 
28107
28116
  // src/lib/org-workspace.ts
28108
- import * as fs25 from "fs";
28117
+ import * as fs24 from "fs";
28109
28118
  import * as path32 from "path";
28110
28119
  import * as yaml13 from "js-yaml";
28111
28120
  function getOrgDir(gitRoot) {
28112
28121
  return resolveLayout(gitRoot).orgDir;
28113
28122
  }
28114
28123
  function orgManifestExists(orgDir) {
28115
- return fs25.existsSync(path32.join(orgDir, ORG_MANIFEST_NAME));
28124
+ return fs24.existsSync(path32.join(orgDir, ORG_MANIFEST_NAME));
28116
28125
  }
28117
28126
  function parseOrgResources(orgDir) {
28118
28127
  const manifestPath = path32.join(orgDir, ORG_MANIFEST_NAME);
28119
28128
  let manifest = {};
28120
- if (fs25.existsSync(manifestPath)) {
28121
- manifest = yaml13.load(fs25.readFileSync(manifestPath, "utf-8")) ?? {};
28129
+ if (fs24.existsSync(manifestPath)) {
28130
+ manifest = yaml13.load(fs24.readFileSync(manifestPath, "utf-8")) ?? {};
28122
28131
  }
28123
28132
  const rawResources = Array.isArray(manifest.resources) ? manifest.resources : [];
28124
28133
  const resourcesDir = path32.join(orgDir, "resources");
@@ -28134,7 +28143,7 @@ function parseOrgResources(orgDir) {
28134
28143
  if (Array.isArray(res.tags)) resource.tags = res.tags;
28135
28144
  if (Array.isArray(res.folders)) resource.folders = res.folders;
28136
28145
  const resDir = path32.join(resourcesDir, slugify(resource.name));
28137
- if (fs25.existsSync(resDir)) {
28146
+ if (fs24.existsSync(resDir)) {
28138
28147
  const files = scanResourceFiles(resDir, "");
28139
28148
  if (files.length > 0) resource.files = files;
28140
28149
  }
@@ -28143,13 +28152,13 @@ function parseOrgResources(orgDir) {
28143
28152
  return { version: 1, resources };
28144
28153
  }
28145
28154
  function writeOrgResources(orgDir, payload) {
28146
- fs25.mkdirSync(orgDir, { recursive: true });
28155
+ fs24.mkdirSync(orgDir, { recursive: true });
28147
28156
  const resources = payload.resources ?? [];
28148
28157
  const manifestResources = resources.map((r) => {
28149
28158
  const { files: _files, ...rest } = r;
28150
28159
  return rest;
28151
28160
  });
28152
- fs25.writeFileSync(
28161
+ fs24.writeFileSync(
28153
28162
  path32.join(orgDir, ORG_MANIFEST_NAME),
28154
28163
  yaml13.dump({ version: 1, resources: manifestResources }, YAML_DUMP_OPTIONS),
28155
28164
  "utf-8"
@@ -28161,10 +28170,10 @@ function writeOrgResources(orgDir, payload) {
28161
28170
  currentSlugs.add(resSlug);
28162
28171
  writeResourceFileTree(path32.join(resourcesDir, resSlug), resource.files || [], orgDir);
28163
28172
  }
28164
- if (fs25.existsSync(resourcesDir)) {
28165
- for (const entry of fs25.readdirSync(resourcesDir, { withFileTypes: true })) {
28173
+ if (fs24.existsSync(resourcesDir)) {
28174
+ for (const entry of fs24.readdirSync(resourcesDir, { withFileTypes: true })) {
28166
28175
  if (entry.isDirectory() && !currentSlugs.has(entry.name)) {
28167
- fs25.rmSync(path32.join(resourcesDir, entry.name), { recursive: true, force: true });
28176
+ fs24.rmSync(path32.join(resourcesDir, entry.name), { recursive: true, force: true });
28168
28177
  }
28169
28178
  }
28170
28179
  }
@@ -28469,7 +28478,7 @@ var init_report_edit_args = __esm({
28469
28478
  });
28470
28479
 
28471
28480
  // src/lib/file-map.ts
28472
- import * as fs26 from "fs";
28481
+ import * as fs25 from "fs";
28473
28482
  import * as path33 from "path";
28474
28483
  function isSafeRelPath(rel) {
28475
28484
  if (rel.length === 0 || rel.length > 300) return false;
@@ -28486,8 +28495,8 @@ function writeFileMap(targetDir, files) {
28486
28495
  throw new Error(`Refusing to write unsafe path: ${rel}`);
28487
28496
  }
28488
28497
  const abs = path33.join(targetDir, rel);
28489
- fs26.mkdirSync(path33.dirname(abs), { recursive: true });
28490
- fs26.writeFileSync(abs, body, "utf-8");
28498
+ fs25.mkdirSync(path33.dirname(abs), { recursive: true });
28499
+ fs25.writeFileSync(abs, body, "utf-8");
28491
28500
  written.push(rel);
28492
28501
  }
28493
28502
  return written;
@@ -28503,7 +28512,7 @@ var admin_exports = {};
28503
28512
  __export(admin_exports, {
28504
28513
  adminCommand: () => adminCommand
28505
28514
  });
28506
- import * as fs27 from "fs";
28515
+ import * as fs26 from "fs";
28507
28516
  import * as path34 from "path";
28508
28517
  async function adminCommand(args2) {
28509
28518
  const [group, ...afterGroup] = args2;
@@ -28819,7 +28828,7 @@ async function runArchiveRead(positional, flagArgs) {
28819
28828
  exitOnApiError(err);
28820
28829
  throw err;
28821
28830
  }
28822
- fs27.writeFileSync(outPath, zip);
28831
+ fs26.writeFileSync(outPath, zip);
28823
28832
  console.log(`Wrote ${zip.byteLength} bytes to ${outPath}`);
28824
28833
  return;
28825
28834
  }
@@ -28961,7 +28970,7 @@ async function runSkillInstall(positional) {
28961
28970
  throw err;
28962
28971
  }
28963
28972
  const root = findGitRoot() ?? process.cwd();
28964
- const present = HARNESS_SKILL_DIRS.filter((dir) => fs27.existsSync(path34.join(root, dir)));
28973
+ const present = HARNESS_SKILL_DIRS.filter((dir) => fs26.existsSync(path34.join(root, dir)));
28965
28974
  const targets = present.length > 0 ? present : HARNESS_SKILL_DIRS;
28966
28975
  const fileCount = Object.keys(res.files).length;
28967
28976
  const relDirs = targets.map((harness) => {
@@ -30960,7 +30969,7 @@ var init_import = __esm({
30960
30969
 
30961
30970
  // src/data/commands/providers.ts
30962
30971
  import { Command as Command5 } from "commander";
30963
- import { writeFileSync as writeFileSync15 } from "fs";
30972
+ import { writeFileSync as writeFileSync14 } from "fs";
30964
30973
  function providerSegment(provider) {
30965
30974
  if (!VALID_PROVIDERS.includes(provider)) {
30966
30975
  throw expected(`Unknown provider ${JSON.stringify(provider)}. Expected one of: ${VALID_PROVIDERS_HELP}.`);
@@ -30993,7 +31002,7 @@ function buildBasesProvidersCommand() {
30993
31002
  );
30994
31003
  if (opts.to) {
30995
31004
  try {
30996
- writeFileSync15(opts.to, JSON.stringify(data, null, 2));
31005
+ writeFileSync14(opts.to, JSON.stringify(data, null, 2));
30997
31006
  } catch (e) {
30998
31007
  throw expected(`--to ${opts.to}: ${e instanceof Error ? e.message : "could not be written"}`);
30999
31008
  }
@@ -32078,7 +32087,7 @@ var init_file_types = __esm({
32078
32087
 
32079
32088
  // src/data/commands/files.ts
32080
32089
  import { Command as Command12 } from "commander";
32081
- import { readFileSync as readFileSync24, writeFileSync as writeFileSync16 } from "fs";
32090
+ import { readFileSync as readFileSync24, writeFileSync as writeFileSync15 } from "fs";
32082
32091
  import { basename as basename18 } from "path";
32083
32092
  function renderFileDiff(fileType, filePath, from, to, d) {
32084
32093
  console.log(sanitizeTerminalText(`${fileType}/${filePath}: v${from} \u2192 v${to}`));
@@ -32158,7 +32167,7 @@ function buildFilesCommand() {
32158
32167
  const { bytes } = await client.download(
32159
32168
  `/v1/${base}/files/${pathSegment(fileType, "file_type")}/${encoded}${versionQs ? `?${versionQs}` : ""}`
32160
32169
  );
32161
- writeFileSync16(out, bytes);
32170
+ writeFileSync15(out, bytes);
32162
32171
  console.log(`Downloaded to ${out}`);
32163
32172
  });
32164
32173
  files.command("history <file_type> <path>").description("List the content versions of a file (newest first)").option("--limit <n>", "Max versions to return").option("--offset <n>", "Pagination offset").action(async function(fileType, filePath, opts) {