@velaro/cli 1.4.119 → 1.4.120

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/bin/velaro.js CHANGED
@@ -125,6 +125,7 @@ import { statusNotifyCommand } from '../lib/commands/status-notify.js';
125
125
  import { statusSlaCommand } from '../lib/commands/status-sla.js';
126
126
  import { emailInboxCommand } from '../lib/commands/email-inbox.js';
127
127
  import { callbackCommand } from '../lib/commands/callback.js';
128
+ import { callpresenceCommand } from '../lib/commands/callpresence.js';
128
129
  import { authorityCommand } from '../lib/commands/authority.js';
129
130
  import { caseCommand } from '../lib/commands/case.js';
130
131
  import { ticketCommand } from '../lib/commands/ticket.js';
@@ -296,6 +297,7 @@ await yargs(hideBin(process.argv))
296
297
  .command(statusSlaCommand)
297
298
  .command(emailInboxCommand)
298
299
  .command(callbackCommand)
300
+ .command(callpresenceCommand)
299
301
  .command(authorityCommand)
300
302
  .command(caseCommand)
301
303
  .command(ticketCommand)
@@ -0,0 +1,143 @@
1
+ import { messagingGet, messagingPut, messagingDel } from '../api.js';
2
+ import { runCommand } from '../run.js';
3
+
4
+ // -- velaro callpresence ---------------------------------------------------------
5
+ // Call-presence policy: what chat and call routing do while an agent is on a phone call, and what happens
6
+ // when the call ends. Site default -> routing group override -> agent override (only when the site permits
7
+ // agent overrides). Backend: velaro-messaging CallPresencePolicyController (route CallPresencePolicy).
8
+ // The site always comes from the credential (vmsg-siteId header), never from CLI args.
9
+
10
+ const WHILE_ON_CALL = ['NoChats', 'TakeChats', 'FinishThenOffline'];
11
+ const AFTER_CALL = ['ReturnAutomatically', 'AskAgent', 'StayOffline'];
12
+ const CALLS_WHILE_BUSY = ['NoCallsWhileBusy', 'RingEvenWhenBusy'];
13
+ const SCOPES = ['site', 'group', 'agent'];
14
+
15
+ const BOLD = '\x1b[1m';
16
+ const DIM = '\x1b[2m';
17
+ const RST = '\x1b[0m';
18
+
19
+ function printEffective(eff) {
20
+ for (const [key, label] of [['whileOnCall', 'While on a call'], ['afterCall', 'After the call'], ['callsWhileBusy', 'Calls while busy on chats']]) {
21
+ const f = eff?.[key];
22
+ if (f) console.log(` ${label.padEnd(26)} ${f.value} ${DIM}(${f.source})${RST}`);
23
+ }
24
+ }
25
+
26
+ async function getHandler(argv) {
27
+ const data = await messagingGet('/CallPresencePolicy');
28
+ if (argv.json) { console.log(JSON.stringify(data, null, 2)); return; }
29
+ console.log(`\n${BOLD}Call presence policy${RST}`);
30
+ console.log(' Site default:');
31
+ printEffective(data.effectiveSite);
32
+ console.log(` Agents may set their own override: ${data.allowAgentOverrides ? 'yes' : 'no'}`);
33
+ const groups = (data.groups ?? []).filter((g) => g.policy && (g.policy.whileOnCall || g.policy.afterCall || g.policy.callsWhileBusy));
34
+ if (groups.length) {
35
+ console.log(' Group overrides:');
36
+ for (const g of groups) console.log(` ${g.teamName} (#${g.teamId}): ${g.policy.whileOnCall ?? '-'} / ${g.policy.afterCall ?? '-'} / ${g.policy.callsWhileBusy ?? '-'} ring: ${g.ringStrategy}`);
37
+ }
38
+ if ((data.agents ?? []).length) {
39
+ console.log(' Agent overrides:');
40
+ for (const a of data.agents) console.log(` ${a.agentName} (#${a.agentId}): ${a.policy.whileOnCall ?? '-'} / ${a.policy.afterCall ?? '-'} / ${a.policy.callsWhileBusy ?? '-'}`);
41
+ }
42
+ console.log('');
43
+ }
44
+
45
+ async function setHandler(argv) {
46
+ const scope = argv.scope;
47
+ const id = scope === 'site' ? 0 : argv.id;
48
+ if (scope !== 'site' && !id) throw new Error('--id is required for group (team id) and agent (agent id) scope');
49
+ const body = {
50
+ whileOnCall: argv.whileOnCall ?? null,
51
+ afterCall: argv.afterCall ?? null,
52
+ callsWhileBusy: argv.callsWhileBusy ?? null,
53
+ };
54
+ if (scope === 'site' && argv.allowAgentOverrides !== undefined) body.allowAgentOverrides = argv.allowAgentOverrides;
55
+ const res = await messagingPut(`/CallPresencePolicy/${scope}/${id}`, body);
56
+ console.log(argv.json ? JSON.stringify(res, null, 2) : `Saved ${scope} ${id}.`);
57
+ }
58
+
59
+ async function clearHandler(argv) {
60
+ const id = argv.scope === 'site' ? 0 : argv.id;
61
+ if (argv.scope !== 'site' && !id) throw new Error('--id is required for group and agent scope');
62
+ await messagingDel(`/CallPresencePolicy/${argv.scope}/${id}`);
63
+ console.log(`Cleared ${argv.scope} ${id}. That level now inherits.`);
64
+ }
65
+
66
+ async function effectiveHandler(argv) {
67
+ const q = argv.team ? `?teamId=${argv.team}` : '';
68
+ const res = await messagingGet(`/CallPresencePolicy/effective/${argv.agentId}${q}`);
69
+ if (argv.json) { console.log(JSON.stringify(res, null, 2)); return; }
70
+ console.log(`\n${BOLD}Effective policy for agent ${res.agentId}${RST}`);
71
+ printEffective(res.effective);
72
+ console.log('');
73
+ }
74
+
75
+ async function statusHandler(argv) {
76
+ const res = await messagingGet('/CallPresencePolicy/presence');
77
+ if (argv.json) { console.log(JSON.stringify(res, null, 2)); return; }
78
+ if (!res.length) { console.log('\n No agents are on a call right now.\n'); return; }
79
+ console.log(`\n${BOLD}Agents on a call${RST}`);
80
+ for (const a of res) console.log(` ${a.agentName} (#${a.agentId}) calls: ${a.activeCallCount}${a.hasSecondCall ? ' [second call]' : ''} current: ${a.currentCallState}`);
81
+ console.log('');
82
+ }
83
+
84
+ const getCommand = {
85
+ command: 'get',
86
+ describe: 'Show the site default, group overrides, agent overrides and the allowed values',
87
+ builder: (y) => y.option('json', { type: 'boolean', describe: 'Raw JSON' }),
88
+ handler: runCommand(getHandler),
89
+ };
90
+
91
+ const setCommand = {
92
+ command: 'set',
93
+ describe: 'Set the policy for the site, a routing group or an agent (omit a setting to inherit)',
94
+ builder: (y) => y
95
+ .option('scope', { choices: SCOPES, demandOption: true, describe: 'Level to set' })
96
+ .option('id', { type: 'number', describe: 'Team id (group scope) or agent id (agent scope)' })
97
+ .option('while-on-call', { choices: WHILE_ON_CALL, describe: 'Chats while on a phone call' })
98
+ .option('after-call', { choices: AFTER_CALL, describe: 'After the call ends' })
99
+ .option('calls-while-busy', { choices: CALLS_WHILE_BUSY, describe: 'Calls for an agent busy on chats' })
100
+ .option('allow-agent-overrides', { type: 'boolean', describe: 'Site scope only: may agents set their own override' })
101
+ .option('json', { type: 'boolean', describe: 'Raw JSON' }),
102
+ handler: runCommand(setHandler),
103
+ };
104
+
105
+ const clearCommand = {
106
+ command: 'clear',
107
+ describe: 'Remove the policy at one level so it inherits again',
108
+ builder: (y) => y
109
+ .option('scope', { choices: SCOPES, demandOption: true })
110
+ .option('id', { type: 'number', describe: 'Team id (group) or agent id (agent)' }),
111
+ handler: runCommand(clearHandler),
112
+ };
113
+
114
+ const effectiveCommand = {
115
+ command: 'effective <agentId>',
116
+ describe: 'Show the resolved policy for one agent and where each setting comes from',
117
+ builder: (y) => y
118
+ .positional('agentId', { type: 'number' })
119
+ .option('team', { type: 'number', describe: 'Routing group to resolve against (agents in several groups)' })
120
+ .option('json', { type: 'boolean', describe: 'Raw JSON' }),
121
+ handler: runCommand(effectiveHandler),
122
+ };
123
+
124
+ const statusCommand = {
125
+ command: 'status',
126
+ describe: 'Agents who are on a live call right now (derived from call records)',
127
+ builder: (y) => y.option('json', { type: 'boolean', describe: 'Raw JSON' }),
128
+ handler: runCommand(statusHandler),
129
+ };
130
+
131
+ export const callpresenceCommand = {
132
+ command: 'callpresence <subcommand>',
133
+ describe: 'Call presence policy: chat and call routing while an agent is on a phone call',
134
+ builder: (y) => y
135
+ .command(getCommand)
136
+ .command(setCommand)
137
+ .command(clearCommand)
138
+ .command(effectiveCommand)
139
+ .command(statusCommand)
140
+ .demandCommand(1, 'Specify a callpresence subcommand.')
141
+ .strict(),
142
+ handler: () => {},
143
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velaro/cli",
3
- "version": "1.4.119",
3
+ "version": "1.4.120",
4
4
  "description": "Velaro Workspace v20 — command-line interface for managing bots, knowledge base ingestion, MCP API keys, search indexes, and ops health.",
5
5
  "type": "module",
6
6
  "bin": {