@velaro/cli 1.4.120 → 1.4.122

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 (68) hide show
  1. package/README.md +0 -19
  2. package/bin/velaro.js +21 -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/index.js +18 -14
  8. package/lib/commands/kb.js +4 -94
  9. package/lib/commands/knowledge.js +2 -2
  10. package/lib/commands/ops-groups.js +0 -13
  11. package/lib/commands/safety.js +1 -1
  12. package/lib/commands/salesforce.js +1 -1
  13. package/lib/commands/sap.js +1 -1
  14. package/lib/commands/schedule-adherence.js +1 -1
  15. package/lib/commands/signature.js +39 -3
  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/signature-policy.js +42 -0
  20. package/lib/signature-policy.test.js +28 -2
  21. package/lib/staff-optional.js +10 -0
  22. package/package.json +2 -2
  23. package/lib/cobrowse-settings.js +0 -90
  24. package/lib/cobrowse-settings.test.js +0 -45
  25. package/lib/commands/activity.js +0 -147
  26. package/lib/commands/acuity.js +0 -66
  27. package/lib/commands/ai-federation.js +0 -55
  28. package/lib/commands/ai-models.js +0 -203
  29. package/lib/commands/ai-spend.js +0 -71
  30. package/lib/commands/avatar.js +0 -253
  31. package/lib/commands/bigcommerce.js +0 -50
  32. package/lib/commands/calendly.js +0 -62
  33. package/lib/commands/cobrowse.js +0 -99
  34. package/lib/commands/coupon-grant.js +0 -192
  35. package/lib/commands/diag-groups.js +0 -108
  36. package/lib/commands/diagnostics.js +0 -298
  37. package/lib/commands/email-inbox.js +0 -110
  38. package/lib/commands/entitlement.js +0 -375
  39. package/lib/commands/image-analysis.js +0 -27
  40. package/lib/commands/logs-insights.js +0 -342
  41. package/lib/commands/logs.js +0 -1248
  42. package/lib/commands/migrate.js +0 -379
  43. package/lib/commands/migration-status.js +0 -66
  44. package/lib/commands/ops.js +0 -266
  45. package/lib/commands/parity-staff-tools.js +0 -205
  46. package/lib/commands/pricing.js +0 -132
  47. package/lib/commands/report-speed.js +0 -112
  48. package/lib/commands/scraper.js +0 -38
  49. package/lib/commands/site-provision.js +0 -68
  50. package/lib/commands/sitesync.js +0 -158
  51. package/lib/commands/skill-usage.js +0 -39
  52. package/lib/commands/staff.js +0 -31
  53. package/lib/commands/status-page.js +0 -95
  54. package/lib/commands/status-sla.js +0 -47
  55. package/lib/commands/subscription.js +0 -102
  56. package/lib/commands/support.js +0 -309
  57. package/lib/commands/tour-policy.js +0 -61
  58. package/lib/commands/triage.js +0 -66
  59. package/lib/entitlement-report-packages.test.js +0 -47
  60. package/lib/log-search.js +0 -252
  61. package/lib/log-search.test.js +0 -374
  62. package/lib/logs-insights.test.js +0 -146
  63. package/lib/messaging-routes.test.js +0 -37
  64. package/lib/report-speed.test.js +0 -26
  65. package/lib/siteUser.js +0 -35
  66. package/lib/siteUser.test.js +0 -45
  67. package/lib/skill-usage.test.js +0 -36
  68. 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,25 +88,13 @@ 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';
128
99
  import { callpresenceCommand } from '../lib/commands/callpresence.js';
129
100
  import { authorityCommand } from '../lib/commands/authority.js';
@@ -141,18 +112,13 @@ import { surveyCommand } from '../lib/commands/survey.js';
141
112
  import { bundleCommand } from '../lib/commands/bundle.js';
142
113
  import { chatWindowCommand } from '../lib/commands/chat-window.js';
143
114
  import { featureDiscoveryCommand } from '../lib/commands/feature-discovery.js';
144
- import { tourPolicyCommand } from '../lib/commands/tour-policy.js';
145
- 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';
146
- import { scraperCommand } from '../lib/commands/scraper.js';
147
115
  import { usageCommand } from '../lib/commands/usage.js';
148
116
  import { campaignsCommand } from '../lib/commands/campaigns.js';
149
117
  import { senderDomainHealthCommand } from '../lib/commands/sender-domain-health.js';
150
118
  import { contactsCommand } from '../lib/commands/contacts.js';
151
119
  import { contactListCommand } from '../lib/commands/contact-list.js';
152
120
  import { recycleBinCommand, aiUsageCommand, siteInfoCommand, billingReceiptsCommand } from '../lib/commands/endpoint-parity.js';
153
- import { adminCommand, appleCommand, forceExpireSiteCommand, backfillCommand, kpiCommand, auditTrailCommand, codeCommand, crmCommand, hangfireCommand } from '../lib/commands/diag-groups.js';
154
- import { aiFollowupsCommand, businessActionCommand, callCommand, conversationCommand, conversionCommand, emailCommand, ivrCommand } from '../lib/commands/ops-groups.js';
155
- import { entitlementGroup } from '../lib/commands/entitlement.js';
121
+ import { aiFollowupsCommand, businessActionCommand, callCommand, conversationCommand, conversionCommand, ivrCommand } from '../lib/commands/ops-groups.js';
156
122
  import { featureDiscoveryGroup } from '../lib/commands/feature-discovery.js';
157
123
  import { billingInsightsGroup } from '../lib/commands/billing-insights.js';
158
124
  import { startUpdateCheck } from '../lib/update-check.js';
@@ -168,7 +134,17 @@ if (!printBannerIfFirstRun() && frontDoor) printBanner({ version: cliVersion });
168
134
 
169
135
  const printUpdateNoticeIfStale = startUpdateCheck();
170
136
 
171
- 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)
172
148
  .scriptName('velaro')
173
149
  .usage('$0 <command> [options]')
174
150
  .command(loginCommand)
@@ -186,18 +162,10 @@ await yargs(hideBin(process.argv))
186
162
  .command(knowledgeCommand)
187
163
  .command(productCommand)
188
164
  .command(mcpKeyCommand)
189
- .command(opsCommand)
190
- .command(cobrowseCommand)
191
165
  .command(deployStateCommand)
192
166
  .command(checkCommand)
193
- .command(logsCommand)
194
- .command(aiModelsCommand)
195
- .command(reportSpeedCommand)
196
167
  .command(siteCommand)
197
- .command(siteProvisionCommand)
198
- .command(siteSyncCommand)
199
168
  .command(statusCommand)
200
- .command(activityCommand)
201
169
  .command(ruleCommand)
202
170
  .command(teamCommand)
203
171
  .command(dynamicsCommand)
@@ -211,13 +179,9 @@ await yargs(hideBin(process.argv))
211
179
  .command(signatureCommand)
212
180
  .command(articleCommand)
213
181
  .command(sharepointCommand)
214
- .command(calendlyCommand)
215
182
  .command(imageCommand)
216
183
  .command(copilotStudioCommand)
217
- .command(acuityCommand)
218
- .command(avatarCommand)
219
184
  .command(applePayPresetCommand)
220
- .command(imageAnalysisCommand)
221
185
  .command(integrationCommand)
222
186
  .command(appointmentsCommand)
223
187
  .command(bookingCommand)
@@ -229,7 +193,6 @@ await yargs(hideBin(process.argv))
229
193
  .command(enterpriseReportsCommand)
230
194
  .command(reportSubscriptionCommand)
231
195
  .command(reportBackfillCommand)
232
- .command({ command: 'staff', desc: 'Velaro staff: cross-site tools (backfill)', builder: staffCommand, handler: () => {} })
233
196
  .command(reportExplainCommand)
234
197
  .command(dbCommand)
235
198
  .command(skillRoutingCommand)
@@ -242,7 +205,6 @@ await yargs(hideBin(process.argv))
242
205
  .command(chatIntelligenceTopicsCommand)
243
206
  .command(csatOverrideUnapproveCommand)
244
207
  .command(focusCommand)
245
- .command(triageCommand)
246
208
  .command(automationDraftCommand)
247
209
  .command(magentoCommand)
248
210
  .command(sapCommand)
@@ -266,9 +228,6 @@ await yargs(hideBin(process.argv))
266
228
  .command(netsuiteCommand)
267
229
  .command(woocommerceCommand)
268
230
  .command(squarespaceCommand)
269
- .command(bigcommerceCommand)
270
- .command(migrateCommand)
271
- .command(migrationStatusCommand)
272
231
  .command(complianceCommand)
273
232
  .command(billingContactsCommand)
274
233
  .command(billingSubscriptionCommand)
@@ -277,25 +236,13 @@ await yargs(hideBin(process.argv))
277
236
  .command(priceIncreaseCommand)
278
237
  .command(billingEmailPreferenceCommand)
279
238
  .command(billingCommand)
280
- .command(couponGrantCommand)
281
239
  .command(signCommand)
282
240
  .command(widgetContainerCommand)
283
241
  .command(inlineWidgetConfigCommand)
284
- .command(pricingGroupCommand)
285
- .command(entitlementGroup)
286
242
  .command({ command: 'billing-agents', desc: 'Run and review the billing agents (staff)', builder: billingAgentsCommand, handler: () => {} })
287
243
  .command({ command: 'package-builder', desc: 'Package graph, drafts, simulation, audit (staff)', builder: packageBuilderCommand, handler: () => {} })
288
- .command({ command: 'subscription', desc: 'Apply/diff SubscriptionPackage packages on a site (superadmin only)', builder: subscriptionCommand, handler: () => {} })
289
- .command(supportGroupCommand)
290
244
  .command(routingCommand)
291
- .command(diagnosticsCommand)
292
- .command(aiSpendCommand)
293
- .command(skillUsageCommand)
294
- .command(aiFederationCommand)
295
- .command(statusPageCommand)
296
245
  .command(statusNotifyCommand)
297
- .command(statusSlaCommand)
298
- .command(emailInboxCommand)
299
246
  .command(callbackCommand)
300
247
  .command(callpresenceCommand)
301
248
  .command(authorityCommand)
@@ -314,23 +261,6 @@ await yargs(hideBin(process.argv))
314
261
  .command(chatWindowCommand)
315
262
  .command(featureDiscoveryGroup)
316
263
  .command(billingInsightsGroup)
317
- .command(scraperGroupCommand)
318
- .command(tourPolicyGroupCommand)
319
- .command(livefluenceCommand)
320
- .command(missedCommand)
321
- .command(serviceCommand)
322
- .command(pageCommand)
323
- .command(uploadedCommand)
324
- .command(msCommand)
325
- .command(outlookCommand)
326
- .command(oauthCommand)
327
- .command(provisionCommand)
328
- .command(sseCommand)
329
- .command(skillCommand)
330
- .command(v10Command)
331
- .command(whatsappCommand)
332
- .command(mobileCommand)
333
- .command(signalrCommand)
334
264
  .command(usageCommand)
335
265
  .command(campaignsCommand)
336
266
  .command(senderDomainHealthCommand)
@@ -340,24 +270,23 @@ await yargs(hideBin(process.argv))
340
270
  .command(aiUsageCommand)
341
271
  .command(siteInfoCommand)
342
272
  .command(billingReceiptsCommand)
343
- .command(adminCommand)
344
- .command(appleCommand)
345
- .command(forceExpireSiteCommand)
346
- .command(backfillCommand)
347
- .command(kpiCommand)
348
- .command(auditTrailCommand)
349
- .command(codeCommand)
350
- .command(crmCommand)
351
- .command(hangfireCommand)
352
273
  .command(aiFollowupsCommand)
353
274
  .command(businessActionCommand)
354
275
  .command(callCommand)
355
276
  .command(conversationCommand)
356
277
  .command(conversionCommand)
357
- .command(emailCommand)
358
278
  .command(ivrCommand)
359
279
  .demandCommand(1, 'Specify a command. Run "velaro --help" for options.')
360
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
+ })
361
290
  .help()
362
291
  .parseAsync();
363
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 }),
@@ -1,9 +1,13 @@
1
1
  import { get, post, getCredentials, messagingGet, messagingPost, messagingPut } from '../api.js';
2
+ import { loadStaff } from '../staff-optional.js';
2
3
 
3
4
  // ── helpers ──────────────────────────────────────────────────────────────────
4
5
 
6
+ const staffIndex = await loadStaff('commands/index-staff.js');
7
+
8
+ // Staff cross-site view is only available when the unpublished staff build is present (the server enforces the real gate).
5
9
  function isVelaroAdmin(creds) {
6
- return creds.siteId === 1032;
10
+ return !!staffIndex?.isStaffSite(creds);
7
11
  }
8
12
 
9
13
  function mb(n) {
@@ -25,7 +29,7 @@ const listCommand = {
25
29
  command: 'list',
26
30
  describe: 'List indexes. Velaro admins see all physical indexes; customers see their virtual indexes + quota.',
27
31
  builder: (y) =>
28
- y.option('site', { type: 'number', describe: 'Site ID (Velaro staff only)' }),
32
+ y.option('site', { type: 'number', describe: 'Site ID (restricted, enforced server-side)' }),
29
33
  handler: async (argv) => {
30
34
  const creds = await getCredentials();
31
35
 
@@ -115,15 +119,15 @@ const listCommand = {
115
119
  },
116
120
  };
117
121
 
118
- // ── site (Velaro staff only) ──────────────────────────────────────────────────
122
+ // ── site (restricted, enforced server-side) ──────────────────────────────────────────────────
119
123
 
120
124
  const siteCommand = {
121
125
  command: 'site <siteId>',
122
- describe: 'Show index breakdown for a specific site (Velaro staff only)',
126
+ describe: 'Show index breakdown for a specific site (restricted, enforced server-side)',
123
127
  handler: async (argv) => {
124
128
  const creds = await getCredentials();
125
129
  if (!isVelaroAdmin(creds)) {
126
- console.error('This command is only available to Velaro staff.');
130
+ console.error('This command is restricted, enforced server-side.');
127
131
  process.exit(1);
128
132
  }
129
133
  const data = await get(`/DatabaseTool/SearchIndexSite?siteId=${argv.siteId}`);
@@ -136,15 +140,15 @@ const siteCommand = {
136
140
  },
137
141
  };
138
142
 
139
- // ── provision (Velaro staff only) ─────────────────────────────────────────────
143
+ // ── provision (restricted, enforced server-side) ─────────────────────────────────────────────
140
144
 
141
145
  const provisionCommand = {
142
146
  command: 'provision <siteId>',
143
- describe: 'Provision a dedicated physical index for a site (Velaro staff only)',
147
+ describe: 'Provision a dedicated physical index for a site (restricted, enforced server-side)',
144
148
  handler: async (argv) => {
145
149
  const creds = await getCredentials();
146
150
  if (!isVelaroAdmin(creds)) {
147
- console.error('This command is only available to Velaro staff.');
151
+ console.error('This command is restricted, enforced server-side.');
148
152
  process.exit(1);
149
153
  }
150
154
  console.log(`Provisioning dedicated index for site ${argv.siteId}...`);
@@ -168,7 +172,7 @@ const reingestCommand = {
168
172
  })
169
173
  .option('site', {
170
174
  type: 'number',
171
- describe: 'Site ID (Velaro staff only)',
175
+ describe: 'Site ID (restricted, enforced server-side)',
172
176
  }),
173
177
  handler: async (argv) => {
174
178
  const creds = await getCredentials();
@@ -213,7 +217,7 @@ const testCommand = {
213
217
  y
214
218
  .positional('query', { type: 'string', describe: 'Search query' })
215
219
  .option('top', { type: 'number', default: 5, describe: 'Number of results to return' })
216
- .option('site', { type: 'number', describe: 'Site ID override (Velaro staff only)' }),
220
+ .option('site', { type: 'number', describe: 'Site ID override (restricted, enforced server-side)' }),
217
221
  handler: async (argv) => {
218
222
  const creds = await getCredentials();
219
223
  const siteParam = isVelaroAdmin(creds) && argv.site ? `&siteId=${argv.site}` : '';
@@ -238,13 +242,13 @@ const testCommand = {
238
242
 
239
243
  // ── export ────────────────────────────────────────────────────────────────────
240
244
 
241
- // -- create (Velaro staff only) -------------------------------------------------
245
+ // -- create (restricted, enforced server-side) -------------------------------------------------
242
246
  // POST KnowledgeSetup/Staff/{siteId}/create-index on velaro-messaging. Idempotent: an existing
243
247
  // index with the same (sanitized) name is returned unchanged.
244
248
 
245
249
  const createCommand = {
246
250
  command: 'create',
247
- describe: 'Create a named virtual index on any site (Velaro staff only; idempotent)',
251
+ describe: 'Create a named virtual index on any site (restricted, enforced server-side; idempotent)',
248
252
  builder: (y) =>
249
253
  y
250
254
  .option('site', { type: 'number', demandOption: true, describe: 'Target site ID' })
@@ -266,13 +270,13 @@ Index ready on site ${argv.site}: ${idx.name} (id: ${idx.id}, purpose: ${idx.pur
266
270
  },
267
271
  };
268
272
 
269
- // -- profile (Velaro staff only) --------------------------------------------------
273
+ // -- profile (restricted, enforced server-side) --------------------------------------------------
270
274
  // PUT KnowledgeSetup/Staff/{siteId}/index-profile on velaro-messaging. Apply-if-present: only the
271
275
  // flags you pass are changed. The index is addressed by name (the endpoint looks up siteId+name).
272
276
 
273
277
  const profileCommand = {
274
278
  command: 'profile',
275
- describe: 'Set the ingestion profile of one index on any site (Velaro staff only; only passed flags change)',
279
+ describe: 'Set the ingestion profile of one index on any site (restricted, enforced server-side; only passed flags change)',
276
280
  builder: (y) =>
277
281
  y
278
282
  .option('site', { type: 'number', demandOption: true, describe: 'Target site ID' })