@velaro/cli 1.4.119 → 1.4.121

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 (66) hide show
  1. package/README.md +0 -19
  2. package/bin/velaro.js +23 -92
  3. package/lib/avatar-motion.test.js +1 -1
  4. package/lib/avatar-switch.test.js +1 -1
  5. package/lib/commands/agent.js +7 -58
  6. package/lib/commands/ai-config.js +8 -34
  7. package/lib/commands/callpresence.js +143 -0
  8. package/lib/commands/index.js +18 -14
  9. package/lib/commands/kb.js +4 -94
  10. package/lib/commands/knowledge.js +2 -2
  11. package/lib/commands/ops-groups.js +0 -13
  12. package/lib/commands/safety.js +1 -1
  13. package/lib/commands/salesforce.js +1 -1
  14. package/lib/commands/sap.js +1 -1
  15. package/lib/commands/schedule-adherence.js +1 -1
  16. package/lib/commands/teams.js +1 -1
  17. package/lib/commands/woocommerce.js +1 -1
  18. package/lib/commands/workflow.js +4 -31
  19. package/lib/staff-optional.js +10 -0
  20. package/package.json +2 -2
  21. package/lib/cobrowse-settings.js +0 -90
  22. package/lib/cobrowse-settings.test.js +0 -45
  23. package/lib/commands/activity.js +0 -147
  24. package/lib/commands/acuity.js +0 -66
  25. package/lib/commands/ai-federation.js +0 -55
  26. package/lib/commands/ai-models.js +0 -203
  27. package/lib/commands/ai-spend.js +0 -71
  28. package/lib/commands/avatar.js +0 -253
  29. package/lib/commands/bigcommerce.js +0 -50
  30. package/lib/commands/calendly.js +0 -62
  31. package/lib/commands/cobrowse.js +0 -99
  32. package/lib/commands/coupon-grant.js +0 -192
  33. package/lib/commands/diag-groups.js +0 -108
  34. package/lib/commands/diagnostics.js +0 -298
  35. package/lib/commands/email-inbox.js +0 -110
  36. package/lib/commands/entitlement.js +0 -375
  37. package/lib/commands/image-analysis.js +0 -27
  38. package/lib/commands/logs-insights.js +0 -342
  39. package/lib/commands/logs.js +0 -1248
  40. package/lib/commands/migrate.js +0 -379
  41. package/lib/commands/migration-status.js +0 -66
  42. package/lib/commands/ops.js +0 -266
  43. package/lib/commands/parity-staff-tools.js +0 -205
  44. package/lib/commands/pricing.js +0 -132
  45. package/lib/commands/report-speed.js +0 -112
  46. package/lib/commands/scraper.js +0 -38
  47. package/lib/commands/site-provision.js +0 -68
  48. package/lib/commands/sitesync.js +0 -158
  49. package/lib/commands/skill-usage.js +0 -39
  50. package/lib/commands/staff.js +0 -31
  51. package/lib/commands/status-page.js +0 -95
  52. package/lib/commands/status-sla.js +0 -47
  53. package/lib/commands/subscription.js +0 -102
  54. package/lib/commands/support.js +0 -309
  55. package/lib/commands/tour-policy.js +0 -61
  56. package/lib/commands/triage.js +0 -66
  57. package/lib/entitlement-report-packages.test.js +0 -47
  58. package/lib/log-search.js +0 -252
  59. package/lib/log-search.test.js +0 -374
  60. package/lib/logs-insights.test.js +0 -146
  61. package/lib/messaging-routes.test.js +0 -37
  62. package/lib/report-speed.test.js +0 -26
  63. package/lib/siteUser.js +0 -35
  64. package/lib/siteUser.test.js +0 -45
  65. package/lib/skill-usage.test.js +0 -36
  66. package/lib/status-sla.test.js +0 -23
package/README.md CHANGED
@@ -138,25 +138,6 @@ velaro kb article screenshot 1234 \
138
138
 
139
139
  > Titles are auto-normalized to Title Case with no dashes, even if you pass a slug-style name — use `--no-title-normalize` to skip that.
140
140
 
141
- ### `velaro logs insights <subcommand>` (Velaro staff only)
142
-
143
- Grouped views over Velaro Logger data (same data as the Admin UI "Insights" tab). All subcommands accept `--last 6h`, `--platform v10|v20|admin`, `--environment Production|Staging`, `--site <id>`, `--env staging|prod` and `--json`.
144
-
145
- ```bash
146
- velaro logs insights groups --last 6h --platform v20 # error groups, most frequent first
147
- velaro logs insights new # groups not seen in the previous 7 days
148
- velaro logs insights regression --at 2h # before vs after a deploy
149
- velaro logs insights trace <correlationId> # cross-platform timeline
150
- velaro logs insights trace --site 1032 --last 30m
151
- velaro logs insights anomalies --hours 48
152
- velaro logs insights sites # per-site scorecard
153
- velaro logs insights mutes
154
- velaro logs insights mute <fingerprint> --reason "known outage" --expires 7d
155
- velaro logs insights unmute <fingerprint>
156
- velaro logs insights sensitive # emails/tokens/cards in logs
157
- velaro logs insights brief <fingerprint> # AI markdown brief
158
- ```
159
-
160
141
  ### `velaro status`
161
142
  Check that the Velaro API is reachable.
162
143
 
package/bin/velaro.js CHANGED
@@ -16,18 +16,10 @@ import { productMatchCommand } from '../lib/commands/product-match.js';
16
16
  import { knowledgeCommand } from '../lib/commands/knowledge.js';
17
17
  import { productCommand } from '../lib/commands/product.js';
18
18
  import { mcpKeyCommand } from '../lib/commands/mcp-key.js';
19
- import { opsCommand } from '../lib/commands/ops.js';
20
- import { cobrowseCommand } from '../lib/commands/cobrowse.js';
21
19
  import { deployStateCommand } from '../lib/commands/deploy-state.js';
22
20
  import { checkCommand } from '../lib/commands/check.js';
23
- import { logsCommand } from '../lib/commands/logs.js';
24
- import { aiModelsCommand } from '../lib/commands/ai-models.js';
25
- import { reportSpeedCommand } from '../lib/commands/report-speed.js';
26
21
  import { siteCommand } from '../lib/commands/site.js';
27
- import { siteProvisionCommand } from '../lib/commands/site-provision.js';
28
- import { siteSyncCommand } from '../lib/commands/sitesync.js';
29
22
  import { statusCommand } from '../lib/commands/status.js';
30
- import { activityCommand } from '../lib/commands/activity.js';
31
23
  import { ruleCommand } from '../lib/commands/rule.js';
32
24
  import { teamCommand } from '../lib/commands/team.js';
33
25
  import { dynamicsCommand } from '../lib/commands/dynamics.js';
@@ -41,13 +33,9 @@ import { notificationsCommand } from '../lib/commands/notifications.js';
41
33
  import { signatureCommand } from '../lib/commands/signature.js';
42
34
  import { articleCommand } from '../lib/commands/article.js';
43
35
  import { sharepointCommand } from '../lib/commands/sharepoint.js';
44
- import { calendlyCommand } from '../lib/commands/calendly.js';
45
36
  import { imageCommand } from '../lib/commands/image.js';
46
37
  import { copilotStudioCommand } from '../lib/commands/copilotstudio.js';
47
- import { acuityCommand } from '../lib/commands/acuity.js';
48
- import { avatarCommand } from '../lib/commands/avatar.js';
49
38
  import { applePayPresetCommand } from '../lib/commands/apple-pay-preset.js';
50
- import { imageAnalysisCommand } from '../lib/commands/image-analysis.js';
51
39
  import { integrationCommand } from '../lib/commands/integration.js';
52
40
  import { appointmentsCommand } from '../lib/commands/appointments.js';
53
41
  import { bookingCommand } from '../lib/commands/booking.js';
@@ -57,7 +45,6 @@ import { reportSubscriptionCommand } from '../lib/commands/report-subscription.j
57
45
  import { experienceImpactCommand } from '../lib/commands/experience-impact.js';
58
46
  import { enterpriseReportsCommand } from '../lib/commands/enterprise-reports.js';
59
47
  import { reportBackfillCommand } from '../lib/commands/report-backfill.js';
60
- import { staffCommand } from '../lib/commands/staff.js';
61
48
  import { reportExplainCommand } from '../lib/commands/report-explain.js';
62
49
  import { conversationEfficiencyCommand } from '../lib/commands/conversation-efficiency.js';
63
50
  import { executiveInsightsCommand } from '../lib/commands/executive-insights.js';
@@ -70,7 +57,6 @@ import { cannedLearningCommand } from '../lib/commands/canned-learning.js';
70
57
  import { csatOverrideUnapproveCommand } from '../lib/commands/csat-override.js';
71
58
  import { chatIntelligenceTopicsCommand } from '../lib/commands/chat-intelligence-topics.js';
72
59
  import { focusCommand } from '../lib/commands/focus.js';
73
- import { triageCommand } from '../lib/commands/triage.js';
74
60
  import { automationDraftCommand } from '../lib/commands/automation-draft.js';
75
61
  import { magentoCommand } from '../lib/commands/magento.js';
76
62
  import { sapCommand } from '../lib/commands/sap.js';
@@ -94,9 +80,6 @@ import { commerceRoutingCommand } from '../lib/commands/commerce-routing.js';
94
80
  import { netsuiteCommand } from '../lib/commands/netsuite.js';
95
81
  import { woocommerceCommand } from '../lib/commands/woocommerce.js';
96
82
  import { squarespaceCommand } from '../lib/commands/squarespace.js';
97
- import { bigcommerceCommand } from '../lib/commands/bigcommerce.js';
98
- import { migrateCommand } from '../lib/commands/migrate.js';
99
- import { migrationStatusCommand } from '../lib/commands/migration-status.js';
100
83
  import { complianceCommand } from '../lib/commands/compliance.js';
101
84
  import { billingContactsCommand } from '../lib/commands/billing-contacts.js';
102
85
  import { billingSubscriptionCommand } from '../lib/commands/billing-subscription.js';
@@ -105,26 +88,15 @@ import { orderFormCommand } from '../lib/commands/order-form.js';
105
88
  import { priceIncreaseCommand } from '../lib/commands/price-increase.js';
106
89
  import { billingEmailPreferenceCommand } from '../lib/commands/billing-email-preference.js';
107
90
  import { billingCommand } from '../lib/commands/billing.js';
108
- import { couponGrantCommand } from '../lib/commands/coupon-grant.js';
109
91
  import { signCommand } from '../lib/commands/sign.js';
110
92
  import { widgetContainerCommand } from '../lib/commands/widget-container.js';
111
93
  import { inlineWidgetConfigCommand } from '../lib/commands/inline-widget-config.js';
112
- import { pricingCommand } from '../lib/commands/pricing.js';
113
94
  import { billingAgentsCommand } from '../lib/commands/billing-agents.js';
114
95
  import { packageBuilderCommand } from '../lib/commands/package-builder.js';
115
- import { entitlementCommand } from '../lib/commands/entitlement.js';
116
- import { subscriptionCommand } from '../lib/commands/subscription.js';
117
- import { supportCommand } from '../lib/commands/support.js';
118
96
  import { routingCommand } from '../lib/commands/routing.js';
119
- import { diagnosticsCommand } from '../lib/commands/diagnostics.js';
120
- import { aiSpendCommand } from '../lib/commands/ai-spend.js';
121
- import { skillUsageCommand } from '../lib/commands/skill-usage.js';
122
- import { aiFederationCommand } from '../lib/commands/ai-federation.js';
123
- import { statusPageCommand } from '../lib/commands/status-page.js';
124
97
  import { statusNotifyCommand } from '../lib/commands/status-notify.js';
125
- import { statusSlaCommand } from '../lib/commands/status-sla.js';
126
- import { emailInboxCommand } from '../lib/commands/email-inbox.js';
127
98
  import { callbackCommand } from '../lib/commands/callback.js';
99
+ import { callpresenceCommand } from '../lib/commands/callpresence.js';
128
100
  import { authorityCommand } from '../lib/commands/authority.js';
129
101
  import { caseCommand } from '../lib/commands/case.js';
130
102
  import { ticketCommand } from '../lib/commands/ticket.js';
@@ -140,18 +112,13 @@ import { surveyCommand } from '../lib/commands/survey.js';
140
112
  import { bundleCommand } from '../lib/commands/bundle.js';
141
113
  import { chatWindowCommand } from '../lib/commands/chat-window.js';
142
114
  import { featureDiscoveryCommand } from '../lib/commands/feature-discovery.js';
143
- import { tourPolicyCommand } from '../lib/commands/tour-policy.js';
144
- import { livefluenceCommand, missedCommand, serviceCommand, pageCommand, uploadedCommand, msCommand, outlookCommand, oauthCommand, provisionCommand, sseCommand, skillCommand, v10Command, whatsappCommand, mobileCommand, signalrCommand, supportGroupCommand, pricingGroupCommand, scraperGroupCommand, tourPolicyGroupCommand } from '../lib/commands/parity-staff-tools.js';
145
- import { scraperCommand } from '../lib/commands/scraper.js';
146
115
  import { usageCommand } from '../lib/commands/usage.js';
147
116
  import { campaignsCommand } from '../lib/commands/campaigns.js';
148
117
  import { senderDomainHealthCommand } from '../lib/commands/sender-domain-health.js';
149
118
  import { contactsCommand } from '../lib/commands/contacts.js';
150
119
  import { contactListCommand } from '../lib/commands/contact-list.js';
151
120
  import { recycleBinCommand, aiUsageCommand, siteInfoCommand, billingReceiptsCommand } from '../lib/commands/endpoint-parity.js';
152
- import { adminCommand, appleCommand, forceExpireSiteCommand, backfillCommand, kpiCommand, auditTrailCommand, codeCommand, crmCommand, hangfireCommand } from '../lib/commands/diag-groups.js';
153
- import { aiFollowupsCommand, businessActionCommand, callCommand, conversationCommand, conversionCommand, emailCommand, ivrCommand } from '../lib/commands/ops-groups.js';
154
- import { entitlementGroup } from '../lib/commands/entitlement.js';
121
+ import { aiFollowupsCommand, businessActionCommand, callCommand, conversationCommand, conversionCommand, ivrCommand } from '../lib/commands/ops-groups.js';
155
122
  import { featureDiscoveryGroup } from '../lib/commands/feature-discovery.js';
156
123
  import { billingInsightsGroup } from '../lib/commands/billing-insights.js';
157
124
  import { startUpdateCheck } from '../lib/update-check.js';
@@ -167,7 +134,17 @@ if (!printBannerIfFirstRun() && frontDoor) printBanner({ version: cliVersion });
167
134
 
168
135
  const printUpdateNoticeIfStale = startUpdateCheck();
169
136
 
170
- await yargs(hideBin(process.argv))
137
+ // Staff commands live in cli/staff, which is NOT in the "files" allowlist of package.json, so the public npm install does not have it.
138
+ // A dev checkout or a staff install does; load it only when present (scripts/validate-cli-no-staff-commands.js guards the split).
139
+ let registerStaffCommands = null;
140
+ try {
141
+ ({ registerStaffCommands } = await import('../staff/register.js'));
142
+ } catch (e) {
143
+ if (e?.code !== 'ERR_MODULE_NOT_FOUND' || !/staff[\\/]register\.js/.test(String(e.message))) throw e;
144
+ }
145
+ const baseYargs = yargs(hideBin(process.argv));
146
+
147
+ await (registerStaffCommands ? registerStaffCommands(baseYargs) : baseYargs)
171
148
  .scriptName('velaro')
172
149
  .usage('$0 <command> [options]')
173
150
  .command(loginCommand)
@@ -185,18 +162,10 @@ await yargs(hideBin(process.argv))
185
162
  .command(knowledgeCommand)
186
163
  .command(productCommand)
187
164
  .command(mcpKeyCommand)
188
- .command(opsCommand)
189
- .command(cobrowseCommand)
190
165
  .command(deployStateCommand)
191
166
  .command(checkCommand)
192
- .command(logsCommand)
193
- .command(aiModelsCommand)
194
- .command(reportSpeedCommand)
195
167
  .command(siteCommand)
196
- .command(siteProvisionCommand)
197
- .command(siteSyncCommand)
198
168
  .command(statusCommand)
199
- .command(activityCommand)
200
169
  .command(ruleCommand)
201
170
  .command(teamCommand)
202
171
  .command(dynamicsCommand)
@@ -210,13 +179,9 @@ await yargs(hideBin(process.argv))
210
179
  .command(signatureCommand)
211
180
  .command(articleCommand)
212
181
  .command(sharepointCommand)
213
- .command(calendlyCommand)
214
182
  .command(imageCommand)
215
183
  .command(copilotStudioCommand)
216
- .command(acuityCommand)
217
- .command(avatarCommand)
218
184
  .command(applePayPresetCommand)
219
- .command(imageAnalysisCommand)
220
185
  .command(integrationCommand)
221
186
  .command(appointmentsCommand)
222
187
  .command(bookingCommand)
@@ -228,7 +193,6 @@ await yargs(hideBin(process.argv))
228
193
  .command(enterpriseReportsCommand)
229
194
  .command(reportSubscriptionCommand)
230
195
  .command(reportBackfillCommand)
231
- .command({ command: 'staff', desc: 'Velaro staff: cross-site tools (backfill)', builder: staffCommand, handler: () => {} })
232
196
  .command(reportExplainCommand)
233
197
  .command(dbCommand)
234
198
  .command(skillRoutingCommand)
@@ -241,7 +205,6 @@ await yargs(hideBin(process.argv))
241
205
  .command(chatIntelligenceTopicsCommand)
242
206
  .command(csatOverrideUnapproveCommand)
243
207
  .command(focusCommand)
244
- .command(triageCommand)
245
208
  .command(automationDraftCommand)
246
209
  .command(magentoCommand)
247
210
  .command(sapCommand)
@@ -265,9 +228,6 @@ await yargs(hideBin(process.argv))
265
228
  .command(netsuiteCommand)
266
229
  .command(woocommerceCommand)
267
230
  .command(squarespaceCommand)
268
- .command(bigcommerceCommand)
269
- .command(migrateCommand)
270
- .command(migrationStatusCommand)
271
231
  .command(complianceCommand)
272
232
  .command(billingContactsCommand)
273
233
  .command(billingSubscriptionCommand)
@@ -276,26 +236,15 @@ await yargs(hideBin(process.argv))
276
236
  .command(priceIncreaseCommand)
277
237
  .command(billingEmailPreferenceCommand)
278
238
  .command(billingCommand)
279
- .command(couponGrantCommand)
280
239
  .command(signCommand)
281
240
  .command(widgetContainerCommand)
282
241
  .command(inlineWidgetConfigCommand)
283
- .command(pricingGroupCommand)
284
- .command(entitlementGroup)
285
242
  .command({ command: 'billing-agents', desc: 'Run and review the billing agents (staff)', builder: billingAgentsCommand, handler: () => {} })
286
243
  .command({ command: 'package-builder', desc: 'Package graph, drafts, simulation, audit (staff)', builder: packageBuilderCommand, handler: () => {} })
287
- .command({ command: 'subscription', desc: 'Apply/diff SubscriptionPackage packages on a site (superadmin only)', builder: subscriptionCommand, handler: () => {} })
288
- .command(supportGroupCommand)
289
244
  .command(routingCommand)
290
- .command(diagnosticsCommand)
291
- .command(aiSpendCommand)
292
- .command(skillUsageCommand)
293
- .command(aiFederationCommand)
294
- .command(statusPageCommand)
295
245
  .command(statusNotifyCommand)
296
- .command(statusSlaCommand)
297
- .command(emailInboxCommand)
298
246
  .command(callbackCommand)
247
+ .command(callpresenceCommand)
299
248
  .command(authorityCommand)
300
249
  .command(caseCommand)
301
250
  .command(ticketCommand)
@@ -312,23 +261,6 @@ await yargs(hideBin(process.argv))
312
261
  .command(chatWindowCommand)
313
262
  .command(featureDiscoveryGroup)
314
263
  .command(billingInsightsGroup)
315
- .command(scraperGroupCommand)
316
- .command(tourPolicyGroupCommand)
317
- .command(livefluenceCommand)
318
- .command(missedCommand)
319
- .command(serviceCommand)
320
- .command(pageCommand)
321
- .command(uploadedCommand)
322
- .command(msCommand)
323
- .command(outlookCommand)
324
- .command(oauthCommand)
325
- .command(provisionCommand)
326
- .command(sseCommand)
327
- .command(skillCommand)
328
- .command(v10Command)
329
- .command(whatsappCommand)
330
- .command(mobileCommand)
331
- .command(signalrCommand)
332
264
  .command(usageCommand)
333
265
  .command(campaignsCommand)
334
266
  .command(senderDomainHealthCommand)
@@ -338,24 +270,23 @@ await yargs(hideBin(process.argv))
338
270
  .command(aiUsageCommand)
339
271
  .command(siteInfoCommand)
340
272
  .command(billingReceiptsCommand)
341
- .command(adminCommand)
342
- .command(appleCommand)
343
- .command(forceExpireSiteCommand)
344
- .command(backfillCommand)
345
- .command(kpiCommand)
346
- .command(auditTrailCommand)
347
- .command(codeCommand)
348
- .command(crmCommand)
349
- .command(hangfireCommand)
350
273
  .command(aiFollowupsCommand)
351
274
  .command(businessActionCommand)
352
275
  .command(callCommand)
353
276
  .command(conversationCommand)
354
277
  .command(conversionCommand)
355
- .command(emailCommand)
356
278
  .command(ivrCommand)
357
279
  .demandCommand(1, 'Specify a command. Run "velaro --help" for options.')
358
280
  .strict()
281
+ .fail((msg, err, y) => {
282
+ if (err) throw err;
283
+ y.showHelp('error');
284
+ console.error(`\n${msg}`);
285
+ if (!registerStaffCommands && /unknown (command|argument)/i.test(String(msg))) {
286
+ console.error('If that is an internal command, it is only in the staff build (a dev checkout or staff install), not the public npm package.');
287
+ }
288
+ process.exit(1);
289
+ })
359
290
  .help()
360
291
  .parseAsync();
361
292
 
@@ -25,7 +25,7 @@ test('only supplied motion args reach the request body', () => {
25
25
  });
26
26
 
27
27
  test('avatar command wires the helper on enable and set, and override accepts --motion-level', async () => {
28
- const src = fs.readFileSync(new URL('./commands/avatar.js', import.meta.url), 'utf8');
28
+ const src = fs.readFileSync(new URL('../staff/commands/avatar.js', import.meta.url), 'utf8');
29
29
  assert.match(src, /applyMotionArgs\(body, argv\)/);
30
30
  assert.match(src, /'motion-level'/);
31
31
  const { overrideBody } = await import('./avatar-override.js');
@@ -36,7 +36,7 @@ test('bulk switch builds the request shape and enforces selection rules', () =>
36
36
  });
37
37
 
38
38
  test('avatar command registers workflow-switch and bulk-switch and the MCP server exposes matching tools', () => {
39
- const src = fs.readFileSync(new URL('./commands/avatar.js', import.meta.url), 'utf8');
39
+ const src = fs.readFileSync(new URL('../staff/commands/avatar.js', import.meta.url), 'utf8');
40
40
  assert.match(src, /command:\s+'workflow-switch <workflowId> <value>'/);
41
41
  assert.match(src, /command:\s+'bulk-switch'/);
42
42
  assert.match(src, /\/avatar\/workflows\/\$\{id\}\/enabled/);
@@ -1,5 +1,8 @@
1
1
  import { get, post, messagingGet, messagingPost, messagingPut, messagingDel, getCredentials } from '../api.js';
2
2
  import { runCommand } from '../run.js';
3
+ import { loadStaff } from '../staff-optional.js';
4
+
5
+ const staffAgent = await loadStaff('commands/agent-staff.js');
3
6
 
4
7
  const VALID_STATUSES = ['Available', 'Busy', 'Away', 'Offline'];
5
8
 
@@ -26,7 +29,7 @@ function fmtSec(s) {
26
29
  export const agentCommand = {
27
30
  command: 'agent <subcommand>',
28
31
  describe: 'View and manage agents',
29
- builder: (yargs) => yargs
32
+ builder: (yargs) => (staffAgent ? staffAgent.addAgentStaffCommands(yargs) : yargs)
30
33
  .command({
31
34
  command: 'list',
32
35
  describe: 'List agents and their current availability',
@@ -55,60 +58,6 @@ export const agentCommand = {
55
58
  console.log(`\n${rows.length} agent(s)`);
56
59
  }),
57
60
  })
58
- .command({
59
- command: 'create',
60
- describe: 'Provision a new licensed agent/admin on an EXISTING site (Velaro staff only) -- ' +
61
- 'closes the gap where site-provision only creates brand-new sites and Users/List ' +
62
- 'requires an existing site admin, which a zero-agent site can never have',
63
- builder: (y) => y
64
- .option('site-id', { type: 'number', demandOption: true, describe: 'Target site ID (must already exist)' })
65
- .option('email', { type: 'string', demandOption: true, describe: 'New agent email' })
66
- .option('first-name', { type: 'string', describe: 'First name' })
67
- .option('last-name', { type: 'string', describe: 'Last name' })
68
- .option('roles', { type: 'array', describe: 'Roles to grant, e.g. --roles Administrator (default: Administrator). "Velaro Admin"/"Velaro Support" are always stripped server-side.' })
69
- .option('team-ids', { type: 'array', describe: 'Team IDs on the target site (default: the site\'s first team)' })
70
- .option('max-chats', { type: 'number', describe: 'Concurrent chat capacity (default: site ceiling, usually 4)' }),
71
- handler: runCommand(async (argv) => {
72
- const creds = await getCredentials();
73
- if (creds.siteId !== 1032) {
74
- console.error('This command is only available to Velaro staff.');
75
- process.exit(1);
76
- }
77
-
78
- const body = {
79
- email: argv.email,
80
- firstName: argv['first-name'],
81
- lastName: argv['last-name'],
82
- roles: argv.roles,
83
- teamIds: argv['team-ids']?.map(Number),
84
- maxChats: argv['max-chats'] ?? 0,
85
- };
86
-
87
- console.log(`\nCreating agent ${argv.email} on site ${argv['site-id']}...`);
88
- // Non-2xx (existing email, seat limit reached, site not found) throws via
89
- // messagingRequest and is reported by runCommand's own catch -- no separate
90
- // success/error branch needed here, unlike site-provision's payload-level flag.
91
- const result = await messagingPost(`/SupportTools/sites/${argv['site-id']}/agents`, body);
92
-
93
- console.log(`\x1b[32mOK: agent created on site ${argv['site-id']}\x1b[0m`);
94
- console.log(` Email: ${result.user?.email ?? argv.email}`);
95
- console.log(` Roles: ${(result.user?.roles ?? []).join(', ')}`);
96
- if (result.temporaryPassword) console.log(` Temp password: ${result.temporaryPassword}`);
97
- console.log(` ${result.message ?? ''}`);
98
- }),
99
- })
100
- .command({
101
- command: 'set-roles',
102
- describe: 'Set roles (Administrator/Manager/Agent) of an EXISTING user on a site (Velaro staff only) -- makes E2E/QA test logins admin-capable',
103
- builder: (y) => y
104
- .option('site-id', { type: 'number', demandOption: true, describe: 'Target site ID' })
105
- .option('email', { type: 'string', demandOption: true, describe: 'Existing user email' })
106
- .option('roles', { type: 'array', demandOption: true, describe: 'e.g. --roles Administrator' }),
107
- handler: runCommand(async (argv) => {
108
- const r = await messagingPut(`/SupportTools/sites/${argv['site-id']}/agents/roles`, { email: argv.email, roles: argv.roles.map(String) });
109
- console.log(`OK: ${r.email} roles ${r.before || '(none)'} -> ${r.roles.join(', ')}`);
110
- }),
111
- })
112
61
  .command({
113
62
  command: 'set-status',
114
63
  describe: 'Set an agent\'s availability status (admin only)',
@@ -138,7 +87,7 @@ export const agentCommand = {
138
87
  .option('end', { type: 'string', describe: 'End date, e.g. 2026-06-15 (default: now)' })
139
88
  .option('reason', { type: 'string', describe: 'Filter: NoAgentsOnline | AgentsNotAvailable | AgentsBusy | OutOfSchedule | TimedOut | Abandoned | Rejected' })
140
89
  .option('team-id', { type: 'number', describe: 'Filter by team ID' })
141
- .option('site-id', { type: 'number', describe: 'SuperAdmin only — run for a specific customer site' }),
90
+ .option('site-id', { type: 'number', describe: 'Elevated access only — run for a specific customer site' }),
142
91
  handler: runCommand(async (argv) => {
143
92
  const qs = new URLSearchParams();
144
93
  if (argv.start) qs.set('start', argv.start);
@@ -187,7 +136,7 @@ export const agentCommand = {
187
136
  .option('start', { type: 'string', describe: 'Start date, e.g. 2026-06-01 (default: 7 days ago)' })
188
137
  .option('end', { type: 'string', describe: 'End date, e.g. 2026-06-15 (default: now). Max 31 days.' })
189
138
  .option('agent-id', { type: 'number', describe: 'Filter to a specific agent (WorkspaceUser ID)' })
190
- .option('site-id', { type: 'number', describe: 'SuperAdmin only — run for a specific customer site' }),
139
+ .option('site-id', { type: 'number', describe: 'Elevated access only — run for a specific customer site' }),
191
140
  handler: runCommand(async (argv) => {
192
141
  const qs = new URLSearchParams();
193
142
  if (argv.start) qs.set('start', argv.start);
@@ -242,7 +191,7 @@ export const agentCommand = {
242
191
  builder: (y) => y
243
192
  .option('start', { type: 'string', describe: 'Start date, e.g. 2026-06-10 (max 7 days before end)' })
244
193
  .option('end', { type: 'string', describe: 'End date, e.g. 2026-06-17 (default: today)' })
245
- .option('site-id', { type: 'number', describe: 'SuperAdmin only — run for a specific customer site' }),
194
+ .option('site-id', { type: 'number', describe: 'Elevated access only — run for a specific customer site' }),
246
195
  handler: runCommand(async (argv) => {
247
196
  const qs = new URLSearchParams();
248
197
  if (argv.start) qs.set('start', argv.start);
@@ -1,9 +1,12 @@
1
1
  import fs from 'node:fs';
2
2
  import { messagingGet, messagingPost, messagingPut } from '../api.js';
3
3
  import { runCommand } from '../run.js';
4
+ import { loadStaff } from '../staff-optional.js';
5
+
6
+ const staffAiConfig = await loadStaff('commands/ai-config-staff.js');
4
7
 
5
8
  // messagingGet() authenticates with the caller's own user JWT, scoped to the caller's site — fine
6
- // for the subcommands above. staff-list below hits SupportTools/sites/{siteId}/ai-configs instead,
9
+ // for the subcommands above. the staff-only list (unpublished staff build) uses a staff route instead,
7
10
  // which is gated by staff auth (Velaro staff JWT or the internal vel_live_* service key), never the
8
11
  // caller's site JWT, so it can read ANY site's AI config without needing that site's own login.
9
12
 
@@ -14,13 +17,12 @@ export const aiConfigCommand = {
14
17
  command: 'ai-config <subcommand>',
15
18
  describe: 'Manage AI configurations (bot prompts, channel overrides)',
16
19
  builder: (yargs) =>
17
- yargs
20
+ (staffAiConfig ? staffAiConfig.addAiConfigStaffCommands(yargs) : yargs)
18
21
  .command(aiConfigListCommand)
19
22
  .command(aiConfigGetCommand)
20
23
  .command(aiConfigCreateCommand)
21
24
  .command(aiConfigSetChannelOverrideCommand)
22
25
  .command(aiConfigListChannelOverridesCommand)
23
- .command(aiConfigStaffListCommand)
24
26
  .command(aiConfigResolvedModelCommand)
25
27
  .command(aiConfigModelCallsCommand)
26
28
  .demandCommand(1, 'Specify a subcommand: list, get, create, set-channel-override, list-channel-overrides, staff-list, resolved-model, model-calls'),
@@ -144,34 +146,6 @@ const aiConfigListChannelOverridesCommand = {
144
146
  }),
145
147
  };
146
148
 
147
- // ── staff-list (SupportTools, service-authed, any site) ───────────────────────
148
-
149
- const aiConfigStaffListCommand = {
150
- command: 'staff-list <siteId>',
151
- describe: 'Velaro staff only — read AI configurations for ANY site by ID (including IndexDocumentCount), without needing that site\'s own user JWT.',
152
- builder: (y) => y.positional('siteId', { type: 'number', describe: 'Site ID to inspect' }),
153
- handler: runCommand(async (argv) => {
154
- const data = await get(`/SupportTools/sites/${argv.siteId}/ai-configs`);
155
- const rows = data?.configs ?? [];
156
- if (!rows.length) { console.log(`No AI configurations found for site ${argv.siteId}.`); return; }
157
-
158
- const idW = Math.max(...rows.map(c => String(c.id).length + 2));
159
- const nameW = Math.max('name'.length, ...rows.map(c => (c.name ?? '').length));
160
-
161
- console.log(`\nSite ${argv.siteId} — ${rows.length} AI configuration(s)\n`);
162
- console.log(`${'id'.padStart(idW)} ${'name'.padEnd(nameW)} status model index docs`);
163
- console.log(`${'-'.repeat(idW)} ${'-'.repeat(nameW)} ------- ------------ ------------------- ----`);
164
- for (const c of rows) {
165
- const id = `[${c.id}]`.padStart(idW);
166
- const name = (c.name ?? '').padEnd(nameW);
167
- const stat = (c.status ?? '—').padEnd(7);
168
- const model = (c.aiModel ?? '—').padEnd(12);
169
- const index = (c.indexName ?? '—').padEnd(19);
170
- console.log(`${id} ${name} ${stat} ${model} ${index} ${c.indexDocumentCount ?? 0}`);
171
- }
172
- }),
173
- };
174
-
175
149
  const aiConfigSetChannelOverrideCommand = {
176
150
  command: 'set-channel-override <id>',
177
151
  describe: 'Add or replace a channel override on an AI configuration',
@@ -213,11 +187,11 @@ const aiConfigSetReplyFormatCommand = {
213
187
 
214
188
  const aiConfigResolvedModelCommand = {
215
189
  command: 'resolved-model <id>',
216
- describe: 'Show which model an AI configuration runs on (model name is returned to Velaro staff only)',
190
+ describe: 'Show which model an AI configuration runs on (model name is returned to restricted, enforced server-side)',
217
191
  builder: (y) => y.positional('id', { type: 'number', describe: 'AI configuration ID' }),
218
192
  handler: runCommand(async (argv) => {
219
193
  const r = await get(`/AIConfiguration/${argv.id}/resolved-model`);
220
- if (!r?.isStaff) { console.log('Velaro Default (model name is visible to Velaro staff only)'); return; }
194
+ if (!r?.isStaff) { console.log('Velaro Default (model name is visible to restricted, enforced server-side)'); return; }
221
195
  console.log(`resolved: ${r.resolvedModel ?? 'unknown'} ${r.usingDefault ? '(Velaro Default)' : `(explicit: ${r.explicitModel})`}`);
222
196
  }),
223
197
  };
@@ -226,7 +200,7 @@ const aiConfigResolvedModelCommand = {
226
200
 
227
201
  const aiConfigModelCallsCommand = {
228
202
  command: 'model-calls',
229
- describe: 'Velaro staff only: recent AI calls on the current site with the model each call used',
203
+ describe: 'restricted, enforced server-side: recent AI calls on the current site with the model each call used',
230
204
  builder: (y) => y
231
205
  .option('role', { type: 'string', describe: 'AI role filter, e.g. chatbot' })
232
206
  .option('limit', { type: 'number', default: 50 }),
@@ -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
+ };