@velaro/cli 1.4.60 → 1.4.62

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/velaro.js CHANGED
@@ -39,6 +39,7 @@ import { integrationCommand } from '../lib/commands/integration.js';
39
39
  import { appointmentsCommand } from '../lib/commands/appointments.js';
40
40
  import { bookingCommand } from '../lib/commands/booking.js';
41
41
  import { reportCommand } from '../lib/commands/report.js';
42
+ import { scheduleAdherenceCommand } from '../lib/commands/schedule-adherence.js';
42
43
  import { conversationEfficiencyCommand } from '../lib/commands/conversation-efficiency.js';
43
44
  import { dbCommand } from '../lib/commands/db.js';
44
45
  import { focusCommand } from '../lib/commands/focus.js';
@@ -75,6 +76,7 @@ import { subscriptionCommand } from '../lib/commands/subscription.js';
75
76
  import { supportCommand } from '../lib/commands/support.js';
76
77
  import { routingCommand } from '../lib/commands/routing.js';
77
78
  import { diagnosticsCommand } from '../lib/commands/diagnostics.js';
79
+ import { aiSpendCommand } from '../lib/commands/ai-spend.js';
78
80
  import { emailInboxCommand } from '../lib/commands/email-inbox.js';
79
81
  import { callbackCommand } from '../lib/commands/callback.js';
80
82
  import { caseCommand } from '../lib/commands/case.js';
@@ -138,6 +140,7 @@ await yargs(hideBin(process.argv))
138
140
  .command(bookingCommand)
139
141
  .command(reportCommand)
140
142
  .command(conversationEfficiencyCommand)
143
+ .command(scheduleAdherenceCommand)
141
144
  .command(dbCommand)
142
145
  .command(focusCommand)
143
146
  .command(automationDraftCommand)
@@ -173,6 +176,7 @@ await yargs(hideBin(process.argv))
173
176
  .command({ command: 'support', desc: 'Staff SupportTools actions on a site (superadmin only)', builder: supportCommand, handler: () => {} })
174
177
  .command(routingCommand)
175
178
  .command(diagnosticsCommand)
179
+ .command(aiSpendCommand)
176
180
  .command(emailInboxCommand)
177
181
  .command(callbackCommand)
178
182
  .command(caseCommand)
@@ -0,0 +1,71 @@
1
+ import { get, post } from '../api.js';
2
+
3
+ const usd = (n) => `$${Number(n ?? 0).toFixed(2)}`;
4
+
5
+ function fmtPT(ts) {
6
+ if (!ts) return '-';
7
+ return new Date(ts).toLocaleString('en-US', { timeZone: 'America/Los_Angeles', dateStyle: 'short', timeStyle: 'short' }) + ' PT';
8
+ }
9
+
10
+ const reportCommand = {
11
+ command: 'report',
12
+ describe: 'AI spend by environment (prod/staging), site, model and key source (superadmin only)',
13
+ builder: (y) => y
14
+ .option('env', { type: 'string', default: 'both', choices: ['both', 'prod', 'staging'] })
15
+ .option('days', { type: 'number', default: 7 })
16
+ .option('json', { type: 'boolean', default: false }),
17
+ handler: async (argv) => {
18
+ const to = new Date();
19
+ const from = new Date(to.getTime() - argv.days * 86400000);
20
+ const r = await get(`SuperAdmin/AiSpend/Report?env=${argv.env}&from=${encodeURIComponent(from.toISOString())}&to=${encodeURIComponent(to.toISOString())}`);
21
+ if (argv.json) { console.log(JSON.stringify(r, null, 2)); return; }
22
+ console.log(`AI spend ${fmtPT(r.from)} to ${fmtPT(r.to)} (breaker trips: not available)`);
23
+ for (const e of r.environments ?? []) {
24
+ if (!e.available) { console.log(`\n[${e.environment}] unavailable: ${e.error}`); continue; }
25
+ const c = e.current;
26
+ console.log(`\n[${e.environment}] ${usd(c.totalEstimatedCostUsd)} / ${c.totalCalls} calls (prev ${usd(e.previous?.totalEstimatedCostUsd)}), cache read ${(e.cacheReadRatio * 100).toFixed(1)}%, QA ${e.qaSharePercent}%`);
27
+ (c.bySite ?? []).slice(0, 10).forEach(s => console.log(` site ${s.siteId}: ${usd(s.estimatedCostUsd)} (${s.calls} calls)`));
28
+ (e.anomalies ?? []).forEach(a => console.log(` ANOMALY site ${a.siteId}: ${a.kind} ${a.detail}`));
29
+ }
30
+ },
31
+ };
32
+
33
+ const reconcileCommand = {
34
+ command: 'reconcile',
35
+ describe: 'Record a provider console total and compare to logged spend',
36
+ builder: (y) => y
37
+ .option('env', { type: 'string', default: 'prod', choices: ['both', 'prod', 'staging'] })
38
+ .option('days', { type: 'number', default: 7 })
39
+ .option('provider', { type: 'string', default: 'Anthropic' })
40
+ .option('key', { type: 'string', describe: 'key bucket: platform, copilot, byok (omit for provider total)' })
41
+ .option('entered', { type: 'number', demandOption: true, describe: 'console total in USD' })
42
+ .option('threshold', { type: 'number', default: 25 })
43
+ .option('notes', { type: 'string' }),
44
+ handler: async (argv) => {
45
+ const to = new Date();
46
+ const from = new Date(to.getTime() - argv.days * 86400000);
47
+ const r = await post('SuperAdmin/AiSpend/Reconciliations', {
48
+ periodStartUtc: from.toISOString(), periodEndUtc: to.toISOString(), environment: argv.env,
49
+ provider: argv.provider, keyLabel: argv.key ?? null, enteredUsd: argv.entered, thresholdUsd: argv.threshold, notes: argv.notes ?? null,
50
+ });
51
+ console.log(`logged ${usd(r.loggedUsd)} vs console ${usd(r.enteredUsd)}: gap ${usd(r.gapUsd)} (${r.gapPercent ?? 'n/a'}%)${r.unloggedSpendFlagged ? ' FLAG: unlogged spend' : ''}`);
52
+ },
53
+ };
54
+
55
+ const historyCommand = {
56
+ command: 'history',
57
+ describe: 'List saved reconciliations',
58
+ builder: (y) => y,
59
+ handler: async () => {
60
+ const rows = await get('SuperAdmin/AiSpend/Reconciliations?take=50');
61
+ for (const r of rows) console.log(`${fmtPT(r.createdUtc)} ${r.environment} ${r.provider}${r.keyLabel ? '/' + r.keyLabel : ''} logged ${usd(r.loggedUsd)} console ${usd(r.enteredUsd)} gap ${usd(r.gapUsd)}${r.unloggedSpendFlagged ? ' FLAG' : ''}`);
62
+ },
63
+ };
64
+
65
+ export const aiSpendCommand = {
66
+ command: 'ai-spend <subcommand>',
67
+ describe: 'AI spend report and provider reconciliation (superadmin only)',
68
+ builder: (y) => y.command(reportCommand).command(reconcileCommand).command(historyCommand)
69
+ .demandCommand(1, 'Specify a subcommand: report, reconcile, history').strict(),
70
+ handler: () => {},
71
+ };
@@ -0,0 +1,33 @@
1
+ import { messagingGet } from '../api.js';
2
+ import { runCommand } from '../run.js';
3
+
4
+ // -- velaro schedule-adherence --------------------------------------------------
5
+ // Staff-only. siteId is an EXPLICIT argument (SupportTools-style), never derived from the caller.
6
+ // Backend: velaro-messaging GET /Reports/sites/{siteId}/schedule-adherence-diagnostics
7
+ // (IsSuperAdminAsync allowSupport gate; role=agent requires agentId, fails closed).
8
+
9
+ export const scheduleAdherenceCommand = {
10
+ command: 'schedule-adherence <siteId>',
11
+ describe: 'Staff: schedule adherence overview/breakdown/intraday/timeline for a site as manager or agent',
12
+ builder: (y) => y
13
+ .positional('siteId', { type: 'number', describe: 'Target customer site ID' })
14
+ .option('role', { type: 'string', choices: ['manager', 'agent'], default: 'manager', describe: 'Scope to apply' })
15
+ .option('agent-id', { type: 'number', describe: 'WorkspaceUser id (required for --role agent)' })
16
+ .option('start', { type: 'string', describe: 'yyyy-MM-dd' })
17
+ .option('end', { type: 'string', describe: 'yyyy-MM-dd' })
18
+ .option('tz', { type: 'string', describe: 'IANA time zone override' })
19
+ .option('json', { type: 'boolean', default: false, describe: 'Raw JSON output' }),
20
+ handler: runCommand(async (argv) => {
21
+ if (argv.role === 'agent' && !argv.agentId) throw new Error('--agent-id is required with --role agent');
22
+ const qs = new URLSearchParams({ detail: 'true', role: argv.role });
23
+ if (argv.agentId) qs.set('agentId', String(argv.agentId));
24
+ for (const k of ['start', 'end', 'tz']) if (argv[k]) qs.set(k, argv[k]);
25
+ const d = await messagingGet(`/Reports/sites/${argv.siteId}/schedule-adherence-diagnostics?${qs}`);
26
+ if (argv.json) { console.log(JSON.stringify(d, null, 2)); return; }
27
+ console.log(`\nSite ${d.siteId} scope=${d.scope} ${d.range?.start}..${d.range?.end} tz=${d.timeZone} invariantsPass=${d.invariantsPass}`);
28
+ console.log(` Totals: sched ${d.totals?.scheduledMinutes}m adherent ${d.totals?.adherentMinutes}m avg ${d.totals?.avgAdherencePercent}%`);
29
+ for (const a of d.agents ?? []) {
30
+ console.log(` [${a.agentId}] ${a.agentName}: ${a.adherencePercent}% status=${a.currentStatus ?? '-'} days=${a.days?.length ?? 0} shiftsToday=${a.timeline?.shifts?.length ?? 0}`);
31
+ }
32
+ }),
33
+ };
@@ -18,10 +18,21 @@ async function usage(argv) {
18
18
  for (const note of u.notes ?? []) console.log(` Note: ${note}`);
19
19
  }
20
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
+
21
30
  export function scraperCommand(yargs) {
22
31
  return yargs
23
32
  .command('usage', 'Show scraper/upload/chunk usage for a site (staff only)', (y) => y
24
33
  .option('site', { type: 'number', demandOption: true, describe: 'Target site id' })
25
34
  .option('json', { type: 'boolean', describe: 'Print raw JSON' }), (a) => usage(a))
26
- .demandCommand(1, 'Specify a subcommand: usage');
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');
27
38
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velaro/cli",
3
- "version": "1.4.60",
3
+ "version": "1.4.62",
4
4
  "description": "Velaro Workspace v20 — command-line interface for managing bots, knowledge base ingestion, MCP API keys, search indexes, and ops health.",
5
5
  "type": "module",
6
6
  "bin": {