@erdoai/cli 0.234.0 → 0.235.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/index.js +59 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1132,6 +1132,20 @@ var ErdoClient = class {
|
|
|
1132
1132
|
{ enabled }
|
|
1133
1133
|
);
|
|
1134
1134
|
}
|
|
1135
|
+
getVoiceAgentInstructions(slug) {
|
|
1136
|
+
return this.request(
|
|
1137
|
+
"GET",
|
|
1138
|
+
`/v1/voice/agents/${encodeURIComponent(slug)}/instructions`
|
|
1139
|
+
);
|
|
1140
|
+
}
|
|
1141
|
+
// Replaces the whole text; the agent's profile keeps a version of the old one.
|
|
1142
|
+
setVoiceAgentInstructions(slug, instructions) {
|
|
1143
|
+
return this.request(
|
|
1144
|
+
"PUT",
|
|
1145
|
+
`/v1/voice/agents/${encodeURIComponent(slug)}/instructions`,
|
|
1146
|
+
{ instructions }
|
|
1147
|
+
);
|
|
1148
|
+
}
|
|
1135
1149
|
setVoiceAgentRealtimeModel(slug, model) {
|
|
1136
1150
|
return this.request(
|
|
1137
1151
|
"POST",
|
|
@@ -8397,6 +8411,51 @@ voiceAgentsCmd.command("whatsapp-replies <slug>").description("Turn a voice agen
|
|
|
8397
8411
|
fail(e);
|
|
8398
8412
|
}
|
|
8399
8413
|
});
|
|
8414
|
+
var voiceAgentInstructionsCmd = voiceAgentsCmd.command("instructions").description("Read or replace a concierge's instructions: the text that tells it how to behave");
|
|
8415
|
+
voiceAgentInstructionsCmd.command("get <slug>").description("Print a concierge's instructions; whether the live agent carries them goes to stderr").option("--json", "print the raw JSON result instead of the text").action(async (slug, opts) => {
|
|
8416
|
+
try {
|
|
8417
|
+
const res = await new ErdoClient().getVoiceAgentInstructions(slug);
|
|
8418
|
+
if (opts.json) {
|
|
8419
|
+
print(res);
|
|
8420
|
+
return;
|
|
8421
|
+
}
|
|
8422
|
+
process.stdout.write(res.instructions.endsWith("\n") ? res.instructions : `${res.instructions}
|
|
8423
|
+
`);
|
|
8424
|
+
process.stderr.write(describeLiveAgent(res));
|
|
8425
|
+
} catch (e) {
|
|
8426
|
+
fail(e);
|
|
8427
|
+
}
|
|
8428
|
+
});
|
|
8429
|
+
voiceAgentInstructionsCmd.command("set <slug>").description(
|
|
8430
|
+
"Replace a concierge's instructions with the contents of a file. The whole text is replaced; the agent's page keeps the previous version. Organization admins with edit access to the agent only."
|
|
8431
|
+
).requiredOption("-f, --file <path>", "file holding the full new instructions").option("--json", "print the raw JSON result instead of a summary").action(async (slug, opts) => {
|
|
8432
|
+
try {
|
|
8433
|
+
const instructions = readFileSync5(opts.file, "utf8");
|
|
8434
|
+
if (!instructions.trim()) {
|
|
8435
|
+
throw new Error(`${opts.file} is empty \u2014 instructions cannot be blank`);
|
|
8436
|
+
}
|
|
8437
|
+
const res = await new ErdoClient().setVoiceAgentInstructions(slug, instructions);
|
|
8438
|
+
if (opts.json) {
|
|
8439
|
+
print(res);
|
|
8440
|
+
return;
|
|
8441
|
+
}
|
|
8442
|
+
console.log(`Saved instructions for ${res.slug} (${res.name}), ${res.instructions.length} characters.`);
|
|
8443
|
+
process.stderr.write(describeLiveAgent(res));
|
|
8444
|
+
} catch (e) {
|
|
8445
|
+
fail(e);
|
|
8446
|
+
}
|
|
8447
|
+
});
|
|
8448
|
+
function describeLiveAgent(res) {
|
|
8449
|
+
if (res.push_pending_since) {
|
|
8450
|
+
return `the last push to the live agent failed (pending since ${res.push_pending_since}); it is retried automatically
|
|
8451
|
+
`;
|
|
8452
|
+
}
|
|
8453
|
+
if (!res.live_agent_synced) {
|
|
8454
|
+
return `the live agent picks this up within seconds \u2014 check with: erdo voice agents instructions get ${res.slug}
|
|
8455
|
+
`;
|
|
8456
|
+
}
|
|
8457
|
+
return "the live agent carries these instructions\n";
|
|
8458
|
+
}
|
|
8400
8459
|
function parseVoiceRealtimeModel(value) {
|
|
8401
8460
|
if (value === "off" || value === "mini" || value === "max") return value;
|
|
8402
8461
|
throw new Error("realtime model must be one of: off, mini, max");
|