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