@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
@@ -1,112 +0,0 @@
1
- import { getCredentials } from '../api.js';
2
- import { readConfig, ENVS } from '../config.js';
3
-
4
- // velaro report-speed: staff control of report/export speed levels (global default + per-customer override).
5
- // Routes live in velaro-messaging (superadmin/report-speed). Docs: docs/architecture/report-speed-levels.md
6
-
7
- const RESET = '\x1b[0m';
8
- const DIM = '\x1b[2m';
9
- const BOLD = '\x1b[1m';
10
- const GREEN = '\x1b[32m';
11
-
12
- async function getMsgBase(argv) {
13
- const cfg = readConfig();
14
- const env = argv.env || cfg.env || 'staging';
15
- return cfg.envs?.[env]?.messagingApiBase ?? ENVS[env]?.messagingApiBase
16
- ?? 'https://velaro-messaging-api-staging.azurewebsites.net';
17
- }
18
-
19
- async function call(argv, path, opts = {}) {
20
- const creds = await getCredentials();
21
- if (creds.siteId !== 1032) {
22
- console.error('velaro report-speed is only available to Velaro staff (site 1032).');
23
- process.exit(1);
24
- }
25
- const msgBase = await getMsgBase(argv);
26
- const res = await fetch(`${msgBase}/superadmin/report-speed/${path}`, {
27
- method: opts.method ?? 'GET',
28
- headers: {
29
- Authorization: `Bearer ${creds.velaroToken}`,
30
- 'X-Internal-SiteId': String(creds.siteId),
31
- ...(opts.body ? { 'Content-Type': 'application/json' } : {}),
32
- },
33
- body: opts.body ? JSON.stringify(opts.body) : undefined,
34
- signal: AbortSignal.timeout(20000),
35
- });
36
- if (!res.ok) {
37
- const body = await res.text().catch(() => '');
38
- console.error(`HTTP ${res.status}: ${body}`);
39
- process.exit(1);
40
- }
41
- return res.json();
42
- }
43
-
44
- export function formatReportSpeed(data) {
45
- const e = data.effective;
46
- const rate = e.ruPerSecond > 0 ? `${e.ruPerSecond} RU/s` : 'not paced';
47
- const where = data.siteId
48
- ? (data.inherited ? `inherited (${data.source})` : `overridden by ${data.overrideBy ?? 'staff'}`)
49
- : 'global default';
50
- const lines = [
51
- `${BOLD}${data.siteId ? `Site ${data.siteId}` : 'Global'}${RESET}: ${e.name} ${DIM}(${where})${RESET}`,
52
- `${DIM}Limits:${RESET} ${e.maxConcurrentJobs} job(s) at once, ${rate}, burst ${e.burstSeconds}s, page ${e.pageSize}, ${e.interPageDelayMs} ms between pages`,
53
- `${DIM}Global default:${RESET} ${data.globalDefault}`,
54
- `${DIM}Levels:${RESET} ${data.levels.map(l => l.key).join(', ')}`,
55
- ];
56
- return lines.join('\n');
57
- }
58
-
59
- async function getLevels(argv) {
60
- const data = argv.site ? await call(argv, `site/${argv.site}`) : await call(argv, 'levels');
61
- console.log(`\n${formatReportSpeed(data)}\n`);
62
- }
63
-
64
- async function setSite(argv) {
65
- const level = argv.clear ? null : argv.level;
66
- if (!argv.clear && !level) {
67
- console.error('Give --level <economy|standard|fast|unlimited> or --clear.');
68
- process.exit(1);
69
- }
70
- const data = await call(argv, `site/${argv.site}`, { method: 'PUT', body: { level, reason: argv.reason ?? null } });
71
- console.log(`\n${GREEN}OK${RESET} ${formatReportSpeed(data)}\n`);
72
- }
73
-
74
- async function setDefault(argv) {
75
- const data = await call(argv, 'default', { method: 'PUT', body: { level: argv.level, reason: argv.reason ?? null } });
76
- console.log(`\n${GREEN}OK${RESET} ${formatReportSpeed(data)}\n`);
77
- }
78
-
79
- export const reportSpeedCommand = {
80
- command: 'report-speed <subcommand>',
81
- describe: 'Report and export speed levels: global default and per-customer override (Velaro staff only)',
82
- builder: yargs => yargs
83
- .command({
84
- command: 'get',
85
- describe: 'Show the levels table and global default, or one customer\'s effective level (--site)',
86
- builder: y => y
87
- .option('site', { describe: 'Customer site ID (omit for the global view)', type: 'number' })
88
- .option('env', { describe: 'staging or prod', type: 'string' }),
89
- handler: getLevels,
90
- })
91
- .command({
92
- command: 'set',
93
- describe: 'Set or clear (--clear) one customer\'s override, e.g. velaro report-speed set --site 1234 --level economy --reason "2-year reports"',
94
- builder: y => y
95
- .option('site', { describe: 'Customer site ID', type: 'number', demandOption: true })
96
- .option('level', { describe: 'economy, standard, fast or unlimited', type: 'string', choices: ['economy', 'standard', 'fast', 'unlimited'] })
97
- .option('clear', { describe: 'Remove the override (inherit the global default)', type: 'boolean', default: false })
98
- .option('reason', { describe: 'Saved in the audit trail', type: 'string' })
99
- .option('env', { describe: 'staging or prod', type: 'string' }),
100
- handler: setSite,
101
- })
102
- .command({
103
- command: 'default',
104
- describe: 'Set the GLOBAL default level (economy, standard or fast; unlimited is internal-only)',
105
- builder: y => y
106
- .option('level', { describe: 'economy, standard or fast', type: 'string', choices: ['economy', 'standard', 'fast'], demandOption: true })
107
- .option('reason', { describe: 'Saved in the audit trail', type: 'string' })
108
- .option('env', { describe: 'staging or prod', type: 'string' }),
109
- handler: setDefault,
110
- })
111
- .demandCommand(1, 'Specify a subcommand: get, set, or default'),
112
- };
@@ -1,38 +0,0 @@
1
- // velaro scraper usage --site <id> — Velaro staff only. Scraper / upload / chunk consumption for
2
- // any site (GET ScraperJobs/StaffUsage/{siteId}; IsVelaroAdminAsync + super-admin enforced
3
- // server-side). The site is always explicit in the route, never derived from the caller's auth.
4
- import { request } from '../api.js';
5
-
6
- const n = (v) => (v ?? 0).toLocaleString('en-US');
7
-
8
- async function usage(argv) {
9
- const u = await request('GET', `ScraperJobs/StaffUsage/${encodeURIComponent(argv.site)}`);
10
- if (argv.json) { console.log(JSON.stringify(u, null, 2)); return; }
11
- console.log(`\nScraper usage, site ${u.siteId}${u.isTrial ? ' (trial)' : ''}`);
12
- console.log(` Crawl pages this month: ${n(u.pagesThisMonthEffective)} / ${n(u.pagesBudgetPerMonth)} (admin ledger ${n(u.pagesThisMonthAdminLedger)}, messaging ledger ${u.pagesThisMonthMessagingLedger ?? 'n/a'})`);
13
- console.log(` Upload pages this month: ${n(u.uploadPagesThisMonth)} / ${n(u.uploadPagesBudgetPerMonth)}`);
14
- console.log(` OCR pages this month: ${n(u.ocrPagesThisMonth)}`);
15
- console.log(` Jobs today: ${n(u.jobsToday)} / ${n(u.maxJobsPerDay)}`);
16
- console.log(` Chunks indexed: ${n(u.chunksIndexed)} / ${n(u.maxIndexedChunkTotal)}`);
17
- for (const i of u.chunksByIndex ?? []) console.log(` ${i.indexName}: ${n(i.chunks)} chunks, ${n(i.documents)} docs`);
18
- for (const note of u.notes ?? []) console.log(` Note: ${note}`);
19
- }
20
-
21
- async function verifyToken(argv) {
22
- const t = await request('GET', 'ScraperJobs/VerifyToken');
23
- if (argv.json) { console.log(JSON.stringify(t, null, 2)); return; }
24
- console.log('\nScraper verification (give this to your web host to allowlist our crawler)');
25
- console.log(` Header: ${t.header_name}: ${t.header_value}`);
26
- console.log(` Scraper IP: ${t.scraper_ip}`);
27
- if (t.instructions) console.log(`\n${t.instructions}`);
28
- }
29
-
30
- export function scraperCommand(yargs) {
31
- return yargs
32
- .command('usage', 'Show scraper/upload/chunk usage for a site (staff only)', (y) => y
33
- .option('site', { type: 'number', demandOption: true, describe: 'Target site id' })
34
- .option('json', { type: 'boolean', describe: 'Print raw JSON' }), (a) => usage(a))
35
- .command('verify-token', 'Show your scraper verification header + IP for web-host allowlisting', (y) => y
36
- .option('json', { type: 'boolean', describe: 'Print raw JSON' }), (a) => verifyToken(a))
37
- .demandCommand(1, 'Specify a subcommand: usage, verify-token');
38
- }
@@ -1,68 +0,0 @@
1
- // velaro site-provision: staff-only site provisioning, including cross-environment
2
- // parity provisioning (forcing a specific SiteId to match another environment).
3
- import { messagingPost, getCredentials } from '../api.js';
4
- import { runCommand } from '../run.js';
5
-
6
- function isVelaroAdmin(creds) {
7
- return creds.siteId === 1032;
8
- }
9
-
10
- export const siteProvisionCommand = {
11
- command: 'site-provision',
12
- describe: 'Provision a new Velaro site (Velaro staff only)',
13
- builder: (y) =>
14
- y
15
- .option('company', { type: 'string', demandOption: true, describe: 'Company name' })
16
- .option('admin-email', { type: 'string', demandOption: true, describe: 'Admin user email' })
17
- .option('admin-first-name', { type: 'string', describe: 'Admin first name' })
18
- .option('admin-last-name', { type: 'string', describe: 'Admin last name' })
19
- .option('tier', { type: 'string', default: 'Starter', describe: 'Starter, Professional, Business, Enterprise, or Trial' })
20
- .option('site-id', { type: 'number', describe: 'Force a specific SiteId (>= 100000), used for cross-environment parity' })
21
- .option('package-id', { type: 'number', describe: 'SubscriptionPackage Id to provision from' })
22
- .option('package-version-id', { type: 'number', describe: 'Specific PackageVersion Id (defaults to latest published for package-id)' })
23
- .option('all-features-on', { type: 'boolean', default: false, describe: 'Everything ON subscription, internal/demo use only' })
24
- .option('trial', { type: 'boolean', default: false, describe: 'Provision as a trial' })
25
- .option('trial-days', { type: 'number', default: 7 })
26
- .option('is-velaro-internal-site', { type: 'boolean', describe: 'Mark as a Velaro-internal site' })
27
- .option('has-demo-data', { type: 'boolean', describe: 'Mark as having demo data' })
28
- .option('billing-source', { type: 'string', describe: 'e.g. "direct"' }),
29
- handler: runCommand(async (argv) => {
30
- const creds = await getCredentials();
31
- if (!isVelaroAdmin(creds)) {
32
- console.error('This command is only available to Velaro staff.');
33
- process.exit(1);
34
- }
35
-
36
- const body = {
37
- companyName: argv.company,
38
- adminEmail: argv['admin-email'],
39
- adminFirstName: argv['admin-first-name'],
40
- adminLastName: argv['admin-last-name'],
41
- subscriptionTier: argv.tier,
42
- explicitSiteId: argv['site-id'],
43
- packageId: argv['package-id'],
44
- packageVersionId: argv['package-version-id'],
45
- allFeaturesOn: argv['all-features-on'],
46
- isTrial: argv.trial,
47
- trialDurationDays: argv['trial-days'],
48
- isVelaroInternalSite: argv['is-velaro-internal-site'],
49
- hasDemoData: argv['has-demo-data'],
50
- billingSource: argv['billing-source'],
51
- };
52
-
53
- console.log(`\nProvisioning site${argv['site-id'] ? ` ${argv['site-id']}` : ''} for "${argv.company}" on ${creds.env}...`);
54
- const result = await messagingPost('/SuperAdmin/ProvisionSite', body);
55
-
56
- if (!result.success) {
57
- console.error(`\x1b[31mFAILED: ${result.error}\x1b[0m`);
58
- if (result.existingSiteId) console.error(` Existing site: ${result.existingSiteId}`);
59
- process.exit(1);
60
- }
61
-
62
- console.log(`\x1b[32mOK: site ${result.siteId} provisioned\x1b[0m`);
63
- console.log(` Company: ${result.companyName}`);
64
- console.log(` Admin: ${result.adminEmail}`);
65
- console.log(` Team: ${result.defaultTeamId}`);
66
- if (result.temporaryPassword) console.log(` Temp password: ${result.temporaryPassword}`);
67
- }),
68
- };
@@ -1,158 +0,0 @@
1
- // velaro sitesync: copies AI configs, bot profiles, workflows, deployments, and site
2
- // settings from a source site to a target site (Velaro staff only). The blob-push/blob-import
3
- // pair is the cross-environment path (shared blob storage between staging and prod), so a
4
- // bundle exported on one environment can be applied on another without direct cross-DB access.
5
- import { get, post, getCredentials } from '../api.js';
6
- import { runCommand } from '../run.js';
7
-
8
- function isVelaroAdmin(creds) {
9
- return creds.siteId === 1032;
10
- }
11
-
12
- function requireStaff(creds) {
13
- if (!isVelaroAdmin(creds)) {
14
- console.error('This command is only available to Velaro staff.');
15
- process.exit(1);
16
- }
17
- }
18
-
19
- function printResult(result) {
20
- if (result.errors?.length) {
21
- console.log('\x1b[31mErrors:\x1b[0m');
22
- for (const e of result.errors) console.log(` ${e}`);
23
- }
24
- if (result.warnings?.length) {
25
- console.log('\x1b[33mWarnings:\x1b[0m');
26
- for (const w of result.warnings) console.log(` ${w}`);
27
- }
28
- if (result.plan?.length) {
29
- console.log(`\nPlan (${result.isDryRun ? 'dry run' : 'applied'}):`);
30
- for (const item of result.plan) {
31
- console.log(` [${item.action}] ${item.resource}: ${item.name}${item.note ? ` (${item.note})` : ''}`);
32
- }
33
- }
34
- console.log(`\nApplied: ${result.applied?.length ?? 0} Skipped: ${result.skipped?.length ?? 0} Errors: ${result.errors?.length ?? 0}`);
35
- console.log(result.success ? '\x1b[32mSuccess\x1b[0m' : '\x1b[31mCompleted with errors\x1b[0m');
36
- }
37
-
38
- const previewCommand = {
39
- command: 'preview',
40
- describe: 'Dry-run preview of a site sync, no writes',
41
- builder: (y) =>
42
- y
43
- .option('source', { type: 'number', demandOption: true, describe: 'Source site ID' })
44
- .option('target', { type: 'number', demandOption: true, describe: 'Target site ID' })
45
- .option('conflict-mode', { type: 'string', default: 'skip', choices: ['skip', 'overwrite', 'rename'] }),
46
- handler: runCommand(async (argv) => {
47
- const creds = await getCredentials();
48
- requireStaff(creds);
49
- const result = await get(`/SiteSync/preview?sourceSiteId=${argv.source}&targetSiteId=${argv.target}&conflictMode=${argv['conflict-mode']}`);
50
- printResult(result);
51
- }),
52
- };
53
-
54
- const blobPushCommand = {
55
- command: 'blob-push',
56
- describe: 'Export a site config bundle and push it to shared blob storage (readable from any environment)',
57
- builder: (y) =>
58
- y
59
- .option('source', { type: 'number', demandOption: true, describe: 'Source site ID' })
60
- .option('label', { type: 'string', describe: 'Label for this bundle' }),
61
- handler: runCommand(async (argv) => {
62
- const creds = await getCredentials();
63
- requireStaff(creds);
64
- const result = await post('/SiteSync/blob/push', { sourceSiteId: argv.source, label: argv.label });
65
- if (!result.success) {
66
- console.error(`\x1b[31mFAILED: ${result.error}\x1b[0m`);
67
- process.exit(1);
68
- }
69
- console.log(`\x1b[32mOK: pushed\x1b[0m`);
70
- console.log(` Blob key: ${result.blobKey}`);
71
- console.log(`\nOn the target environment, run:`);
72
- console.log(` velaro env <target-env>`);
73
- console.log(` velaro sitesync blob-import --blob-key ${result.blobKey} --target <targetSiteId> --dry-run`);
74
- }),
75
- };
76
-
77
- const blobListCommand = {
78
- command: 'blob-list',
79
- describe: 'List bundles currently in shared blob storage, newest first',
80
- handler: runCommand(async () => {
81
- const creds = await getCredentials();
82
- requireStaff(creds);
83
- const entries = await get('/SiteSync/blob/list');
84
- if (!entries?.length) {
85
- console.log('No bundles in blob storage.');
86
- return;
87
- }
88
- for (const e of entries) {
89
- console.log(`${e.blobKey}`);
90
- console.log(` label: ${e.label ?? '(none)'} source site: ${e.sourceSiteId ?? '?'} pushed by: ${e.pushedBy ?? 'unknown'} at: ${e.exportedAt ?? '?'}`);
91
- }
92
- }),
93
- };
94
-
95
- const blobImportCommand = {
96
- command: 'blob-import',
97
- describe: 'Pull a bundle from blob by key and apply (or preview) it to a target site',
98
- builder: (y) =>
99
- y
100
- .option('blob-key', { type: 'string', demandOption: true })
101
- .option('target', { type: 'number', demandOption: true, describe: 'Target site ID' })
102
- .option('conflict-mode', { type: 'string', default: 'skip', choices: ['skip', 'overwrite', 'rename'] })
103
- .option('dry-run', { type: 'boolean', default: false }),
104
- handler: runCommand(async (argv) => {
105
- const creds = await getCredentials();
106
- requireStaff(creds);
107
- const result = await post('/SiteSync/blob/import', {
108
- blobKey: argv['blob-key'],
109
- targetSiteId: argv.target,
110
- conflictMode: argv['conflict-mode'],
111
- dryRun: argv['dry-run'],
112
- });
113
- printResult(result);
114
- if (argv['dry-run'] && result.success) {
115
- console.log(`\nRe-run without --dry-run to apply.`);
116
- }
117
- }),
118
- };
119
-
120
- const applyCommand = {
121
- command: 'apply',
122
- describe: 'Export a bundle from a source site (same database) and apply it directly to a target site',
123
- builder: (y) =>
124
- y
125
- .option('source', { type: 'number', demandOption: true, describe: 'Source site ID' })
126
- .option('target', { type: 'number', demandOption: true, describe: 'Target site ID' })
127
- .option('conflict-mode', { type: 'string', default: 'skip', choices: ['skip', 'overwrite', 'rename'] })
128
- .option('dry-run', { type: 'boolean', default: false }),
129
- handler: runCommand(async (argv) => {
130
- const creds = await getCredentials();
131
- requireStaff(creds);
132
- const bundle = await get(`/SiteSync/export?sourceSiteId=${argv.source}`);
133
- const result = await post('/SiteSync/apply', {
134
- targetSiteId: argv.target,
135
- conflictMode: argv['conflict-mode'],
136
- dryRun: argv['dry-run'],
137
- bundle,
138
- });
139
- printResult(result);
140
- if (argv['dry-run'] && result.success) {
141
- console.log(`\nRe-run without --dry-run to apply.`);
142
- }
143
- }),
144
- };
145
-
146
- export const siteSyncCommand = {
147
- command: 'sitesync <subcommand>',
148
- describe: 'Copy AI configs, bot profiles, workflows, deployments, and site settings between sites (Velaro staff only)',
149
- builder: (yargs) =>
150
- yargs
151
- .command(previewCommand)
152
- .command(applyCommand)
153
- .command(blobPushCommand)
154
- .command(blobListCommand)
155
- .command(blobImportCommand)
156
- .demandCommand(1, 'Specify a subcommand: preview, apply, blob-push, blob-list, blob-import'),
157
- handler: () => {},
158
- };
@@ -1,39 +0,0 @@
1
- import { messagingGet } from '../api.js';
2
- import { runCommand } from '../run.js';
3
-
4
- const usd = (n) => `$${Number(n ?? 0).toFixed(2)}`;
5
-
6
- // Pure formatter so the output shape is unit-testable without a network call.
7
- export function formatSkillUsage(r) {
8
- const lines = [];
9
- lines.push(`Site ${r.siteId}, ${r.month}${r.isTrial ? ' (trial)' : ''}, overage: ${r.overageBehavior}`);
10
- lines.push('');
11
- lines.push('Billable usage (same numbers as the customer Billing page):');
12
- for (const u of r.usage ?? []) {
13
- const limit = u.unlimited ? 'unlimited' : u.limit.toLocaleString();
14
- lines.push(` ${u.name.padEnd(24)} ${String(u.used.toLocaleString()).padStart(9)} / ${limit.padStart(9)} ${u.unlimited ? '' : `${u.percent}%`.padStart(5)} gate: ${u.mode ?? 'n/a'}`);
15
- }
16
- lines.push('');
17
- lines.push('Calls by surface (staff, copilot and composite calls are never billed to the customer):');
18
- const surfaces = r.callsBySurface ?? [];
19
- if (!surfaces.length) lines.push(' (none recorded)');
20
- for (const s of surfaces) lines.push(` ${String(s.surface).padEnd(20)} ${s.calls.toLocaleString()}`);
21
- lines.push('');
22
- lines.push('LLM cost this month by key source (BYOK removes this cost only; skill usage above still counts):');
23
- const llm = r.llmCostThisMonth ?? [];
24
- if (!llm.length) lines.push(' (none logged)');
25
- for (const l of llm) lines.push(` ${String(l.keySource ?? 'unknown').padEnd(12)} ${usd(l.costUsd)} / ${l.calls} calls`);
26
- return lines.join('\n');
27
- }
28
-
29
- export const skillUsageCommand = {
30
- command: 'skill-usage <siteId>',
31
- describe: 'Per-customer skill/integration usage vs plan limits, by surface, with LLM cost split (Velaro staff only)',
32
- builder: (y) => y
33
- .positional('siteId', { type: 'number', describe: 'Target site ID' })
34
- .option('json', { type: 'boolean', default: false }),
35
- handler: runCommand(async (argv) => {
36
- const r = await messagingGet(`/SupportTools/sites/${argv.siteId}/skill-usage`);
37
- console.log(argv.json ? JSON.stringify(r, null, 2) : formatSkillUsage(r));
38
- }),
39
- };
@@ -1,31 +0,0 @@
1
- // velaro staff backfill --site <id> --type csat --from --to [--apply] -- Velaro staff only.
2
- // Backend: messaging GET SuperAdmin/backfill-types, POST SuperAdmin/sites/{siteId}/backfill.
3
- // Site is always explicit in the route, never derived from the caller's auth.
4
- import { messagingGet, messagingPost } from '../api.js';
5
-
6
- async function run(argv) {
7
- if (argv.list) {
8
- const t = await messagingGet('/SuperAdmin/backfill-types');
9
- if (argv.json) { console.log(JSON.stringify(t, null, 2)); return; }
10
- for (const x of t) console.log(`${x.type}: ${x.title} - ${x.description}`);
11
- return;
12
- }
13
- if (!argv.site || !argv.type || !argv.from || !argv.to) throw new Error('--site, --type, --from and --to are required (or use --list).');
14
- const r = await messagingPost(`/SuperAdmin/sites/${encodeURIComponent(argv.site)}/backfill`, { type: argv.type, from: argv.from, to: argv.to, apply: !!argv.apply });
15
- if (argv.json) { console.log(JSON.stringify(r, null, 2)); return; }
16
- console.log(argv.apply ? `\nBackfill APPLIED for site ${argv.site}` : `\nBackfill PREVIEW for site ${argv.site} (nothing written; add --apply)`);
17
- console.log(JSON.stringify(r, null, 2));
18
- }
19
-
20
- export function staffCommand(yargs) {
21
- return yargs
22
- .command('backfill', 'Preview/apply a report-data backfill for any site (staff only)', (y) => y
23
- .option('site', { type: 'number', describe: 'Target site id' })
24
- .option('type', { type: 'string', describe: 'Backfill type, e.g. csat' })
25
- .option('from', { type: 'string', describe: 'yyyy-MM-dd' })
26
- .option('to', { type: 'string', describe: 'yyyy-MM-dd' })
27
- .option('apply', { type: 'boolean', default: false, describe: 'Write (default preview)' })
28
- .option('list', { type: 'boolean', default: false, describe: 'List backfill types' })
29
- .option('json', { type: 'boolean', describe: 'Raw JSON' }), (a) => run(a).catch(e => { console.error(e.message); process.exit(1); }))
30
- .demandCommand(1, 'Specify a subcommand: backfill');
31
- }
@@ -1,95 +0,0 @@
1
- import { messagingRequest } from '../api.js';
2
-
3
- const COMPONENTS = 'Messaging, Voice & Calls, AI Assistant, Database, API, Integrations, Email Campaigns, Velaro Sign, Velaro Forms, Agent Console, Core API, Chat Engagement';
4
- const TOKENS = 'AffectedServices is a comma-separated list of component names (' + COMPONENTS + ') plus optional uptime tokens: "counts-uptime" forces the incident to count against uptime, "no-uptime-impact" forces it not to. Default: only a core chat outage counts.';
5
-
6
- const listCommand = {
7
- command: 'list',
8
- describe: 'List status incidents (SuperAdmin, velaro-messaging GET /superadmin/status-incidents)',
9
- builder: (y) => y.option('filter', { type: 'string', default: 'active', choices: ['active', 'resolved', 'all'] }).option('json', { type: 'boolean', default: false }),
10
- handler: async (argv) => {
11
- const rows = await messagingRequest('GET', `/superadmin/status-incidents?filter=${argv.filter}`);
12
- if (argv.json) { console.log(JSON.stringify(rows, null, 2)); return; }
13
- for (const r of rows ?? []) console.log(`#${r.id} ${r.status} ${r.incidentType}/${r.severity} ${r.title} [${r.affectedServices ?? ''}]`);
14
- },
15
- };
16
-
17
- const createCommand = {
18
- command: 'create',
19
- describe: 'Create a status incident. ' + TOKENS,
20
- builder: (y) => y
21
- .option('title', { type: 'string', demandOption: true })
22
- .option('description', { type: 'string', default: '' })
23
- .option('status', { type: 'string', default: 'Investigating', describe: 'Investigating, Identified, Monitoring, Resolved' })
24
- .option('type', { type: 'string', default: 'Incident', describe: 'Incident or Maintenance' })
25
- .option('severity', { type: 'string', default: 'Minor', describe: 'Minor or Major' })
26
- .option('services', { type: 'string', default: '', describe: 'AffectedServices CSV. ' + TOKENS })
27
- .option('regions', { type: 'string', default: '' })
28
- .option('exclude-from-uptime', { type: 'boolean', default: false })
29
- .option('hidden', { type: 'boolean', default: false, describe: 'Hide from the public page' }),
30
- handler: async (argv) => {
31
- const r = await messagingRequest('POST', '/superadmin/status-incidents', {
32
- title: argv.title, description: argv.description, status: argv.status, incidentType: argv.type, severity: argv.severity,
33
- affectedServices: argv.services, affectedRegions: argv.regions, excludeFromUptime: argv.excludeFromUptime, isVisibleToCustomers: !argv.hidden,
34
- });
35
- console.log(`Created incident #${r.id}: ${r.title}`);
36
- },
37
- };
38
-
39
- const updateCommand = {
40
- command: 'update <id>',
41
- describe: 'Update a status incident (pass every field you want kept). ' + TOKENS,
42
- builder: (y) => y
43
- .positional('id', { type: 'number' })
44
- .option('title', { type: 'string' }).option('description', { type: 'string' })
45
- .option('status', { type: 'string' }).option('type', { type: 'string' }).option('severity', { type: 'string' })
46
- .option('services', { type: 'string', describe: 'AffectedServices CSV. ' + TOKENS })
47
- .option('regions', { type: 'string' })
48
- .option('end-time', { type: 'string', describe: 'ISO timestamp the incident ended' })
49
- .option('exclude-from-uptime', { type: 'boolean' })
50
- .option('hidden', { type: 'boolean' }),
51
- handler: async (argv) => {
52
- const body = {
53
- title: argv.title, description: argv.description, status: argv.status, incidentType: argv.type, severity: argv.severity,
54
- affectedServices: argv.services, affectedRegions: argv.regions, endTime: argv.endTime,
55
- excludeFromUptime: argv.excludeFromUptime ?? false, isVisibleToCustomers: argv.hidden === undefined ? true : !argv.hidden,
56
- };
57
- const r = await messagingRequest('PUT', `/superadmin/status-incidents/${argv.id}`, body);
58
- console.log(`Updated incident #${r?.id ?? argv.id}`);
59
- },
60
- };
61
-
62
- const deleteCommand = {
63
- command: 'delete <id>',
64
- describe: 'Delete a status incident or clear an override',
65
- builder: (y) => y.positional('id', { type: 'number' }),
66
- handler: async (argv) => {
67
- await messagingRequest('DELETE', `/superadmin/status-incidents/${argv.id}`);
68
- console.log(`Deleted incident #${argv.id}`);
69
- },
70
- };
71
-
72
- const overrideCommand = {
73
- command: 'override',
74
- describe: 'Force a public status page component to a status (POST /superadmin/status-overrides). Components: ' + COMPONENTS + '. Clear with: velaro status-page delete <id>',
75
- builder: (y) => y
76
- .option('component', { type: 'string', demandOption: true, describe: COMPONENTS })
77
- .option('status', { type: 'string', demandOption: true, choices: ['operational', 'degraded', 'outage', 'maintenance'] })
78
- .option('note', { type: 'string', default: '' })
79
- .option('expires-at', { type: 'string', describe: 'ISO timestamp the override auto-clears' })
80
- .option('counts-against-uptime', { type: 'boolean', describe: 'true adds counts-uptime, false adds no-uptime-impact; omit for default' }),
81
- handler: async (argv) => {
82
- const r = await messagingRequest('POST', '/superadmin/status-overrides', {
83
- component: argv.component, status: argv.status, note: argv.note, expiresAt: argv.expiresAt ?? null, countsAgainstUptime: argv.countsAgainstUptime ?? null,
84
- });
85
- console.log(`Override #${r.id} created: ${r.title}`);
86
- },
87
- };
88
-
89
- export const statusPageCommand = {
90
- command: 'status-page <subcommand>',
91
- describe: 'Public status page incidents and component overrides (SuperAdmin only)',
92
- builder: (y) => y.command(listCommand).command(createCommand).command(updateCommand).command(deleteCommand).command(overrideCommand)
93
- .demandCommand(1, 'Specify a subcommand: list, create, update, delete, override').strict(),
94
- handler: () => {},
95
- };
@@ -1,47 +0,0 @@
1
- import { writeFileSync } from 'node:fs';
2
- import { messagingRequest, messagingRequestText } from '../api.js';
3
-
4
- // Staff SLA report for the public status page (velaro-messaging SuperAdmin/status-sla).
5
- // Endpoint is live only after velaro-messaging PR 2223 is deployed.
6
-
7
- export function buildStatusSlaQuery(argv) {
8
- const p = new URLSearchParams();
9
- if (argv.from) p.set('from', argv.from);
10
- if (argv.to) p.set('to', argv.to);
11
- p.set('platform', argv.platform || 'v20');
12
- if (argv.includeMaintenance) p.set('includeMaintenance', 'true');
13
- if (argv.includeDeployments) p.set('includeDeployments', 'true');
14
- if (argv.includeExcludedChecks) p.set('includeExcludedChecks', 'true');
15
- if (argv.degradedDown) p.set('degradedCountsAsDown', 'true');
16
- if (argv.slowMs !== undefined) p.set('slowResponseMs', String(argv.slowMs));
17
- p.set('format', argv.csv ? 'csv' : 'json');
18
- return p.toString();
19
- }
20
-
21
- export const statusSlaCommand = {
22
- command: 'status-sla',
23
- describe: 'SLA / uptime report for the status page, per component (staff only)',
24
- builder: (y) => y
25
- .option('from', { type: 'string', demandOption: true, describe: 'Start date (YYYY-MM-DD)' })
26
- .option('to', { type: 'string', demandOption: true, describe: 'End date (YYYY-MM-DD)' })
27
- .option('platform', { type: 'string', default: 'v20', choices: ['v20', 'v11'] })
28
- .option('include-maintenance', { type: 'boolean', default: false, describe: 'Count scheduled maintenance as downtime' })
29
- .option('include-deployments', { type: 'boolean', default: false, describe: 'Count deployment windows as downtime' })
30
- .option('include-excluded-checks', { type: 'boolean', default: false })
31
- .option('degraded-down', { type: 'boolean', default: false, describe: 'Degraded counts as down' })
32
- .option('slow-ms', { type: 'number', describe: 'Responses slower than this many ms count as slow' })
33
- .option('csv', { type: 'boolean', default: false, describe: 'CSV output (stdout, or --out file)' })
34
- .option('out', { type: 'string', describe: 'Write CSV to this file' })
35
- .option('staging', { type: 'boolean', default: false, describe: 'Use the staging messaging API' }),
36
- handler: async (argv) => {
37
- const path = `SuperAdmin/status-sla?${buildStatusSlaQuery(argv)}`;
38
- const env = argv.staging ? 'staging' : undefined;
39
- if (argv.csv) {
40
- const csv = await messagingRequestText('GET', path, env);
41
- if (argv.out) { writeFileSync(argv.out, csv); console.error(`Wrote ${argv.out}`); }
42
- else process.stdout.write(csv);
43
- return;
44
- }
45
- console.log(JSON.stringify(await messagingRequest('GET', path, undefined, env), null, 2));
46
- },
47
- };