@base44-preview/cli 0.0.31-pr.227.5bb703f → 0.0.31-pr.228.043cc19
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 +44 -29
- package/dist/cli/index.js.map +4 -4
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -160583,15 +160583,16 @@ async function fetchAgents() {
|
|
|
160583
160583
|
}
|
|
160584
160584
|
// src/core/resources/agent/config.ts
|
|
160585
160585
|
import { join as join3 } from "node:path";
|
|
160586
|
+
import { isDeepStrictEqual } from "node:util";
|
|
160586
160587
|
async function readAgentFile(agentPath) {
|
|
160587
|
-
const
|
|
160588
|
-
const result = AgentConfigSchema.safeParse(
|
|
160588
|
+
const raw2 = await readJsonFile(agentPath);
|
|
160589
|
+
const result = AgentConfigSchema.safeParse(raw2);
|
|
160589
160590
|
if (!result.success) {
|
|
160590
160591
|
throw new SchemaValidationError("Invalid agent file", result.error, agentPath);
|
|
160591
160592
|
}
|
|
160592
|
-
return result.data;
|
|
160593
|
+
return { data: result.data, raw: raw2 };
|
|
160593
160594
|
}
|
|
160594
|
-
async function
|
|
160595
|
+
async function readAgentFiles(agentsDir) {
|
|
160595
160596
|
if (!await pathExists(agentsDir)) {
|
|
160596
160597
|
return [];
|
|
160597
160598
|
}
|
|
@@ -160599,35 +160600,49 @@ async function readAllAgents(agentsDir) {
|
|
|
160599
160600
|
cwd: agentsDir,
|
|
160600
160601
|
absolute: true
|
|
160601
160602
|
});
|
|
160602
|
-
|
|
160603
|
+
return await Promise.all(files.map(async (filePath) => {
|
|
160604
|
+
const { data, raw: raw2 } = await readAgentFile(filePath);
|
|
160605
|
+
return { data, raw: raw2, filePath };
|
|
160606
|
+
}));
|
|
160607
|
+
}
|
|
160608
|
+
async function readAllAgents(agentsDir) {
|
|
160609
|
+
const entries = await readAgentFiles(agentsDir);
|
|
160603
160610
|
const names = new Set;
|
|
160604
|
-
for (const
|
|
160605
|
-
if (names.has(
|
|
160606
|
-
throw new Error(`Duplicate agent name "${
|
|
160611
|
+
for (const { data } of entries) {
|
|
160612
|
+
if (names.has(data.name)) {
|
|
160613
|
+
throw new Error(`Duplicate agent name "${data.name}"`);
|
|
160607
160614
|
}
|
|
160608
|
-
names.add(
|
|
160615
|
+
names.add(data.name);
|
|
160609
160616
|
}
|
|
160610
|
-
return
|
|
160617
|
+
return entries.map((e2) => e2.data);
|
|
160611
160618
|
}
|
|
160612
160619
|
async function writeAgents(agentsDir, remoteAgents) {
|
|
160613
|
-
const
|
|
160620
|
+
const entries = await readAgentFiles(agentsDir);
|
|
160621
|
+
const nameToEntry = new Map;
|
|
160622
|
+
for (const entry of entries) {
|
|
160623
|
+
if (nameToEntry.has(entry.data.name)) {
|
|
160624
|
+
throw new Error(`Duplicate agent name "${entry.data.name}"`);
|
|
160625
|
+
}
|
|
160626
|
+
nameToEntry.set(entry.data.name, entry);
|
|
160627
|
+
}
|
|
160614
160628
|
const newNames = new Set(remoteAgents.map((a) => a.name));
|
|
160615
|
-
const
|
|
160616
|
-
for (const
|
|
160617
|
-
|
|
160618
|
-
|
|
160619
|
-
|
|
160620
|
-
});
|
|
160621
|
-
for (const filePath of files) {
|
|
160622
|
-
await deleteFile(filePath);
|
|
160629
|
+
const deleted = [];
|
|
160630
|
+
for (const [name2, entry] of nameToEntry) {
|
|
160631
|
+
if (!newNames.has(name2)) {
|
|
160632
|
+
await deleteFile(entry.filePath);
|
|
160633
|
+
deleted.push(name2);
|
|
160623
160634
|
}
|
|
160624
160635
|
}
|
|
160636
|
+
const written = [];
|
|
160625
160637
|
for (const agent of remoteAgents) {
|
|
160626
|
-
const
|
|
160638
|
+
const existing = nameToEntry.get(agent.name);
|
|
160639
|
+
if (existing && isDeepStrictEqual(existing.raw, agent)) {
|
|
160640
|
+
continue;
|
|
160641
|
+
}
|
|
160642
|
+
const filePath = existing?.filePath ?? join3(agentsDir, `${agent.name}.${CONFIG_FILE_EXTENSION}`);
|
|
160627
160643
|
await writeJsonFile(filePath, agent);
|
|
160644
|
+
written.push(agent.name);
|
|
160628
160645
|
}
|
|
160629
|
-
const written = remoteAgents.map((a) => a.name);
|
|
160630
|
-
const deleted = toDelete.map((a) => a.name);
|
|
160631
160646
|
return { written, deleted };
|
|
160632
160647
|
}
|
|
160633
160648
|
// src/core/resources/agent/resource.ts
|
|
@@ -168931,14 +168946,11 @@ async function pullAgentsAction() {
|
|
|
168931
168946
|
successMessage: "Agents fetched successfully",
|
|
168932
168947
|
errorMessage: "Failed to fetch agents"
|
|
168933
168948
|
});
|
|
168934
|
-
|
|
168935
|
-
return { outroMessage: "No agents found on Base44" };
|
|
168936
|
-
}
|
|
168937
|
-
const { written, deleted } = await runTask("Writing agent files", async () => {
|
|
168949
|
+
const { written, deleted } = await runTask("Syncing agent files", async () => {
|
|
168938
168950
|
return await writeAgents(agentsDir, remoteAgents.items);
|
|
168939
168951
|
}, {
|
|
168940
|
-
successMessage: "Agent files
|
|
168941
|
-
errorMessage: "Failed to
|
|
168952
|
+
successMessage: "Agent files synced successfully",
|
|
168953
|
+
errorMessage: "Failed to sync agent files"
|
|
168942
168954
|
});
|
|
168943
168955
|
if (written.length > 0) {
|
|
168944
168956
|
M2.success(`Written: ${written.join(", ")}`);
|
|
@@ -168946,6 +168958,9 @@ async function pullAgentsAction() {
|
|
|
168946
168958
|
if (deleted.length > 0) {
|
|
168947
168959
|
M2.warn(`Deleted: ${deleted.join(", ")}`);
|
|
168948
168960
|
}
|
|
168961
|
+
if (written.length === 0 && deleted.length === 0) {
|
|
168962
|
+
M2.info("All agents are already up to date");
|
|
168963
|
+
}
|
|
168949
168964
|
return {
|
|
168950
168965
|
outroMessage: `Pulled ${remoteAgents.total} agents to ${agentsDir}`
|
|
168951
168966
|
};
|
|
@@ -174653,4 +174668,4 @@ export {
|
|
|
174653
174668
|
CLIExitError
|
|
174654
174669
|
};
|
|
174655
174670
|
|
|
174656
|
-
//# debugId=
|
|
174671
|
+
//# debugId=CB57B581E375BEA664756E2164756E21
|