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

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,54 @@ 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 claimedPaths = new Set([...nameToEntry.values()].map((e2) => e2.filePath));
185443
+ const written = [];
185435
185444
  for (const agent of remoteAgents) {
185436
- const slug = toFileSlug(agent.name);
185437
- const filePath = join3(agentsDir, `${slug}.${CONFIG_FILE_EXTENSION}`);
185445
+ const existing = nameToEntry.get(agent.name);
185446
+ if (existing && isDeepStrictEqual(existing.raw, agent)) {
185447
+ continue;
185448
+ }
185449
+ const defaultPath = join3(agentsDir, `${agent.name}.${CONFIG_FILE_EXTENSION}`);
185450
+ if (!existing && claimedPaths.has(defaultPath)) {
185451
+ throw new Error(`Cannot write agent "${agent.name}": file "${defaultPath}" is already used by another agent`);
185452
+ }
185453
+ const filePath = existing?.filePath ?? defaultPath;
185438
185454
  await writeJsonFile(filePath, agent);
185455
+ written.push(agent.name);
185439
185456
  }
185440
- const written = remoteAgents.map((a) => a.name);
185441
- const deleted = toDelete.map((a) => a.name);
185442
185457
  return { written, deleted };
185443
185458
  }
185444
185459
  // src/core/resources/agent/resource.ts
@@ -185655,7 +185670,7 @@ async function removeConnector(integrationType) {
185655
185670
  }
185656
185671
  // src/core/resources/connector/config.ts
185657
185672
  import { join as join4 } from "node:path";
185658
- import { isDeepStrictEqual } from "node:util";
185673
+ import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
185659
185674
  async function readConnectorFile(connectorPath) {
185660
185675
  const parsed = await readJsonFile(connectorPath);
185661
185676
  const result = ConnectorResourceSchema.safeParse(parsed);
@@ -185716,7 +185731,7 @@ async function writeConnectors(connectorsDir, remoteConnectors) {
185716
185731
  type: connector.integrationType,
185717
185732
  scopes: connector.scopes
185718
185733
  };
185719
- if (existing && isDeepStrictEqual(existing.data, localConnector)) {
185734
+ if (existing && isDeepStrictEqual2(existing.data, localConnector)) {
185720
185735
  continue;
185721
185736
  }
185722
185737
  const filePath = existing?.filePath ?? join4(connectorsDir, `${connector.integrationType}.${CONFIG_FILE_EXTENSION}`);
@@ -193925,7 +193940,7 @@ var {
193925
193940
  // package.json
193926
193941
  var package_default = {
193927
193942
  name: "base44",
193928
- version: "0.0.33",
193943
+ version: "0.0.34",
193929
193944
  description: "Base44 CLI - Unified interface for managing Base44 applications",
193930
193945
  type: "module",
193931
193946
  bin: {
@@ -194130,14 +194145,11 @@ async function pullAgentsAction() {
194130
194145
  successMessage: "Agents fetched successfully",
194131
194146
  errorMessage: "Failed to fetch agents"
194132
194147
  });
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 () => {
194148
+ const { written, deleted } = await runTask("Syncing agent files", async () => {
194137
194149
  return await writeAgents(agentsDir, remoteAgents.items);
194138
194150
  }, {
194139
- successMessage: "Agent files written successfully",
194140
- errorMessage: "Failed to write agent files"
194151
+ successMessage: "Agent files synced successfully",
194152
+ errorMessage: "Failed to sync agent files"
194141
194153
  });
194142
194154
  if (written.length > 0) {
194143
194155
  R2.success(`Written: ${written.join(", ")}`);
@@ -194145,6 +194157,9 @@ async function pullAgentsAction() {
194145
194157
  if (deleted.length > 0) {
194146
194158
  R2.warn(`Deleted: ${deleted.join(", ")}`);
194147
194159
  }
194160
+ if (written.length === 0 && deleted.length === 0) {
194161
+ R2.info("All agents are already up to date");
194162
+ }
194148
194163
  return {
194149
194164
  outroMessage: `Pulled ${remoteAgents.total} agents to ${agentsDir}`
194150
194165
  };
@@ -200605,4 +200620,4 @@ export {
200605
200620
  CLIExitError
200606
200621
  };
200607
200622
 
200608
- //# debugId=682DFFEB8217B90164756E2164756E21
200623
+ //# debugId=40A3934F16CD09CB64756E2164756E21