@velaro/cli 1.4.122 → 1.4.123

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.
@@ -4,7 +4,10 @@
4
4
  * velaro teams-phone status Show current configuration
5
5
  * velaro teams-phone set --tenant-id ... Create or update the configuration
6
6
  * velaro teams-phone remove Delete the configuration
7
- * velaro teams-phone test Run the inbound-calling readiness checks
7
+ * velaro teams-phone test Run the calling readiness checks (ACS connection, callback, consent, resource account)
8
+ * velaro teams-phone queue list List queues with their max wait for a free agent
9
+ * velaro teams-phone queue set --resource-account-id <guid> [--max-wait-seconds 30-600] ... Create or update a queue
10
+ * velaro teams-phone queue delete <id> Delete a queue
8
11
  * velaro teams-phone agents list List agents and their Teams user object IDs
9
12
  * velaro teams-phone agents set <agentId> <teamsUserId> Map an agent to an Entra user Object ID
10
13
  * velaro teams-phone agents delete <agentId> Clear an agent's mapping
@@ -87,8 +90,11 @@ async function removeHandler() {
87
90
 
88
91
  async function testHandler() {
89
92
  const result = await messagingPost('/TeamsPhone/Config/Test', {});
90
- const color = result?.success ? GRN : RED;
91
- console.log(`\n${color}${result?.success ? 'Success' : 'Failed'}${RST}: ${result?.message ?? '(no message)'}`);
93
+ // No checks reported is never a pass: an empty body must not read as ready.
94
+ const noChecks = !Array.isArray(result?.checks) || result.checks.length === 0;
95
+ const passed = result?.success === true && !noChecks;
96
+ const color = passed ? GRN : RED;
97
+ console.log(`\n${color}${passed ? 'Success' : 'Failed'}${RST}: ${result?.message ?? '(no message)'}${noChecks ? ' The test returned no checks, so nothing was verified.' : ''}`);
92
98
  if (typeof result?.callingReady === 'boolean') {
93
99
  console.log(` Inbound calling ready: ${result.callingReady ? GRN : RED}${result.callingReady}${RST}`);
94
100
  }
@@ -98,7 +104,75 @@ async function testHandler() {
98
104
  }
99
105
  }
100
106
  console.log('');
101
- if (!result?.success) process.exitCode = 1;
107
+ if (!passed) process.exitCode = 1;
108
+ }
109
+
110
+ // -- queue (extra resource accounts, each with its own max wait) -------------------
111
+
112
+ /** GET /TeamsPhone/Queues returns { queues: [...] }. Any other shape is an error, never an empty list. */
113
+ export function queuesFromResponse(res) {
114
+ if (!res || !Array.isArray(res.queues)) {
115
+ throw new Error(`Unexpected response from GET /TeamsPhone/Queues (expected { queues: [...] }): ${JSON.stringify(res)?.slice(0, 300)}`);
116
+ }
117
+ return res.queues;
118
+ }
119
+
120
+ async function queueListHandler() {
121
+ let queues;
122
+ try {
123
+ queues = queuesFromResponse(await messagingGet('/TeamsPhone/Queues'));
124
+ } catch (err) {
125
+ console.error(`
126
+ ${RED}${err.message}${RST}
127
+ `);
128
+ process.exit(1);
129
+ }
130
+ if (queues.length === 0) {
131
+ console.log(`
132
+ ${DIM}No queues found.${RST}
133
+ `);
134
+ return;
135
+ }
136
+ console.log(`
137
+ ${BOLD}Teams Phone queues${RST}`);
138
+ for (const q of queues) {
139
+ const wait = typeof q.maxWaitSeconds === 'number' ? `${q.maxWaitSeconds}s` : `${DIM}default${RST}`;
140
+ console.log(` ${String(q.id).padEnd(6)} ${String(q.queueName ?? q.assignedPhoneNumber ?? '').padEnd(28)} ring ${String(q.ringTimeoutSeconds ?? '').padEnd(4)} max wait ${wait}`);
141
+ }
142
+ console.log('');
143
+ }
144
+
145
+ async function queueSetHandler(argv) {
146
+ const wait = argv.maxWaitSeconds;
147
+ if (wait !== undefined && (!Number.isInteger(wait) || wait < 30 || wait > 600)) {
148
+ throw new Error('--max-wait-seconds must be a whole number from 30 to 600.');
149
+ }
150
+ // POST is an upsert keyed by resource account: fields left undefined would overwrite stored values with null. So read
151
+ // the existing queue first and pass its current values through for every flag the admin did not give.
152
+ const listed = await messagingGet('/TeamsPhone/Queues');
153
+ const existing = Array.isArray(listed?.queues)
154
+ ? listed.queues.find((q) => q.applicationInstanceObjectId === argv.resourceAccountId)
155
+ : undefined;
156
+ const pick = (given, key) => (given !== undefined ? given : existing?.[key]);
157
+ const body = {
158
+ applicationInstanceObjectId: argv.resourceAccountId,
159
+ assignedPhoneNumber: pick(argv.phoneNumber, 'assignedPhoneNumber'),
160
+ queueName: pick(argv.name, 'queueName'),
161
+ teamId: pick(argv.teamId, 'teamId'),
162
+ ringTimeoutSeconds: pick(argv.ringTimeoutSeconds, 'ringTimeoutSeconds'),
163
+ maxWaitSeconds: pick(wait, 'maxWaitSeconds'),
164
+ };
165
+ const r = await messagingPost('/TeamsPhone/Queues', body);
166
+ const q = r?.queue;
167
+ const saved = q?.maxWaitSeconds ?? body.maxWaitSeconds;
168
+ console.log(`
169
+ ${GRN}✓${RST} Queue saved${q?.id !== undefined ? ` (id ${q.id})` : ''}. Max wait: ${saved !== undefined && saved !== null ? `${saved} seconds` : 'default'}.
170
+ `);
171
+ }
172
+
173
+ async function queueDeleteHandler(argv) {
174
+ await messagingDel(`/TeamsPhone/Queues/${encodeURIComponent(argv.id)}`);
175
+ console.log(`\n${GRN}✓${RST} Queue ${argv.id} deleted.\n`);
102
176
  }
103
177
 
104
178
  // -- agents (agent -> Entra user object id) ---------------------------------------
@@ -169,10 +243,41 @@ export const teamsPhoneCommand = {
169
243
  })
170
244
  .command({
171
245
  command: 'test',
172
- describe: 'Run the Teams Phone readiness checks (consent, resource account, Graph reachability) and print each check',
246
+ describe: 'Run the Teams Phone calling readiness checks (tenant ID, resource account, admin consent, inbound call routing) and print each check as PASS or FAIL',
173
247
  builder: yy => yy,
174
248
  handler: testHandler,
175
249
  })
250
+ .command({
251
+ command: 'queue <action>',
252
+ describe: 'Queues: extra resource accounts, each with its own max wait for a free agent (list | set | delete)',
253
+ builder: yy => yy
254
+ .command({
255
+ command: 'list',
256
+ describe: 'List queues with their max wait',
257
+ builder: z => z,
258
+ handler: queueListHandler,
259
+ })
260
+ .command({
261
+ command: 'set',
262
+ describe: 'Create or update a queue (keyed by --resource-account-id)',
263
+ builder: z => z
264
+ .option('resource-account-id', { describe: 'Teams resource account (application instance) object ID of the queue', type: 'string', demandOption: true })
265
+ .option('phone-number', { describe: 'Queue phone number (E.164)', type: 'string' })
266
+ .option('name', { describe: 'Queue name shown in reports and on the call pop', type: 'string' })
267
+ .option('team-id', { describe: 'Velaro team whose agents this queue rings; omit for any available agent', type: 'number' })
268
+ .option('ring-timeout-seconds', { describe: 'Seconds each agent is rung before moving on', type: 'number' })
269
+ .option('max-wait-seconds', { describe: 'Longest a caller waits for a free agent, 30 to 600 (default 120)', type: 'number' }),
270
+ handler: queueSetHandler,
271
+ })
272
+ .command({
273
+ command: 'delete <id>',
274
+ describe: 'Delete a queue',
275
+ builder: z => z.positional('id', { type: 'number', describe: 'Queue id from queue list' }),
276
+ handler: queueDeleteHandler,
277
+ })
278
+ .demandCommand(1, 'Specify list, set or delete.'),
279
+ handler: () => {},
280
+ })
176
281
  .command({
177
282
  command: 'agents <action>',
178
283
  describe: 'Agent mapping: which Entra user Object ID is which Velaro agent (list | set | delete)',
@@ -0,0 +1,15 @@
1
+ import test from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { queuesFromResponse } from './commands/teams-phone.js';
4
+
5
+ test('queue list reads the queues key', () => {
6
+ const q = [{ id: 1, maxWaitSeconds: 90 }];
7
+ assert.deepEqual(queuesFromResponse({ queues: q }), q);
8
+ assert.deepEqual(queuesFromResponse({ queues: [] }), []);
9
+ });
10
+
11
+ test('queue list rejects a bare array or error body instead of reporting no queues', () => {
12
+ assert.throws(() => queuesFromResponse([{ id: 1 }]), /Unexpected response/);
13
+ assert.throws(() => queuesFromResponse({ error: 'boom' }), /Unexpected response/);
14
+ assert.throws(() => queuesFromResponse(null), /Unexpected response/);
15
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velaro/cli",
3
- "version": "1.4.122",
3
+ "version": "1.4.123",
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": {