retell-sync-cli 2.0.0 → 2.2.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.
Files changed (2) hide show
  1. package/dist/cli.js +85 -5
  2. package/package.json +3 -2
package/dist/cli.js CHANGED
@@ -135412,7 +135412,12 @@ async function deploy({
135412
135412
  spinner = createSpinner(`Deploying ${totalChanges} changes...`);
135413
135413
  const updateResults = await Promise.allSettled([
135414
135414
  ...changes.agents.map(async (change) => {
135415
- const { _id, _version, ...updateData } = change.current;
135415
+ const {
135416
+ _id,
135417
+ _version,
135418
+ response_engine: _10,
135419
+ ...updateData
135420
+ } = change.current;
135416
135421
  await retell.agent.update(_id, updateData);
135417
135422
  return { type: "agent", id: _id, name: change.name };
135418
135423
  }),
@@ -135459,20 +135464,93 @@ async function deploy({
135459
135464
  return { id: id2, name: agentNames.get(id2) ?? id2 };
135460
135465
  }));
135461
135466
  spinner.stop(source_default.dim("Done"));
135462
- let publishedCount = 0;
135467
+ const publishedAgentIds = [];
135463
135468
  for (const result of publishResults) {
135464
135469
  if (result.status === "fulfilled") {
135465
135470
  console.log(source_default.green(`Published ${source_default.bold(result.value.name)}`));
135466
- publishedCount++;
135471
+ publishedAgentIds.push(result.value.id);
135467
135472
  } else {
135468
135473
  console.log(source_default.red(`Failed to publish: ${result.reason}`));
135469
135474
  }
135470
135475
  }
135471
- console.log(source_default.green(`Published ${pluralize("agent", publishedCount, true)}`));
135476
+ console.log(source_default.green(`Published ${pluralize("agent", publishedAgentIds.length, true)}`));
135477
+ if (publishedAgentIds.length > 0) {
135478
+ await updatePhoneNumberVersions(publishedAgentIds, agentNames);
135479
+ }
135472
135480
  }
135473
135481
  console.log(source_default.bold("Syncing latest state..."));
135474
135482
  await pull({ agentsDir, configFormat, agentIds });
135475
135483
  }
135484
+ async function updatePhoneNumberVersions(publishedAgentIds, agentNames) {
135485
+ const spinner = createSpinner("Updating phone numbers...");
135486
+ const [phoneNumbers, ...agentVersionLists] = await Promise.all([
135487
+ retell.phoneNumber.list(),
135488
+ ...publishedAgentIds.map((id2) => retell.agent.getVersions(id2))
135489
+ ]);
135490
+ const publishedVersions = new Map;
135491
+ for (const [i5, agentId] of publishedAgentIds.entries()) {
135492
+ const versions2 = agentVersionLists[i5];
135493
+ if (!versions2)
135494
+ continue;
135495
+ const latestPublished = versions2.filter((v10) => v10.is_published).sort((a7, b7) => (b7.version ?? 0) - (a7.version ?? 0))[0];
135496
+ if (latestPublished?.version != null) {
135497
+ publishedVersions.set(agentId, latestPublished.version);
135498
+ }
135499
+ }
135500
+ const publishedAgentIdSet = new Set(publishedAgentIds);
135501
+ const updates = [];
135502
+ for (const phone of phoneNumbers) {
135503
+ const inboundVersion = phone.inbound_agent_id && publishedAgentIdSet.has(phone.inbound_agent_id) ? publishedVersions.get(phone.inbound_agent_id) : undefined;
135504
+ const outboundVersion = phone.outbound_agent_id && publishedAgentIdSet.has(phone.outbound_agent_id) ? publishedVersions.get(phone.outbound_agent_id) : undefined;
135505
+ if (inboundVersion != null || outboundVersion != null) {
135506
+ updates.push({
135507
+ phoneNumber: phone.phone_number,
135508
+ inboundVersion,
135509
+ outboundVersion
135510
+ });
135511
+ }
135512
+ }
135513
+ if (updates.length === 0) {
135514
+ spinner.stop(source_default.dim("No phone numbers to update"));
135515
+ return;
135516
+ }
135517
+ const updateResults = await Promise.allSettled(updates.map(async ({ phoneNumber, inboundVersion, outboundVersion }) => {
135518
+ await retell.phoneNumber.update(phoneNumber, {
135519
+ ...inboundVersion != null && {
135520
+ inbound_agent_version: inboundVersion
135521
+ },
135522
+ ...outboundVersion != null && {
135523
+ outbound_agent_version: outboundVersion
135524
+ }
135525
+ });
135526
+ return phoneNumber;
135527
+ }));
135528
+ spinner.stop(source_default.dim("Done"));
135529
+ let updatedCount = 0;
135530
+ for (const result of updateResults) {
135531
+ if (result.status === "fulfilled") {
135532
+ const phone = updates.find((u4) => u4.phoneNumber === result.value);
135533
+ const agentInfo = [];
135534
+ if (phone?.inboundVersion != null) {
135535
+ const inboundPhone = phoneNumbers.find((p4) => p4.phone_number === result.value);
135536
+ const agentId = inboundPhone?.inbound_agent_id;
135537
+ const name = agentId ? agentNames.get(agentId) ?? agentId : "unknown";
135538
+ agentInfo.push(`inbound: ${name} v${phone.inboundVersion}`);
135539
+ }
135540
+ if (phone?.outboundVersion != null) {
135541
+ const outboundPhone = phoneNumbers.find((p4) => p4.phone_number === result.value);
135542
+ const agentId = outboundPhone?.outbound_agent_id;
135543
+ const name = agentId ? agentNames.get(agentId) ?? agentId : "unknown";
135544
+ agentInfo.push(`outbound: ${name} v${phone.outboundVersion}`);
135545
+ }
135546
+ console.log(source_default.green(`Updated ${source_default.bold(result.value)} (${agentInfo.join(", ")})`));
135547
+ updatedCount++;
135548
+ } else {
135549
+ console.log(source_default.red(`Failed to update phone number: ${result.reason}`));
135550
+ }
135551
+ }
135552
+ console.log(source_default.green(`Updated ${pluralize("phone number", updatedCount, true)}`));
135553
+ }
135476
135554
  function computeChanges(local, remote) {
135477
135555
  const changes = {
135478
135556
  agents: [],
@@ -135486,7 +135564,9 @@ function computeChanges(local, remote) {
135486
135564
  const remoteAgent = remoteAgents.get(agent._id);
135487
135565
  if (!remoteAgent)
135488
135566
  continue;
135489
- const differences = diff(remoteAgent, agent);
135567
+ const { response_engine: _localRe, ...localComparable } = agent;
135568
+ const { response_engine: _remoteRe, ...remoteComparable } = remoteAgent;
135569
+ const differences = diff(remoteComparable, localComparable);
135490
135570
  if (differences.length > 0) {
135491
135571
  changes.agents.push({
135492
135572
  id: agent._id,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "retell-sync-cli",
3
- "version": "2.0.0",
3
+ "version": "2.2.0",
4
4
  "description": "CLI tool for syncing Retell AI agents between local filesystem and API",
5
5
  "keywords": [
6
6
  "agents",
@@ -18,7 +18,8 @@
18
18
  "scripts": {
19
19
  "check": "bunx tsc --noEmit && bun fix",
20
20
  "fix": "oxlint --type-aware --fix-suggestions && prettier . --write",
21
- "build": "bun build ./src/cli.ts --target bun --outdir dist"
21
+ "build": "bun check && bun build ./src/cli.ts --target bun --outdir dist",
22
+ "prepublishOnly": "bun run build"
22
23
  },
23
24
  "dependencies": {
24
25
  "@inquirer/prompts": "^8.1.0",