@base44-preview/cli 0.0.34-pr.320.49b087d → 0.0.34-pr.321.2426836

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/index.js CHANGED
@@ -185389,16 +185389,18 @@ async function fetchAgents() {
185389
185389
  }
185390
185390
  // src/core/resources/agent/config.ts
185391
185391
  import { join as join3 } from "node:path";
185392
- import { isDeepStrictEqual } from "node:util";
185392
+ function toFileSlug(name2) {
185393
+ return name2.toLowerCase().replace(/[^a-z0-9_]/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "");
185394
+ }
185393
185395
  async function readAgentFile(agentPath) {
185394
- const raw2 = await readJsonFile(agentPath);
185395
- const result = AgentConfigSchema.safeParse(raw2);
185396
+ const parsed = await readJsonFile(agentPath);
185397
+ const result = AgentConfigSchema.safeParse(parsed);
185396
185398
  if (!result.success) {
185397
185399
  throw new SchemaValidationError("Invalid agent file", result.error, agentPath);
185398
185400
  }
185399
- return { data: result.data, raw: raw2 };
185401
+ return result.data;
185400
185402
  }
185401
- async function readAgentFiles(agentsDir) {
185403
+ async function readAllAgents(agentsDir) {
185402
185404
  if (!await pathExists(agentsDir)) {
185403
185405
  return [];
185404
185406
  }
@@ -185406,49 +185408,37 @@ async function readAgentFiles(agentsDir) {
185406
185408
  cwd: agentsDir,
185407
185409
  absolute: true
185408
185410
  });
185409
- return await Promise.all(files.map(async (filePath) => {
185410
- const { data, raw: raw2 } = await readAgentFile(filePath);
185411
- return { data, raw: raw2, filePath };
185412
- }));
185413
- }
185414
- async function readAllAgents(agentsDir) {
185415
- const entries = await readAgentFiles(agentsDir);
185411
+ const agents = await Promise.all(files.map((filePath) => readAgentFile(filePath)));
185416
185412
  const names = new Set;
185417
- for (const { data } of entries) {
185418
- if (names.has(data.name)) {
185419
- throw new Error(`Duplicate agent name "${data.name}"`);
185413
+ for (const agent of agents) {
185414
+ if (names.has(agent.name)) {
185415
+ throw new Error(`Duplicate agent name "${agent.name}"`);
185420
185416
  }
185421
- names.add(data.name);
185417
+ names.add(agent.name);
185422
185418
  }
185423
- return entries.map((e2) => e2.data);
185419
+ return agents;
185424
185420
  }
185425
185421
  async function writeAgents(agentsDir, remoteAgents) {
185426
- const entries = await readAgentFiles(agentsDir);
185427
- const nameToEntry = new Map;
185428
- for (const entry of entries) {
185429
- if (nameToEntry.has(entry.data.name)) {
185430
- throw new Error(`Duplicate agent name "${entry.data.name}"`);
185431
- }
185432
- nameToEntry.set(entry.data.name, entry);
185433
- }
185422
+ const existingAgents = await readAllAgents(agentsDir);
185434
185423
  const newNames = new Set(remoteAgents.map((a) => a.name));
185435
- const deleted = [];
185436
- for (const [name2, entry] of nameToEntry) {
185437
- if (!newNames.has(name2)) {
185438
- await deleteFile(entry.filePath);
185439
- deleted.push(name2);
185424
+ const toDelete = existingAgents.filter((a) => !newNames.has(a.name));
185425
+ for (const agent of toDelete) {
185426
+ const slug = toFileSlug(agent.name);
185427
+ const files = await globby(`${slug}.${CONFIG_FILE_EXTENSION_GLOB}`, {
185428
+ cwd: agentsDir,
185429
+ absolute: true
185430
+ });
185431
+ for (const filePath of files) {
185432
+ await deleteFile(filePath);
185440
185433
  }
185441
185434
  }
185442
- const written = [];
185443
185435
  for (const agent of remoteAgents) {
185444
- const existing = nameToEntry.get(agent.name);
185445
- if (existing && isDeepStrictEqual(existing.raw, agent)) {
185446
- continue;
185447
- }
185448
- const filePath = existing?.filePath ?? join3(agentsDir, `${agent.name}.${CONFIG_FILE_EXTENSION}`);
185436
+ const slug = toFileSlug(agent.name);
185437
+ const filePath = join3(agentsDir, `${slug}.${CONFIG_FILE_EXTENSION}`);
185449
185438
  await writeJsonFile(filePath, agent);
185450
- written.push(agent.name);
185451
185439
  }
185440
+ const written = remoteAgents.map((a) => a.name);
185441
+ const deleted = toDelete.map((a) => a.name);
185452
185442
  return { written, deleted };
185453
185443
  }
185454
185444
  // src/core/resources/agent/resource.ts
@@ -185665,7 +185655,7 @@ async function removeConnector(integrationType) {
185665
185655
  }
185666
185656
  // src/core/resources/connector/config.ts
185667
185657
  import { join as join4 } from "node:path";
185668
- import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
185658
+ import { isDeepStrictEqual } from "node:util";
185669
185659
  async function readConnectorFile(connectorPath) {
185670
185660
  const parsed = await readJsonFile(connectorPath);
185671
185661
  const result = ConnectorResourceSchema.safeParse(parsed);
@@ -185726,7 +185716,7 @@ async function writeConnectors(connectorsDir, remoteConnectors) {
185726
185716
  type: connector.integrationType,
185727
185717
  scopes: connector.scopes
185728
185718
  };
185729
- if (existing && isDeepStrictEqual2(existing.data, localConnector)) {
185719
+ if (existing && isDeepStrictEqual(existing.data, localConnector)) {
185730
185720
  continue;
185731
185721
  }
185732
185722
  const filePath = existing?.filePath ?? join4(connectorsDir, `${connector.integrationType}.${CONFIG_FILE_EXTENSION}`);
@@ -194219,11 +194209,14 @@ async function pullAgentsAction() {
194219
194209
  successMessage: "Agents fetched successfully",
194220
194210
  errorMessage: "Failed to fetch agents"
194221
194211
  });
194222
- const { written, deleted } = await runTask("Syncing agent files", async () => {
194212
+ if (remoteAgents.items.length === 0) {
194213
+ return { outroMessage: "No agents found on Base44" };
194214
+ }
194215
+ const { written, deleted } = await runTask("Writing agent files", async () => {
194223
194216
  return await writeAgents(agentsDir, remoteAgents.items);
194224
194217
  }, {
194225
- successMessage: "Agent files synced successfully",
194226
- errorMessage: "Failed to sync agent files"
194218
+ successMessage: "Agent files written successfully",
194219
+ errorMessage: "Failed to write agent files"
194227
194220
  });
194228
194221
  if (written.length > 0) {
194229
194222
  R2.success(`Written: ${written.join(", ")}`);
@@ -194231,9 +194224,6 @@ async function pullAgentsAction() {
194231
194224
  if (deleted.length > 0) {
194232
194225
  R2.warn(`Deleted: ${deleted.join(", ")}`);
194233
194226
  }
194234
- if (written.length === 0 && deleted.length === 0) {
194235
- R2.info("All agents are already up to date");
194236
- }
194237
194227
  return {
194238
194228
  outroMessage: `Pulled ${remoteAgents.total} agents to ${agentsDir}`
194239
194229
  };
@@ -200802,4 +200792,4 @@ export {
200802
200792
  CLIExitError
200803
200793
  };
200804
200794
 
200805
- //# debugId=5772B05CC453E3F364756E2164756E21
200795
+ //# debugId=744F4836F1F0A62164756E2164756E21