@base44-preview/cli 0.0.33-pr.286.ddceb19 → 0.0.34-pr.228.2ae7cac

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,18 +185389,16 @@ async function fetchAgents() {
185389
185389
  }
185390
185390
  // src/core/resources/agent/config.ts
185391
185391
  import { join as join3 } from "node:path";
185392
- function toFileSlug(name2) {
185393
- return name2.toLowerCase().replace(/[^a-z0-9_]/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "");
185394
- }
185392
+ import { isDeepStrictEqual } from "node:util";
185395
185393
  async function readAgentFile(agentPath) {
185396
- const parsed = await readJsonFile(agentPath);
185397
- const result = AgentConfigSchema.safeParse(parsed);
185394
+ const raw2 = await readJsonFile(agentPath);
185395
+ const result = AgentConfigSchema.safeParse(raw2);
185398
185396
  if (!result.success) {
185399
185397
  throw new SchemaValidationError("Invalid agent file", result.error, agentPath);
185400
185398
  }
185401
- return result.data;
185399
+ return { data: result.data, raw: raw2 };
185402
185400
  }
185403
- async function readAllAgents(agentsDir) {
185401
+ async function readAgentFiles(agentsDir) {
185404
185402
  if (!await pathExists(agentsDir)) {
185405
185403
  return [];
185406
185404
  }
@@ -185408,37 +185406,49 @@ async function readAllAgents(agentsDir) {
185408
185406
  cwd: agentsDir,
185409
185407
  absolute: true
185410
185408
  });
185411
- const agents = await Promise.all(files.map((filePath) => readAgentFile(filePath)));
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);
185412
185416
  const names = new Set;
185413
- for (const agent of agents) {
185414
- if (names.has(agent.name)) {
185415
- throw new Error(`Duplicate agent name "${agent.name}"`);
185417
+ for (const { data } of entries) {
185418
+ if (names.has(data.name)) {
185419
+ throw new Error(`Duplicate agent name "${data.name}"`);
185416
185420
  }
185417
- names.add(agent.name);
185421
+ names.add(data.name);
185418
185422
  }
185419
- return agents;
185423
+ return entries.map((e2) => e2.data);
185420
185424
  }
185421
185425
  async function writeAgents(agentsDir, remoteAgents) {
185422
- const existingAgents = await readAllAgents(agentsDir);
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
+ }
185423
185434
  const newNames = new Set(remoteAgents.map((a) => a.name));
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);
185435
+ const deleted = [];
185436
+ for (const [name2, entry] of nameToEntry) {
185437
+ if (!newNames.has(name2)) {
185438
+ await deleteFile(entry.filePath);
185439
+ deleted.push(name2);
185433
185440
  }
185434
185441
  }
185442
+ const written = [];
185435
185443
  for (const agent of remoteAgents) {
185436
- const slug = toFileSlug(agent.name);
185437
- const filePath = join3(agentsDir, `${slug}.${CONFIG_FILE_EXTENSION}`);
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}`);
185438
185449
  await writeJsonFile(filePath, agent);
185450
+ written.push(agent.name);
185439
185451
  }
185440
- const written = remoteAgents.map((a) => a.name);
185441
- const deleted = toDelete.map((a) => a.name);
185442
185452
  return { written, deleted };
185443
185453
  }
185444
185454
  // src/core/resources/agent/resource.ts
@@ -185655,7 +185665,7 @@ async function removeConnector(integrationType) {
185655
185665
  }
185656
185666
  // src/core/resources/connector/config.ts
185657
185667
  import { join as join4 } from "node:path";
185658
- import { isDeepStrictEqual } from "node:util";
185668
+ import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
185659
185669
  async function readConnectorFile(connectorPath) {
185660
185670
  const parsed = await readJsonFile(connectorPath);
185661
185671
  const result = ConnectorResourceSchema.safeParse(parsed);
@@ -185716,7 +185726,7 @@ async function writeConnectors(connectorsDir, remoteConnectors) {
185716
185726
  type: connector.integrationType,
185717
185727
  scopes: connector.scopes
185718
185728
  };
185719
- if (existing && isDeepStrictEqual(existing.data, localConnector)) {
185729
+ if (existing && isDeepStrictEqual2(existing.data, localConnector)) {
185720
185730
  continue;
185721
185731
  }
185722
185732
  const filePath = existing?.filePath ?? join4(connectorsDir, `${connector.integrationType}.${CONFIG_FILE_EXTENSION}`);
@@ -193925,7 +193935,7 @@ var {
193925
193935
  // package.json
193926
193936
  var package_default = {
193927
193937
  name: "base44",
193928
- version: "0.0.33",
193938
+ version: "0.0.34",
193929
193939
  description: "Base44 CLI - Unified interface for managing Base44 applications",
193930
193940
  type: "module",
193931
193941
  bin: {
@@ -194130,14 +194140,11 @@ async function pullAgentsAction() {
194130
194140
  successMessage: "Agents fetched successfully",
194131
194141
  errorMessage: "Failed to fetch agents"
194132
194142
  });
194133
- if (remoteAgents.items.length === 0) {
194134
- return { outroMessage: "No agents found on Base44" };
194135
- }
194136
- const { written, deleted } = await runTask("Writing agent files", async () => {
194143
+ const { written, deleted } = await runTask("Syncing agent files", async () => {
194137
194144
  return await writeAgents(agentsDir, remoteAgents.items);
194138
194145
  }, {
194139
- successMessage: "Agent files written successfully",
194140
- errorMessage: "Failed to write agent files"
194146
+ successMessage: "Agent files synced successfully",
194147
+ errorMessage: "Failed to sync agent files"
194141
194148
  });
194142
194149
  if (written.length > 0) {
194143
194150
  R2.success(`Written: ${written.join(", ")}`);
@@ -194145,6 +194152,9 @@ async function pullAgentsAction() {
194145
194152
  if (deleted.length > 0) {
194146
194153
  R2.warn(`Deleted: ${deleted.join(", ")}`);
194147
194154
  }
194155
+ if (written.length === 0 && deleted.length === 0) {
194156
+ R2.info("All agents are already up to date");
194157
+ }
194148
194158
  return {
194149
194159
  outroMessage: `Pulled ${remoteAgents.total} agents to ${agentsDir}`
194150
194160
  };
@@ -200605,4 +200615,4 @@ export {
200605
200615
  CLIExitError
200606
200616
  };
200607
200617
 
200608
- //# debugId=682DFFEB8217B90164756E2164756E21
200618
+ //# debugId=199B0E01CD0F366764756E2164756E21