retell-sync-cli 3.8.1 → 3.9.0
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.js +89 -4
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -134762,8 +134762,12 @@ var retell = new retell_sdk_default({
|
|
|
134762
134762
|
});
|
|
134763
134763
|
async function getRemoteState({
|
|
134764
134764
|
draft = false,
|
|
134765
|
-
agentIds = null
|
|
134765
|
+
agentIds = null,
|
|
134766
|
+
version: version2
|
|
134766
134767
|
} = {}) {
|
|
134768
|
+
if (version2 != null && agentIds) {
|
|
134769
|
+
return getRemoteStateByVersion(agentIds, version2);
|
|
134770
|
+
}
|
|
134767
134771
|
const [allVoiceAgents, allChatAgents, llms, conversationFlows] = await Promise.all([
|
|
134768
134772
|
retellPagination((opts) => retell.agent.list(opts), "agent_id"),
|
|
134769
134773
|
retellPagination((opts) => retell.chatAgent.list(opts), "agent_id"),
|
|
@@ -134784,6 +134788,65 @@ async function getRemoteState({
|
|
|
134784
134788
|
conversationFlows
|
|
134785
134789
|
});
|
|
134786
134790
|
}
|
|
134791
|
+
async function getRemoteStateByVersion(agentIds, version2) {
|
|
134792
|
+
const results = await Promise.all(agentIds.map(async (id2) => {
|
|
134793
|
+
try {
|
|
134794
|
+
const agent = await retell.agent.retrieve(id2, {
|
|
134795
|
+
query: { version: version2 }
|
|
134796
|
+
});
|
|
134797
|
+
return { type: "voice", agent };
|
|
134798
|
+
} catch {
|
|
134799
|
+
try {
|
|
134800
|
+
const agent = await retell.chatAgent.retrieve(id2, {
|
|
134801
|
+
query: { version: version2 }
|
|
134802
|
+
});
|
|
134803
|
+
return { type: "chat", agent };
|
|
134804
|
+
} catch {
|
|
134805
|
+
throw new Error(`Agent ${id2} not found at version ${version2}. ` + `Use 'retell.agent.getVersions(id)' to see available versions.`);
|
|
134806
|
+
}
|
|
134807
|
+
}
|
|
134808
|
+
}));
|
|
134809
|
+
const voiceAgents = [];
|
|
134810
|
+
const chatAgents = [];
|
|
134811
|
+
for (const result of results) {
|
|
134812
|
+
if (result.type === "voice") {
|
|
134813
|
+
voiceAgents.push(result.agent);
|
|
134814
|
+
} else {
|
|
134815
|
+
chatAgents.push(result.agent);
|
|
134816
|
+
}
|
|
134817
|
+
}
|
|
134818
|
+
const llmIds = new Set;
|
|
134819
|
+
const llmVersions = new Map;
|
|
134820
|
+
const flowIds = new Set;
|
|
134821
|
+
const flowVersions = new Map;
|
|
134822
|
+
for (const agent of [...voiceAgents, ...chatAgents]) {
|
|
134823
|
+
if (agent.response_engine.type === "retell-llm") {
|
|
134824
|
+
llmIds.add(agent.response_engine.llm_id);
|
|
134825
|
+
if (agent.response_engine.version != null) {
|
|
134826
|
+
llmVersions.set(agent.response_engine.llm_id, agent.response_engine.version);
|
|
134827
|
+
}
|
|
134828
|
+
} else if (agent.response_engine.type === "conversation-flow") {
|
|
134829
|
+
flowIds.add(agent.response_engine.conversation_flow_id);
|
|
134830
|
+
if (agent.response_engine.version != null) {
|
|
134831
|
+
flowVersions.set(agent.response_engine.conversation_flow_id, agent.response_engine.version);
|
|
134832
|
+
}
|
|
134833
|
+
}
|
|
134834
|
+
}
|
|
134835
|
+
const [llms, conversationFlows] = await Promise.all([
|
|
134836
|
+
Promise.all([...llmIds].map((id2) => retell.llm.retrieve(id2, {
|
|
134837
|
+
query: { version: llmVersions.get(id2) }
|
|
134838
|
+
}))),
|
|
134839
|
+
Promise.all([...flowIds].map((id2) => retell.conversationFlow.retrieve(id2, {
|
|
134840
|
+
query: { version: flowVersions.get(id2) }
|
|
134841
|
+
})))
|
|
134842
|
+
]);
|
|
134843
|
+
return canonicalizeFromApi({
|
|
134844
|
+
voiceAgents,
|
|
134845
|
+
chatAgents,
|
|
134846
|
+
llms,
|
|
134847
|
+
conversationFlows
|
|
134848
|
+
});
|
|
134849
|
+
}
|
|
134787
134850
|
function canonicalizeFromApi({
|
|
134788
134851
|
voiceAgents: voiceAgentsList,
|
|
134789
134852
|
chatAgents: chatAgentsList,
|
|
@@ -135760,16 +135823,36 @@ async function resolveAgentIds(args, { all = false, select = false } = {}) {
|
|
|
135760
135823
|
var {$: $10 } = globalThis.Bun;
|
|
135761
135824
|
async function pullCommand(agentIdArgs, opts, cmd) {
|
|
135762
135825
|
const globalOpts = cmd.optsWithGlobals();
|
|
135826
|
+
let version2;
|
|
135827
|
+
if (opts.version != null) {
|
|
135828
|
+
version2 = parseInt(opts.version, 10);
|
|
135829
|
+
if (Number.isNaN(version2) || version2 < 0) {
|
|
135830
|
+
console.log(source_default.red("Error: --version must be a non-negative integer"));
|
|
135831
|
+
process.exitCode = 1;
|
|
135832
|
+
return;
|
|
135833
|
+
}
|
|
135834
|
+
}
|
|
135835
|
+
if (version2 != null && opts.all) {
|
|
135836
|
+
console.log(source_default.red("Error: --version cannot be used with --all (must specify agent IDs)"));
|
|
135837
|
+
process.exitCode = 1;
|
|
135838
|
+
return;
|
|
135839
|
+
}
|
|
135763
135840
|
try {
|
|
135764
135841
|
const agentIds = await resolveAgentIds(agentIdArgs, {
|
|
135765
135842
|
all: opts.all,
|
|
135766
135843
|
select: opts.select
|
|
135767
135844
|
});
|
|
135845
|
+
if (version2 != null && !agentIds) {
|
|
135846
|
+
console.log(source_default.red("Error: --version requires specific agent IDs"));
|
|
135847
|
+
process.exitCode = 1;
|
|
135848
|
+
return;
|
|
135849
|
+
}
|
|
135768
135850
|
await pull({
|
|
135769
135851
|
agentsDir: globalOpts.agentsDir,
|
|
135770
135852
|
configFormat: globalOpts.configFormat,
|
|
135771
135853
|
agentIds,
|
|
135772
135854
|
yes: opts.yes,
|
|
135855
|
+
version: version2,
|
|
135773
135856
|
tests: opts.tests ?? true
|
|
135774
135857
|
});
|
|
135775
135858
|
} catch (err) {
|
|
@@ -135785,10 +135868,12 @@ async function pull({
|
|
|
135785
135868
|
configFormat = DEFAULT_CONFIG_FORMAT,
|
|
135786
135869
|
agentIds = null,
|
|
135787
135870
|
yes = false,
|
|
135871
|
+
version: version2,
|
|
135788
135872
|
tests = true
|
|
135789
135873
|
} = {}) {
|
|
135790
135874
|
const scopeLabel = agentIds ? `${agentIds.length} agent(s)` : "all agents";
|
|
135791
|
-
|
|
135875
|
+
const versionLabel = version2 != null ? ` (version ${version2})` : "";
|
|
135876
|
+
console.log(source_default.bold(`Pulling ${scopeLabel}${versionLabel} from Retell...`));
|
|
135792
135877
|
if (!yes) {
|
|
135793
135878
|
const { stdout } = await $10`git status --porcelain -- ${agentsDir}`.nothrow().quiet();
|
|
135794
135879
|
const hasChanges = stdout.toString().trim().length > 0;
|
|
@@ -135805,7 +135890,7 @@ async function pull({
|
|
|
135805
135890
|
}
|
|
135806
135891
|
}
|
|
135807
135892
|
const spinner = createSpinner("Fetching from Retell API...");
|
|
135808
|
-
const remoteState = await getRemoteState({ draft: true, agentIds });
|
|
135893
|
+
const remoteState = await getRemoteState({ draft: true, agentIds, version: version2 });
|
|
135809
135894
|
const totalAgents = remoteState.voiceAgents.length + remoteState.chatAgents.length;
|
|
135810
135895
|
spinner.stop(source_default.dim(`${pluralize("agent", totalAgents, true)} (${remoteState.voiceAgents.length} voice, ${remoteState.chatAgents.length} chat), ${pluralize("LLM", remoteState.llms.length, true)}, ${pluralize("flow", remoteState.conversationFlows.length, true)}`));
|
|
135811
135896
|
const writeSpinner = createSpinner("Writing files...");
|
|
@@ -136523,7 +136608,7 @@ async function updatePhoneNumberVersions(publishedAgentIds, agentNames) {
|
|
|
136523
136608
|
// src/cli.ts
|
|
136524
136609
|
var program2 = new Command;
|
|
136525
136610
|
program2.name("retell").description("Retell AI agent management CLI").option("-w, --agents-dir <dir>", "Directory for agent files", DEFAULT_AGENTS_DIR).option("-f, --config-format <format>", `Config file format (${CONFIG_FORMATS.join(", ")})`, DEFAULT_CONFIG_FORMAT);
|
|
136526
|
-
program2.command("pull [agentIds...]").description("Pull agents from Retell API (
|
|
136611
|
+
program2.command("pull [agentIds...]").description("Pull agents from Retell API (pulls latest draft state by default)").option("-a, --all", "Pull all agents in the account").option("-s, --select", "Force interactive agent selection").option("-y, --yes", "Skip confirmation prompts").option("-v, --version <number>", "Pull a specific version (requires agent IDs)").option("--no-tests", "Skip pulling test case definitions").action(pullCommand);
|
|
136527
136612
|
program2.command("deploy [agentIds...]").description("Deploy local changes to Retell draft").option("-a, --all", "Deploy all agents in the account").option("-s, --select", "Force interactive agent selection").option("-n, --dry-run", "Show changes without applying").option("-v, --verbose", "Show full diff details (use with --dry-run)").option("-q, --quiet", "Output only affected agent IDs (for piping)").action(deployCommand);
|
|
136528
136613
|
program2.command("publish [agentIds...]").description("Publish agents with unpublished draft changes").option("-a, --all", "Publish all agents in the account").option("-s, --select", "Force interactive agent selection").option("-n, --dry-run", "Show what would be published without publishing").option("-q, --quiet", "Output only published agent IDs (for piping)").action(publishCommand);
|
|
136529
136614
|
program2.parse();
|