retell-sync-cli 1.0.1 → 1.1.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 +60 -55
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -96621,6 +96621,9 @@ var require_dist = __commonJS((exports) => {
|
|
|
96621
96621
|
exports.visitAsync = visit.visitAsync;
|
|
96622
96622
|
});
|
|
96623
96623
|
|
|
96624
|
+
// src/cli.ts
|
|
96625
|
+
var {$: $13 } = globalThis.Bun;
|
|
96626
|
+
|
|
96624
96627
|
// node_modules/commander/esm.mjs
|
|
96625
96628
|
var import__ = __toESM(require_commander(), 1);
|
|
96626
96629
|
var {
|
|
@@ -134612,19 +134615,13 @@ var dist_default3 = createPrompt((config2, done) => {
|
|
|
134612
134615
|
var {$: $11 } = globalThis.Bun;
|
|
134613
134616
|
async function pullCommand(opts, cmd) {
|
|
134614
134617
|
const globalOpts = cmd.optsWithGlobals();
|
|
134615
|
-
const {
|
|
134616
|
-
branch = globalOpts.branch,
|
|
134617
|
-
draft = false,
|
|
134618
|
-
yes = false,
|
|
134619
|
-
merge: merge2 = false
|
|
134620
|
-
} = opts;
|
|
134621
134618
|
try {
|
|
134622
134619
|
await pull({
|
|
134623
134620
|
agentsDir: globalOpts.agentsDir,
|
|
134624
|
-
|
|
134625
|
-
|
|
134626
|
-
|
|
134627
|
-
|
|
134621
|
+
syncBranch: globalOpts.syncBranch,
|
|
134622
|
+
workingBranch: opts.merge ? globalOpts.workingBranch : undefined,
|
|
134623
|
+
draft: opts.draft,
|
|
134624
|
+
yes: opts.yes
|
|
134628
134625
|
});
|
|
134629
134626
|
} catch (err) {
|
|
134630
134627
|
if (err instanceof ExitPromptError) {
|
|
@@ -134636,10 +134633,10 @@ async function pullCommand(opts, cmd) {
|
|
|
134636
134633
|
}
|
|
134637
134634
|
async function pull({
|
|
134638
134635
|
agentsDir = DEFAULT_AGENTS_DIR,
|
|
134639
|
-
|
|
134636
|
+
syncBranch,
|
|
134637
|
+
workingBranch,
|
|
134640
134638
|
draft: pullDrafts = false,
|
|
134641
|
-
yes: skipConfirmations = false
|
|
134642
|
-
merge: merge2 = false
|
|
134639
|
+
yes: skipConfirmations = false
|
|
134643
134640
|
}) {
|
|
134644
134641
|
if (pullDrafts && !skipConfirmations) {
|
|
134645
134642
|
const proceed = await dist_default3({
|
|
@@ -134654,7 +134651,7 @@ async function pull({
|
|
|
134654
134651
|
const remoteState = await getRemoteState({ draft: pullDrafts });
|
|
134655
134652
|
spinner.stop(source_default.dim(`${pluralize("agent", remoteState.voiceAgents.length, true)}, ${pluralize("LLM", remoteState.llms.length, true)}, ${pluralize("flow", remoteState.conversationFlows.length, true)}`));
|
|
134656
134653
|
const regressions = await checkVersionRegressions(remoteState.voiceAgents, {
|
|
134657
|
-
|
|
134654
|
+
syncBranch,
|
|
134658
134655
|
agentsDir
|
|
134659
134656
|
});
|
|
134660
134657
|
if (regressions.length > 0 && !skipConfirmations) {
|
|
@@ -134676,31 +134673,24 @@ Warning: ${regressions.length} agent(s) would have their version regressed:`));
|
|
|
134676
134673
|
const files = await serializeState(remoteState, { agentsDir });
|
|
134677
134674
|
spinner.stop(source_default.dim(`${pluralize("file", Object.keys(files).length, true)}`));
|
|
134678
134675
|
spinner = createSpinner("Creating git objects...");
|
|
134679
|
-
const result = await createCommitFromFiles(files,
|
|
134676
|
+
const result = await createCommitFromFiles(files, syncBranch, {
|
|
134680
134677
|
agents: remoteState.voiceAgents.length,
|
|
134681
134678
|
llms: remoteState.llms.length,
|
|
134682
134679
|
flows: remoteState.conversationFlows.length
|
|
134683
134680
|
});
|
|
134684
134681
|
if (result.created) {
|
|
134685
|
-
spinner.stop(source_default.green(`Updated ${source_default.bold(
|
|
134682
|
+
spinner.stop(source_default.green(`Updated ${source_default.bold(syncBranch)} to ${source_default.yellow(result.commitSha.slice(0, 7))}`));
|
|
134686
134683
|
} else {
|
|
134687
134684
|
spinner.stop(source_default.dim(`No changes detected`));
|
|
134688
134685
|
}
|
|
134689
|
-
if (
|
|
134690
|
-
|
|
134691
|
-
|
|
134692
|
-
targetBranch = merge2;
|
|
134693
|
-
} else {
|
|
134694
|
-
const { stdout } = await $11`git rev-parse --abbrev-ref HEAD`.quiet();
|
|
134695
|
-
targetBranch = stdout.toString().trim();
|
|
134696
|
-
}
|
|
134697
|
-
spinner = createSpinner(`Merging ${branch} into ${targetBranch}...`);
|
|
134698
|
-
const { stdout: srcStdout } = await $11`git rev-parse refs/heads/${branch}`.quiet();
|
|
134686
|
+
if (workingBranch) {
|
|
134687
|
+
spinner = createSpinner(`Merging ${syncBranch} into ${workingBranch}...`);
|
|
134688
|
+
const { stdout: srcStdout } = await $11`git rev-parse refs/heads/${syncBranch}`.quiet();
|
|
134699
134689
|
const srcSha = srcStdout.toString().trim();
|
|
134700
|
-
const { stdout: targetStdout, exitCode: targetExitCode } = await $11`git rev-parse refs/heads/${
|
|
134690
|
+
const { stdout: targetStdout, exitCode: targetExitCode } = await $11`git rev-parse refs/heads/${workingBranch} 2>/dev/null`.nothrow().quiet();
|
|
134701
134691
|
if (targetExitCode !== 0) {
|
|
134702
|
-
await $11`git update-ref refs/heads/${
|
|
134703
|
-
spinner.stop(source_default.green(`Created ${source_default.bold(
|
|
134692
|
+
await $11`git update-ref refs/heads/${workingBranch} ${srcSha}`.quiet();
|
|
134693
|
+
spinner.stop(source_default.green(`Created ${source_default.bold(workingBranch)} from ${source_default.bold(syncBranch)}`));
|
|
134704
134694
|
} else {
|
|
134705
134695
|
const targetSha = targetStdout.toString().trim();
|
|
134706
134696
|
if (srcSha === targetSha) {
|
|
@@ -134708,20 +134698,20 @@ Warning: ${regressions.length} agent(s) would have their version regressed:`));
|
|
|
134708
134698
|
} else {
|
|
134709
134699
|
const { exitCode: isAncestor } = await $11`git merge-base --is-ancestor ${targetSha} ${srcSha}`.nothrow().quiet();
|
|
134710
134700
|
if (isAncestor === 0) {
|
|
134711
|
-
await $11`git update-ref refs/heads/${
|
|
134712
|
-
spinner.stop(source_default.green(`Fast-forwarded ${source_default.bold(
|
|
134701
|
+
await $11`git update-ref refs/heads/${workingBranch} ${srcSha}`.quiet();
|
|
134702
|
+
spinner.stop(source_default.green(`Fast-forwarded ${source_default.bold(workingBranch)} to ${source_default.bold(syncBranch)}`));
|
|
134713
134703
|
} else {
|
|
134714
134704
|
const { stdout: mergeTreeOut, exitCode: mergeTreeExit } = await $11`git merge-tree --write-tree ${targetSha} ${srcSha}`.nothrow().quiet();
|
|
134715
134705
|
if (mergeTreeExit !== 0) {
|
|
134716
134706
|
spinner.stop(source_default.red(`Merge conflict`));
|
|
134717
|
-
console.error(source_default.red(`Cannot auto-merge ${
|
|
134707
|
+
console.error(source_default.red(`Cannot auto-merge ${syncBranch} into ${workingBranch}. Resolve conflicts manually.`));
|
|
134718
134708
|
} else {
|
|
134719
134709
|
const mergedTreeSha = mergeTreeOut.toString().trim();
|
|
134720
|
-
const message = `Merge ${
|
|
134710
|
+
const message = `Merge ${syncBranch} into ${workingBranch}`;
|
|
134721
134711
|
const { stdout: commitOut } = await $11`git commit-tree ${mergedTreeSha} -p ${targetSha} -p ${srcSha} -m ${message}`.quiet();
|
|
134722
134712
|
const mergeCommitSha = commitOut.toString().trim();
|
|
134723
|
-
await $11`git update-ref refs/heads/${
|
|
134724
|
-
spinner.stop(source_default.green(`Merged ${source_default.bold(
|
|
134713
|
+
await $11`git update-ref refs/heads/${workingBranch} ${mergeCommitSha}`.quiet();
|
|
134714
|
+
spinner.stop(source_default.green(`Merged ${source_default.bold(syncBranch)} into ${source_default.bold(workingBranch)}`));
|
|
134725
134715
|
}
|
|
134726
134716
|
}
|
|
134727
134717
|
}
|
|
@@ -134789,10 +134779,12 @@ async function createCommitFromFiles(files, branch, stats) {
|
|
|
134789
134779
|
await $11`git update-ref refs/heads/${branch} ${commitSha}`.quiet();
|
|
134790
134780
|
return { created: true, commitSha };
|
|
134791
134781
|
}
|
|
134792
|
-
async function checkVersionRegressions(remoteAgents, {
|
|
134782
|
+
async function checkVersionRegressions(remoteAgents, { syncBranch, agentsDir }) {
|
|
134793
134783
|
let branchState;
|
|
134794
134784
|
try {
|
|
134795
|
-
branchState = await getCommitState(`refs/heads/${
|
|
134785
|
+
branchState = await getCommitState(`refs/heads/${syncBranch}`, {
|
|
134786
|
+
agentsDir
|
|
134787
|
+
});
|
|
134796
134788
|
} catch {
|
|
134797
134789
|
return [];
|
|
134798
134790
|
}
|
|
@@ -134815,15 +134807,15 @@ async function checkVersionRegressions(remoteAgents, { branch, agentsDir }) {
|
|
|
134815
134807
|
// src/commands/deploy.ts
|
|
134816
134808
|
async function deployCommand(opts, cmd) {
|
|
134817
134809
|
const globalOpts = cmd.optsWithGlobals();
|
|
134818
|
-
const { dryRun = false, draft = false, yes = false, publish = false } = opts;
|
|
134819
134810
|
try {
|
|
134820
134811
|
await deploy({
|
|
134821
134812
|
agentsDir: globalOpts.agentsDir,
|
|
134822
|
-
|
|
134823
|
-
|
|
134824
|
-
|
|
134825
|
-
|
|
134826
|
-
|
|
134813
|
+
syncBranch: globalOpts.syncBranch,
|
|
134814
|
+
workingBranch: globalOpts.workingBranch,
|
|
134815
|
+
dryRun: opts.dryRun,
|
|
134816
|
+
draft: opts.draft,
|
|
134817
|
+
yes: opts.yes,
|
|
134818
|
+
publish: opts.publish
|
|
134827
134819
|
});
|
|
134828
134820
|
} catch (err) {
|
|
134829
134821
|
if (err instanceof ExitPromptError) {
|
|
@@ -134835,7 +134827,8 @@ async function deployCommand(opts, cmd) {
|
|
|
134835
134827
|
}
|
|
134836
134828
|
async function deploy({
|
|
134837
134829
|
agentsDir = DEFAULT_AGENTS_DIR,
|
|
134838
|
-
|
|
134830
|
+
syncBranch,
|
|
134831
|
+
workingBranch,
|
|
134839
134832
|
dryRun = false,
|
|
134840
134833
|
draft = false,
|
|
134841
134834
|
yes = false,
|
|
@@ -134843,20 +134836,20 @@ async function deploy({
|
|
|
134843
134836
|
}) {
|
|
134844
134837
|
console.log(source_default.bold("Pulling first..."));
|
|
134845
134838
|
await pull({
|
|
134846
|
-
|
|
134839
|
+
syncBranch,
|
|
134840
|
+
workingBranch,
|
|
134847
134841
|
draft,
|
|
134848
134842
|
yes,
|
|
134849
|
-
agentsDir
|
|
134850
|
-
branch
|
|
134843
|
+
agentsDir
|
|
134851
134844
|
});
|
|
134852
134845
|
console.log(source_default.bold("Analyzing changes..."));
|
|
134853
|
-
const [{ stdout:
|
|
134854
|
-
$12`git rev-parse
|
|
134855
|
-
$12`git rev-parse
|
|
134846
|
+
const [{ stdout: workingRef }, { stdout: syncRef }] = await Promise.all([
|
|
134847
|
+
$12`git rev-parse refs/heads/${workingBranch}`.quiet(),
|
|
134848
|
+
$12`git rev-parse refs/heads/${syncBranch}`.quiet()
|
|
134856
134849
|
]);
|
|
134857
134850
|
let spinner = createSpinner("Reading state from git...");
|
|
134858
134851
|
const [currentState, syncState] = await Promise.all([
|
|
134859
|
-
getCommitState(
|
|
134852
|
+
getCommitState(workingRef.toString().trim(), { agentsDir }),
|
|
134860
134853
|
getCommitState(syncRef.toString().trim(), { agentsDir })
|
|
134861
134854
|
]);
|
|
134862
134855
|
spinner.stop(source_default.dim("Read state from git"));
|
|
@@ -134944,7 +134937,7 @@ async function deploy({
|
|
|
134944
134937
|
draft,
|
|
134945
134938
|
yes: true,
|
|
134946
134939
|
agentsDir,
|
|
134947
|
-
|
|
134940
|
+
syncBranch
|
|
134948
134941
|
});
|
|
134949
134942
|
}
|
|
134950
134943
|
}
|
|
@@ -135036,8 +135029,20 @@ function printChangeSummary(changes) {
|
|
|
135036
135029
|
|
|
135037
135030
|
// src/cli.ts
|
|
135038
135031
|
var program2 = new Command;
|
|
135039
|
-
var
|
|
135040
|
-
|
|
135041
|
-
|
|
135032
|
+
var DEFAULT_SYNC_BRANCH = "retell-sync";
|
|
135033
|
+
async function getCurrentBranch() {
|
|
135034
|
+
const { stdout, exitCode } = await $13`git rev-parse --abbrev-ref HEAD`.nothrow().quiet();
|
|
135035
|
+
if (exitCode !== 0)
|
|
135036
|
+
return "HEAD";
|
|
135037
|
+
const branch = stdout.toString().trim();
|
|
135038
|
+
return branch === "HEAD" ? "HEAD" : branch;
|
|
135039
|
+
}
|
|
135040
|
+
program2.name("retell").description("Retell AI agent management CLI").option("-w, --agents-dir <dir>", "Directory for agent files", DEFAULT_AGENTS_DIR).option("-s, --sync-branch <branch>", "Branch for storing API state", DEFAULT_SYNC_BRANCH).option("-b, --working-branch <branch>", "Branch to merge into / compare against (defaults to current branch)").hook("preAction", async (thisCommand) => {
|
|
135041
|
+
const opts = thisCommand.opts();
|
|
135042
|
+
if (!opts.workingBranch) {
|
|
135043
|
+
opts.workingBranch = await getCurrentBranch();
|
|
135044
|
+
}
|
|
135045
|
+
});
|
|
135046
|
+
program2.command("pull").description("Pull agents from Retell API and optionally merge into working branch").option("-d, --draft", "Include unpublished agents").option("-y, --yes", "Skip confirmation prompts").option("-m, --merge", "Merge sync branch into working branch after pull").action(pullCommand);
|
|
135042
135047
|
program2.command("deploy").description("Deploy local changes to Retell API").option("-n, --dry-run", "Show changes without applying").option("-d, --draft", "Include unpublished agents when pulling").option("-y, --yes", "Skip confirmation prompts").option("-p, --publish", "Publish agents after deploying").action(deployCommand);
|
|
135043
135048
|
program2.parse();
|