@velaro/cli 1.4.112 → 1.4.113
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 +8 -0
- package/lib/capability-authority.js +33 -0
- package/lib/capability-authority.test.js +28 -0
- package/lib/commands/authority.js +63 -0
- package/lib/commands/billing-insights.js +72 -0
- package/lib/commands/commerce-routing.js +72 -0
- package/lib/commands/kb.js +6 -2
- package/lib/commands/mcp-key.js +5 -0
- package/lib/commands/sms.js +78 -0
- package/lib/commands/support.js +43 -1
- package/lib/commerce-routing.test.js +25 -0
- package/package.json +1 -1
package/bin/velaro.js
CHANGED
|
@@ -83,10 +83,12 @@ import { klaviyoMigrationCommand } from '../lib/commands/klaviyo-migration.js';
|
|
|
83
83
|
import { telephonyCommand } from '../lib/commands/telephony.js';
|
|
84
84
|
import { teamsPhoneCommand } from '../lib/commands/teams-phone.js';
|
|
85
85
|
import { zoomPhoneCommand } from '../lib/commands/zoom-phone.js';
|
|
86
|
+
import { smsCommand } from '../lib/commands/sms.js';
|
|
86
87
|
import { teamsCommand } from '../lib/commands/teams.js';
|
|
87
88
|
import { slackCommand } from '../lib/commands/slack.js';
|
|
88
89
|
import { webflowCommand } from '../lib/commands/webflow.js';
|
|
89
90
|
import { shopifyCommand } from '../lib/commands/shopify.js';
|
|
91
|
+
import { commerceRoutingCommand } from '../lib/commands/commerce-routing.js';
|
|
90
92
|
import { netsuiteCommand } from '../lib/commands/netsuite.js';
|
|
91
93
|
import { woocommerceCommand } from '../lib/commands/woocommerce.js';
|
|
92
94
|
import { squarespaceCommand } from '../lib/commands/squarespace.js';
|
|
@@ -121,6 +123,7 @@ import { statusNotifyCommand } from '../lib/commands/status-notify.js';
|
|
|
121
123
|
import { statusSlaCommand } from '../lib/commands/status-sla.js';
|
|
122
124
|
import { emailInboxCommand } from '../lib/commands/email-inbox.js';
|
|
123
125
|
import { callbackCommand } from '../lib/commands/callback.js';
|
|
126
|
+
import { authorityCommand } from '../lib/commands/authority.js';
|
|
124
127
|
import { caseCommand } from '../lib/commands/case.js';
|
|
125
128
|
import { pickupCommand } from '../lib/commands/pickup.js';
|
|
126
129
|
import { siteSaleCommand } from '../lib/commands/site-sale.js';
|
|
@@ -147,6 +150,7 @@ import { adminCommand, appleCommand, forceExpireSiteCommand, backfillCommand, kp
|
|
|
147
150
|
import { aiFollowupsCommand, businessActionCommand, callCommand, conversationCommand, conversionCommand, emailCommand, ivrCommand } from '../lib/commands/ops-groups.js';
|
|
148
151
|
import { entitlementGroup } from '../lib/commands/entitlement.js';
|
|
149
152
|
import { featureDiscoveryGroup } from '../lib/commands/feature-discovery.js';
|
|
153
|
+
import { billingInsightsGroup } from '../lib/commands/billing-insights.js';
|
|
150
154
|
import { startUpdateCheck } from '../lib/update-check.js';
|
|
151
155
|
import { printBanner, printBannerIfFirstRun } from '../lib/banner.js';
|
|
152
156
|
import { createRequire } from 'module';
|
|
@@ -247,10 +251,12 @@ await yargs(hideBin(process.argv))
|
|
|
247
251
|
.command(telephonyCommand)
|
|
248
252
|
.command(teamsPhoneCommand)
|
|
249
253
|
.command(zoomPhoneCommand)
|
|
254
|
+
.command(smsCommand)
|
|
250
255
|
.command(teamsCommand)
|
|
251
256
|
.command(slackCommand)
|
|
252
257
|
.command(webflowCommand)
|
|
253
258
|
.command(shopifyCommand)
|
|
259
|
+
.command(commerceRoutingCommand)
|
|
254
260
|
.command(netsuiteCommand)
|
|
255
261
|
.command(woocommerceCommand)
|
|
256
262
|
.command(squarespaceCommand)
|
|
@@ -285,6 +291,7 @@ await yargs(hideBin(process.argv))
|
|
|
285
291
|
.command(statusSlaCommand)
|
|
286
292
|
.command(emailInboxCommand)
|
|
287
293
|
.command(callbackCommand)
|
|
294
|
+
.command(authorityCommand)
|
|
288
295
|
.command(caseCommand)
|
|
289
296
|
.command(pickupCommand)
|
|
290
297
|
.command(siteSaleCommand)
|
|
@@ -298,6 +305,7 @@ await yargs(hideBin(process.argv))
|
|
|
298
305
|
.command(bundleCommand)
|
|
299
306
|
.command(chatWindowCommand)
|
|
300
307
|
.command(featureDiscoveryGroup)
|
|
308
|
+
.command(billingInsightsGroup)
|
|
301
309
|
.command(scraperGroupCommand)
|
|
302
310
|
.command(tourPolicyGroupCommand)
|
|
303
311
|
.command(livefluenceCommand)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Pure helpers for `velaro authority ...` (capability authority: which system wins when two overlap).
|
|
2
|
+
// Messaging routes: GET CapabilityAuthority, GET CapabilityAuthority/{c}/History, PUT CapabilityAuthority/{c}
|
|
3
|
+
// { mode }, POST CapabilityAuthority/{c}/Revert.
|
|
4
|
+
|
|
5
|
+
export const MODES = ['default', 'off'];
|
|
6
|
+
|
|
7
|
+
export function parseMode(v) {
|
|
8
|
+
const m = String(v ?? '').trim().toLowerCase();
|
|
9
|
+
if (!MODES.includes(m)) throw new Error(`mode must be "default" or "off" (got "${v}")`);
|
|
10
|
+
return m;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function parseCapability(v) {
|
|
14
|
+
const c = String(v ?? '').trim();
|
|
15
|
+
if (!/^[a-z][a-z0-9_]*$/.test(c)) throw new Error(`capability must be a snake_case name such as realtime_stock (got "${v}")`);
|
|
16
|
+
return c;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const capabilityPath = (capability, suffix = '') => `/CapabilityAuthority/${encodeURIComponent(parseCapability(capability))}${suffix}`;
|
|
20
|
+
|
|
21
|
+
export function describeCapability(c) {
|
|
22
|
+
return [
|
|
23
|
+
`${c.capability}: ${c.mode === 'off' ? 'keep both tools' : 'Velaro default'}`,
|
|
24
|
+
` why: ${c.why}`,
|
|
25
|
+
` wins: ${(c.authoritativeTools ?? []).join(', ') || '-'}`,
|
|
26
|
+
` superseded: ${(c.supersededTools ?? []).join(', ') || '-'}`,
|
|
27
|
+
].join('\n');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function describeHistory(rows) {
|
|
31
|
+
if (!rows?.length) return ['No changes yet.'];
|
|
32
|
+
return rows.map((h) => `${h.changedAt} by ${h.changedByEmail || h.changeSource || 'unknown'} was ${h.previousMode}`);
|
|
33
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import { parseMode, parseCapability, capabilityPath, describeHistory, describeCapability } from './capability-authority.js';
|
|
5
|
+
|
|
6
|
+
test('parseMode accepts default/off (any case) and rejects anything else', () => {
|
|
7
|
+
assert.equal(parseMode('DEFAULT'), 'default');
|
|
8
|
+
assert.equal(parseMode('off'), 'off');
|
|
9
|
+
assert.throws(() => parseMode('on'), /mode must be/);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test('capability names are validated and routes target the messaging controller', () => {
|
|
13
|
+
assert.equal(capabilityPath('realtime_stock'), '/CapabilityAuthority/realtime_stock');
|
|
14
|
+
assert.equal(capabilityPath('realtime_stock', '/Revert'), '/CapabilityAuthority/realtime_stock/Revert');
|
|
15
|
+
assert.throws(() => parseCapability('../x'), /snake_case/);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test('history and capability rendering', () => {
|
|
19
|
+
assert.deepEqual(describeHistory([]), ['No changes yet.']);
|
|
20
|
+
assert.match(describeHistory([{ changedAt: '2026-10-25', changedByEmail: 'a@b.com', previousMode: 'default' }])[0], /a@b.com.*was default/);
|
|
21
|
+
assert.match(describeCapability({ capability: 'realtime_stock', mode: 'off', why: 'w', authoritativeTools: ['n'], supersededTools: ['m'] }), /keep both tools/);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('authority.js uses the messaging helpers only', () => {
|
|
25
|
+
const src = fs.readFileSync(new URL('./commands/authority.js', import.meta.url), 'utf8');
|
|
26
|
+
assert.match(src, /messagingGet, messagingPut, messagingPost/);
|
|
27
|
+
assert.doesNotMatch(src, /import\s*\{[^}]*\b(get|post|put|del)\b[^}]*\}\s*from '\.\.\/api\.js'/);
|
|
28
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { messagingGet, messagingPut, messagingPost } from '../api.js';
|
|
2
|
+
import { runCommand } from '../run.js';
|
|
3
|
+
import { parseMode, capabilityPath, describeCapability, describeHistory } from '../capability-authority.js';
|
|
4
|
+
|
|
5
|
+
// velaro authority get | set <capability> <default|off> | history <capability> | revert <capability>
|
|
6
|
+
// Capability authority: which system the AI uses when two connected systems overlap (today: realtime_stock,
|
|
7
|
+
// ERP beats storefront). set/revert are Administrator only; every change is logged and revertable.
|
|
8
|
+
// Site comes from the credential (vmsg-siteId header), never from CLI args.
|
|
9
|
+
|
|
10
|
+
const capArg = (y) => y.positional('capability', { type: 'string', describe: 'Capability, e.g. realtime_stock' });
|
|
11
|
+
|
|
12
|
+
const getCommand = {
|
|
13
|
+
command: 'get',
|
|
14
|
+
describe: 'Show every capability authority rule and its current mode for this site',
|
|
15
|
+
builder: (y) => y,
|
|
16
|
+
handler: runCommand(async () => {
|
|
17
|
+
const data = await messagingGet('/CapabilityAuthority');
|
|
18
|
+
for (const c of data?.capabilities ?? []) console.log(describeCapability(c) + '\n');
|
|
19
|
+
}),
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const setCommand = {
|
|
23
|
+
command: 'set <capability> <mode>',
|
|
24
|
+
describe: 'Set a capability to "default" (Velaro rule applies) or "off" (keep both tools). Administrator only',
|
|
25
|
+
builder: (y) => capArg(y).positional('mode', { type: 'string', choices: ['default', 'off'] }),
|
|
26
|
+
handler: runCommand(async (argv) => {
|
|
27
|
+
const data = await messagingPut(capabilityPath(argv.capability), { mode: parseMode(argv.mode) });
|
|
28
|
+
for (const c of data?.capabilities ?? []) console.log(describeCapability(c) + '\n');
|
|
29
|
+
}),
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const historyCommand = {
|
|
33
|
+
command: 'history <capability>',
|
|
34
|
+
describe: 'Last 10 changes to a capability (who, when, previous mode)',
|
|
35
|
+
builder: capArg,
|
|
36
|
+
handler: runCommand(async (argv) => {
|
|
37
|
+
const data = await messagingGet(capabilityPath(argv.capability, '/History'));
|
|
38
|
+
for (const line of describeHistory(data?.history)) console.log(line);
|
|
39
|
+
}),
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const revertCommand = {
|
|
43
|
+
command: 'revert <capability>',
|
|
44
|
+
describe: 'Revert the last change to a capability. Administrator only; errors if nothing to revert',
|
|
45
|
+
builder: capArg,
|
|
46
|
+
handler: runCommand(async (argv) => {
|
|
47
|
+
const data = await messagingPost(capabilityPath(argv.capability, '/Revert'), {});
|
|
48
|
+
for (const c of data?.capabilities ?? []) console.log(describeCapability(c) + '\n');
|
|
49
|
+
}),
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const authorityCommand = {
|
|
53
|
+
command: 'authority <subcommand>',
|
|
54
|
+
describe: 'Capability authority: which system the AI uses when two systems overlap',
|
|
55
|
+
builder: (y) => y
|
|
56
|
+
.command(getCommand)
|
|
57
|
+
.command(setCommand)
|
|
58
|
+
.command(historyCommand)
|
|
59
|
+
.command(revertCommand)
|
|
60
|
+
.demandCommand(1, 'Specify an authority subcommand.')
|
|
61
|
+
.strict(),
|
|
62
|
+
handler: () => {},
|
|
63
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// velaro billing-insights: billing page recommendations, the Add capacity / Compare plans button preference, and
|
|
2
|
+
// (staff) the monthly recommendations run, a site's recommendation history, and contract limits autofill.
|
|
3
|
+
// Site scoping is server-side: customer calls never pass a siteId. Staff calls name the site in the route.
|
|
4
|
+
import { request } from '../api.js';
|
|
5
|
+
|
|
6
|
+
const bool = (v) => v === true || v === 'true';
|
|
7
|
+
|
|
8
|
+
async function list() {
|
|
9
|
+
const r = await request('GET', 'BillingInsights/recommendations');
|
|
10
|
+
if (!r?.enabled) { console.log('\nBilling recommendations are turned off for this site.'); return; }
|
|
11
|
+
const items = r.items ?? [];
|
|
12
|
+
if (!items.length) { console.log('\nNo billing recommendations this month.'); return; }
|
|
13
|
+
for (const i of items) console.log(`\n#${i.id} ${i.title}\n ${i.body}\n -> ${i.ctaLabel}: ${i.targetUrl}`);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async function dismiss(args) {
|
|
17
|
+
const id = Number(args.id);
|
|
18
|
+
if (!Number.isInteger(id) || id <= 0) { console.error('Usage: velaro billing-insights dismiss <id>'); process.exit(1); }
|
|
19
|
+
await request('POST', `BillingInsights/recommendations/${id}/dismiss`, {});
|
|
20
|
+
console.log(`Dismissed recommendation #${id}.`);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async function prefs() {
|
|
24
|
+
const r = await request('GET', 'BillingInsights/preferences');
|
|
25
|
+
console.log(`\nCapacity buttons hidden: ${r.hideCapacityButtons}\nRecommendations on: ${r.recommendationsEnabled}\nYou can change these: ${r.canManage}`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async function setPrefs(args) {
|
|
29
|
+
const body = {};
|
|
30
|
+
if (args.hideCapacityButtons !== undefined) body.hideCapacityButtons = bool(args.hideCapacityButtons);
|
|
31
|
+
if (args.recommendations !== undefined) body.recommendationsEnabled = bool(args.recommendations);
|
|
32
|
+
if (!Object.keys(body).length) { console.error('Usage: velaro billing-insights set-preferences [--hide-capacity-buttons true|false] [--recommendations true|false]'); process.exit(1); }
|
|
33
|
+
const r = await request('PUT', 'BillingInsights/preferences', body);
|
|
34
|
+
console.log(`Saved. Capacity buttons hidden: ${r.hideCapacityButtons}, recommendations on: ${r.recommendationsEnabled}`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async function run(args) {
|
|
38
|
+
const body = { siteId: args.siteId ?? null, dryRun: !bool(args.apply) };
|
|
39
|
+
const r = await request('POST', 'BillingInsights/staff/run', body);
|
|
40
|
+
console.log(JSON.stringify(r, null, 2));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async function history(args) {
|
|
44
|
+
const r = await request('GET', `BillingInsights/staff/sites/${Number(args.siteId)}/recommendations?take=${Number(args.take) || 30}`);
|
|
45
|
+
console.log(JSON.stringify(r, null, 2));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function contractLimits(args) {
|
|
49
|
+
const r = await request('GET', `BillingInsights/contract-limits?packageKeys=${encodeURIComponent(args.packageKeys)}`);
|
|
50
|
+
console.log(r.markdown);
|
|
51
|
+
if (r.unknownKeys?.length) console.error(`\nUnknown package keys: ${r.unknownKeys.join(', ')}`);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function billingInsightsCommand(yargs) {
|
|
55
|
+
return yargs
|
|
56
|
+
.command('recommendations', 'List this month\'s billing recommendations (site administrators)', () => {}, () => list())
|
|
57
|
+
.command('dismiss <id>', 'Dismiss a recommendation', (y) => y.positional('id', { type: 'number' }), (a) => dismiss(a))
|
|
58
|
+
.command('preferences', 'Show the capacity-button and recommendations preferences', () => {}, () => prefs())
|
|
59
|
+
.command('set-preferences', 'Change the preferences (site administrators)', (y) => y
|
|
60
|
+
.option('hide-capacity-buttons', { type: 'string', desc: 'true|false: hide Add capacity / Compare plans' })
|
|
61
|
+
.option('recommendations', { type: 'string', desc: 'true|false: turn recommendations on or off' }), (a) => setPrefs({ hideCapacityButtons: a['hide-capacity-buttons'], recommendations: a.recommendations }))
|
|
62
|
+
.command('run', 'Staff: run the recommendations pass (dry run unless --apply true)', (y) => y
|
|
63
|
+
.option('site-id', { type: 'number' }).option('apply', { type: 'string', desc: 'true to persist' }), (a) => run({ siteId: a['site-id'], apply: a.apply }))
|
|
64
|
+
.command('history <siteId>', 'Staff: a site\'s recommendation history', (y) => y
|
|
65
|
+
.positional('siteId', { type: 'number' }).option('take', { type: 'number' }), (a) => history(a))
|
|
66
|
+
.command('contract-limits <packageKeys>', 'Staff: contract autofill text for pricing packages (comma separated PackageKey values)', (y) => y
|
|
67
|
+
.positional('packageKeys', { type: 'string' }), (a) => contractLimits(a))
|
|
68
|
+
.demandCommand(1, 'Specify a subcommand: recommendations | dismiss | preferences | set-preferences | run | history | contract-limits');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Registered group object (the CLI/MCP parity validator reads `command:` from a named const).
|
|
72
|
+
export const billingInsightsGroup = { command: 'billing-insights', desc: 'Billing recommendations, capacity-button preference, contract limits autofill', builder: billingInsightsCommand, handler: () => {} };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* velaro commerce-routing — which connected commerce system the AI asks first for each question
|
|
3
|
+
*
|
|
4
|
+
* velaro commerce-routing get
|
|
5
|
+
* velaro commerce-routing set [--product-search magento] [--order-status netsuite] [--stock-check netsuite] [--customer-lookup netsuite]
|
|
6
|
+
* velaro commerce-routing clear
|
|
7
|
+
*
|
|
8
|
+
* Only matters when a site has two or more commerce systems connected (Magento + NetSuite, ...). Backend contract:
|
|
9
|
+
* GET/PUT /CommerceRouting (velaro-messaging). The site always comes from your login.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { messagingGet, messagingPut } from '../api.js';
|
|
13
|
+
|
|
14
|
+
const GRN = '\x1b[32m';
|
|
15
|
+
const DIM = '\x1b[2m';
|
|
16
|
+
const BOLD = '\x1b[1m';
|
|
17
|
+
const RST = '\x1b[0m';
|
|
18
|
+
|
|
19
|
+
const FLAG_TO_CAPABILITY = {
|
|
20
|
+
'product-search': 'product_search',
|
|
21
|
+
'order-status': 'order_status',
|
|
22
|
+
'stock-check': 'stock_check',
|
|
23
|
+
'customer-lookup': 'customer_lookup',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/** Builds the PUT body from CLI flags. Capabilities not given are cleared back to the default. */
|
|
27
|
+
export function buildRoutingBody(argv) {
|
|
28
|
+
const preferred = {};
|
|
29
|
+
for (const [flag, capability] of Object.entries(FLAG_TO_CAPABILITY)) {
|
|
30
|
+
const key = flag.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
31
|
+
const v = argv[flag] ?? argv[key];
|
|
32
|
+
if (typeof v === 'string' && v.trim() && v.trim().toLowerCase() !== 'default') preferred[capability] = v.trim().toLowerCase();
|
|
33
|
+
}
|
|
34
|
+
return { preferred };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function print(view) {
|
|
38
|
+
console.log(`\n${BOLD}Commerce system routing${RST} ${DIM}(only used when 2+ commerce systems are connected)${RST}\n`);
|
|
39
|
+
for (const cap of view.capabilities ?? []) {
|
|
40
|
+
const chosen = view.preferred?.[cap];
|
|
41
|
+
console.log(` ${cap.padEnd(16)} ${chosen ? `${GRN}${chosen}${RST} (override)` : `${view.defaults?.[cap] ?? 'automatic'} ${DIM}(default)${RST}`}`);
|
|
42
|
+
}
|
|
43
|
+
console.log('');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function getHandler() {
|
|
47
|
+
print(await messagingGet('/CommerceRouting'));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async function setHandler(argv) {
|
|
51
|
+
const updated = await messagingPut('/CommerceRouting', buildRoutingBody(argv));
|
|
52
|
+
console.log(`\n${GRN}✓${RST} Commerce routing updated.`);
|
|
53
|
+
print(updated);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async function clearHandler() {
|
|
57
|
+
const updated = await messagingPut('/CommerceRouting', { preferred: {} });
|
|
58
|
+
console.log(`\n${GRN}✓${RST} Commerce routing cleared (defaults restored).`);
|
|
59
|
+
print(updated);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export const commerceRoutingCommand = {
|
|
63
|
+
command: 'commerce-routing <action>',
|
|
64
|
+
describe: 'Which connected commerce system (Magento, Shopify, NetSuite, ...) the AI asks first for products, orders, stock and customers',
|
|
65
|
+
builder: y => y
|
|
66
|
+
.positional('action', { choices: ['get', 'set', 'clear'], type: 'string' })
|
|
67
|
+
.option('product-search', { type: 'string', describe: 'System for product questions: magento|shopify|bigcommerce|woocommerce|netsuite|default' })
|
|
68
|
+
.option('order-status', { type: 'string', describe: 'System for order status questions' })
|
|
69
|
+
.option('stock-check', { type: 'string', describe: 'System for stock and availability questions' })
|
|
70
|
+
.option('customer-lookup', { type: 'string', describe: 'System for customer account lookups' }),
|
|
71
|
+
handler: argv => (argv.action === 'get' ? getHandler() : argv.action === 'clear' ? clearHandler() : setHandler(argv)),
|
|
72
|
+
};
|
package/lib/commands/kb.js
CHANGED
|
@@ -302,7 +302,7 @@ const overrideCommand = {
|
|
|
302
302
|
for (const item of items) {
|
|
303
303
|
const status = item.isActive ? 'active ' : 'inactive';
|
|
304
304
|
const expiry = item.expiresAt ? ` expires ${new Date(item.expiresAt).toLocaleDateString()}` : '';
|
|
305
|
-
console.log(` [${item.id}] ${status} ${truncate(item.title ?? item.content, 60)}${expiry}`);
|
|
305
|
+
console.log(` [${item.id}] ${status} ${truncate(item.topic ?? item.title ?? item.overrideFact ?? item.content, 60)}${expiry}`);
|
|
306
306
|
}
|
|
307
307
|
}),
|
|
308
308
|
})
|
|
@@ -313,10 +313,14 @@ const overrideCommand = {
|
|
|
313
313
|
y
|
|
314
314
|
.option('title', { type: 'string', demandOption: true, describe: 'Override title' })
|
|
315
315
|
.option('content', { type: 'string', demandOption: true, describe: 'Authoritative content' })
|
|
316
|
+
.option('search-terms', { type: 'string', describe: 'Comma-separated keywords; the override only fires when the visitor message contains one' })
|
|
316
317
|
.option('expires', { type: 'string', describe: 'Expiry date (ISO 8601, e.g. 2026-12-31)' }),
|
|
317
318
|
handler: runCommand(async (argv) => {
|
|
318
319
|
await requireFeature('enableKnowledgeBase', 'Knowledge Base');
|
|
319
|
-
|
|
320
|
+
// The messaging API model is { topic, overrideFact, searchTerms, priority, expiresAt }; sending
|
|
321
|
+
// title/content returned 400 "Topic and fact are required." (fixed 2026-10-27).
|
|
322
|
+
const payload = { topic: argv.title, overrideFact: argv.content };
|
|
323
|
+
if (argv['search-terms']) payload.searchTerms = argv['search-terms'];
|
|
320
324
|
if (argv.expires) payload.expiresAt = new Date(argv.expires).toISOString();
|
|
321
325
|
const result = await messagingPost('/Ticket/knowledge-overrides', payload);
|
|
322
326
|
console.log(`Override added: [${result.id}] "${argv.title}"`);
|
package/lib/commands/mcp-key.js
CHANGED
|
@@ -60,11 +60,16 @@ const mcpKeyCreateCommand = {
|
|
|
60
60
|
.option('expires', {
|
|
61
61
|
describe: 'Expiry date in ISO 8601 format (e.g. 2027-01-01)',
|
|
62
62
|
type: 'string',
|
|
63
|
+
})
|
|
64
|
+
.option('scopes', {
|
|
65
|
+
describe: 'Comma-separated scopes (e.g. "admin" for staff admin tools). Omit for the default scope set.',
|
|
66
|
+
type: 'string',
|
|
63
67
|
}),
|
|
64
68
|
|
|
65
69
|
handler: runCommand(async (argv) => {
|
|
66
70
|
const payload = { label: argv.label };
|
|
67
71
|
if (argv.expires) payload.expiresAt = new Date(argv.expires).toISOString();
|
|
72
|
+
if (argv.scopes) payload.scopes = String(argv.scopes).split(',').map((s) => s.trim()).filter(Boolean);
|
|
68
73
|
|
|
69
74
|
const result = await post('/McpApiKeys', payload);
|
|
70
75
|
console.log(`MCP key created: ${result.label}`);
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* velaro sms tollfree - text-enable a toll-free number the site already owns (calls stay with Teams Phone or the carrier)
|
|
3
|
+
*
|
|
4
|
+
* velaro sms tollfree status --number +18335550100 [--team-id n]
|
|
5
|
+
* velaro sms tollfree host --number ... --business ... --email ... --phone ... --street ... --city ... --region ... --postal ...
|
|
6
|
+
* velaro sms tollfree verify --number ... --spec verification.json (fields as in MCP sms_tollfree_verify)
|
|
7
|
+
*
|
|
8
|
+
* Backend: velaro-messaging Sms/TollFree (SmsTollFreeController). Site from the auth context only.
|
|
9
|
+
*/
|
|
10
|
+
import fs from 'node:fs';
|
|
11
|
+
import { messagingGet, messagingPost } from '../api.js';
|
|
12
|
+
|
|
13
|
+
const print = (o) => console.log(JSON.stringify(o, null, 2));
|
|
14
|
+
|
|
15
|
+
export const smsCommand = {
|
|
16
|
+
command: 'sms <subcommand>',
|
|
17
|
+
describe: 'SMS channel tools (toll-free texting on a number you already own)',
|
|
18
|
+
builder: (y) => y
|
|
19
|
+
.command({
|
|
20
|
+
command: 'tollfree <action>',
|
|
21
|
+
describe: 'Toll-free texting: status | host | verify',
|
|
22
|
+
builder: (yy) => yy
|
|
23
|
+
.command({
|
|
24
|
+
command: 'status',
|
|
25
|
+
describe: 'Hosting, Inbox and carrier verification status (finishes the Inbox channel once hosting completes)',
|
|
26
|
+
builder: (z) => z.option('number', { type: 'string', demandOption: true }).option('team-id', { type: 'number' }),
|
|
27
|
+
handler: async (a) => {
|
|
28
|
+
const team = a.teamId ? '&teamId=' + a.teamId : '';
|
|
29
|
+
print(await messagingGet('/Sms/TollFree/Status?phoneNumber=' + encodeURIComponent(a.number) + team));
|
|
30
|
+
},
|
|
31
|
+
})
|
|
32
|
+
.command({
|
|
33
|
+
command: 'host',
|
|
34
|
+
describe: 'Request texting on the number (Twilio emails the owner a letter of authorization)',
|
|
35
|
+
builder: (z) => z
|
|
36
|
+
.option('number', { type: 'string', demandOption: true })
|
|
37
|
+
.option('team-id', { type: 'number' })
|
|
38
|
+
.option('business', { type: 'string', demandOption: true })
|
|
39
|
+
.option('contact-name', { type: 'string' })
|
|
40
|
+
.option('email', { type: 'string', demandOption: true })
|
|
41
|
+
.option('phone', { type: 'string', demandOption: true })
|
|
42
|
+
.option('street', { type: 'string', demandOption: true })
|
|
43
|
+
.option('city', { type: 'string', demandOption: true })
|
|
44
|
+
.option('region', { type: 'string', demandOption: true })
|
|
45
|
+
.option('postal', { type: 'string', demandOption: true })
|
|
46
|
+
.option('country', { type: 'string', default: 'US' }),
|
|
47
|
+
handler: async (a) => print(await messagingPost('/Sms/TollFree/Host', {
|
|
48
|
+
phoneNumber: a.number,
|
|
49
|
+
teamId: a.teamId,
|
|
50
|
+
businessName: a.business,
|
|
51
|
+
contactName: a.contactName,
|
|
52
|
+
contactEmail: a.email,
|
|
53
|
+
contactPhone: a.phone,
|
|
54
|
+
street: a.street,
|
|
55
|
+
city: a.city,
|
|
56
|
+
region: a.region,
|
|
57
|
+
postalCode: a.postal,
|
|
58
|
+
country: a.country,
|
|
59
|
+
})),
|
|
60
|
+
})
|
|
61
|
+
.command({
|
|
62
|
+
command: 'verify',
|
|
63
|
+
describe: 'Submit the carrier toll-free verification from a JSON file',
|
|
64
|
+
builder: (z) => z
|
|
65
|
+
.option('number', { type: 'string', demandOption: true })
|
|
66
|
+
.option('spec', { type: 'string', demandOption: true, describe: 'JSON file with the verification fields' }),
|
|
67
|
+
handler: async (a) => {
|
|
68
|
+
const body = JSON.parse(fs.readFileSync(a.spec, 'utf8'));
|
|
69
|
+
print(await messagingPost('/Sms/TollFree/Verification', { ...body, phoneNumber: a.number }));
|
|
70
|
+
},
|
|
71
|
+
})
|
|
72
|
+
.demandCommand(1, 'Specify status, host or verify.'),
|
|
73
|
+
handler: () => {},
|
|
74
|
+
})
|
|
75
|
+
.demandCommand(1, 'Specify an sms subcommand.')
|
|
76
|
+
.strict(),
|
|
77
|
+
handler: () => {},
|
|
78
|
+
};
|
package/lib/commands/support.js
CHANGED
|
@@ -26,6 +26,38 @@ async function setLimit(args) {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
// Read-back for set-limit: GET SupportTools/sites/{id}/subscription/limits (messaging API, staff only).
|
|
30
|
+
async function getLimit(args) {
|
|
31
|
+
if (!args.site) {
|
|
32
|
+
console.error('Usage: velaro support get-limit --site 100140 [--key maxWorkflowRunsPerMonth]');
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
const qs = args.key ? `?key=${encodeURIComponent(args.key)}` : '';
|
|
36
|
+
const r = await messagingGet(`SupportTools/sites/${args.site}/subscription/limits${qs}`);
|
|
37
|
+
if (args.json) { console.log(JSON.stringify(r, null, 2)); return; }
|
|
38
|
+
console.log(`Site ${r.siteId} (package version ${r.packageVersionId ?? 'none'}, overage: ${r.overageBehavior})`);
|
|
39
|
+
const fmt = v => (v === null || v === undefined ? '-' : String(v));
|
|
40
|
+
console.log('\nField'.padEnd(42) + 'Sub'.padEnd(12) + 'Plan'.padEnd(12) + 'Effective'.padEnd(12) + 'Override');
|
|
41
|
+
for (const f of r.fields || []) {
|
|
42
|
+
console.log(f.key.padEnd(41) + fmt(f.subscriptionValue).padEnd(12) + fmt(f.planValue).padEnd(12) + fmt(f.effective).padEnd(12) + (f.isOverride ? 'yes' : ''));
|
|
43
|
+
}
|
|
44
|
+
console.log('\nMetric (what enforcement checks)'.padEnd(42) + 'Effective'.padEnd(12) + 'Plan'.padEnd(12) + 'Cached'.padEnd(12) + 'Override');
|
|
45
|
+
for (const m of r.metrics || []) {
|
|
46
|
+
console.log(m.metric.padEnd(41) + fmt(m.effective).padEnd(12) + fmt(m.planValue).padEnd(12) + (fmt(m.cachedEffective) + (m.cacheStale ? ' (stale)' : '')).padEnd(12) + (m.isOverride ? 'yes' : ''));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Temporary grant: +N units on a metered cap until the period rolls over, then back to the plan value (no cleanup).
|
|
51
|
+
async function grantLimit(args) {
|
|
52
|
+
const n = Number(args.amount);
|
|
53
|
+
if (!args.site || !args.metric || !Number.isInteger(n) || n < 0) {
|
|
54
|
+
console.error('Usage: velaro support grant-limit --site 100140 --metric workflow_runs --amount 400 (amount 0 clears)');
|
|
55
|
+
process.exit(1);
|
|
56
|
+
}
|
|
57
|
+
const r = await messagingPost(`SupportTools/sites/${args.site}/subscription/temporary-grant`, { metric: args.metric, amount: n });
|
|
58
|
+
console.log(`Site ${r.siteId}: +${r.grantAmount} ${r.metric} until ${r.expiresAtPacific}; effective limit now ${r.effectiveLimitNow ?? '?'}. ${r.note}`);
|
|
59
|
+
}
|
|
60
|
+
|
|
29
61
|
async function scraperCreateJob(args) {
|
|
30
62
|
if (!args.site || !args.urls) {
|
|
31
63
|
console.error('Usage: velaro support scraper-create-job --site 1032 --urls "https://example.com" [--maxPages 30] [--crawlDepth 2] [--name "job name"]');
|
|
@@ -249,6 +281,16 @@ export function supportCommand(yargs) {
|
|
|
249
281
|
.option('key', { type: 'string', demandOption: true, desc: 'Cap name, e.g. maxBotTurnsPerMonth' })
|
|
250
282
|
.option('value', { type: 'number', demandOption: true, desc: 'Whole number >= 0' })
|
|
251
283
|
, a => setLimit(a))
|
|
284
|
+
.command('get-limit', 'Read back numeric Subscription caps for a site: subscription value, plan value, effective value, override flag (superadmin only, read-only)', y => y
|
|
285
|
+
.option('site', { type: 'number', demandOption: true, desc: 'Site ID' })
|
|
286
|
+
.option('key', { type: 'string', desc: 'Only this cap, e.g. maxWorkflowRunsPerMonth or workflow_runs' })
|
|
287
|
+
.option('json', { type: 'boolean', desc: 'Raw JSON' })
|
|
288
|
+
, a => getLimit(a))
|
|
289
|
+
.command('grant-limit', 'Temporarily raise a metered cap for the rest of the billing period; it reverts to the plan value automatically (superadmin only)', y => y
|
|
290
|
+
.option('site', { type: 'number', demandOption: true, desc: 'Site ID' })
|
|
291
|
+
.option('metric', { type: 'string', demandOption: true, desc: 'workflow_runs | webhook_invocations | http_request_actions | conversations | ivr_minutes | mcp_calls | workflow_ai_calls' })
|
|
292
|
+
.option('amount', { type: 'number', demandOption: true, desc: 'Extra units this period (0 clears the grant)' })
|
|
293
|
+
, a => grantLimit(a))
|
|
252
294
|
.command('scraper-create-job', 'Trigger a scraper job on behalf of any site (superadmin only — no need to be logged in as that site\'s own user)', y => y
|
|
253
295
|
.option('site', { type: 'number', demandOption: true, desc: 'Target site ID' })
|
|
254
296
|
.option('urls', { type: 'string', demandOption: true, desc: 'Comma-separated URLs to crawl' })
|
|
@@ -263,5 +305,5 @@ export function supportCommand(yargs) {
|
|
|
263
305
|
.option('channel', { type: 'string', desc: 'Conversation source, e.g. Web, TwilioSms (default Web)' })
|
|
264
306
|
.option('overrideIndexes', { type: 'string', desc: 'Comma-separated index names to override the config\'s own IndexName for this query' })
|
|
265
307
|
, a => chatQuery(a))
|
|
266
|
-
.demandCommand(1, 'Specify a subcommand: deployments | impersonate | agent-lookup | add-site-user | toggle-flag | set-limit | scraper-create-job | chat-query | send-email | tour-insights | connection-timeline | connection-evidence');
|
|
308
|
+
.demandCommand(1, 'Specify a subcommand: deployments | impersonate | agent-lookup | add-site-user | toggle-flag | set-limit | get-limit | grant-limit | scraper-create-job | chat-query | send-email | tour-insights | connection-timeline | connection-evidence');
|
|
267
309
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import { buildRoutingBody } from './commands/commerce-routing.js';
|
|
7
|
+
|
|
8
|
+
const root = path.join(path.dirname(fileURLToPath(import.meta.url)), '..', '..');
|
|
9
|
+
|
|
10
|
+
test('buildRoutingBody maps flags to capabilities and drops "default"', () => {
|
|
11
|
+
assert.deepEqual(buildRoutingBody({ 'product-search': 'Magento', 'order-status': 'netsuite' }), {
|
|
12
|
+
preferred: { product_search: 'magento', order_status: 'netsuite' },
|
|
13
|
+
});
|
|
14
|
+
assert.deepEqual(buildRoutingBody({ 'stock-check': 'default' }), { preferred: {} });
|
|
15
|
+
assert.deepEqual(buildRoutingBody({}), { preferred: {} });
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test('CLI registers commerce-routing and MCP exposes get/set without a siteId argument', () => {
|
|
19
|
+
const cli = fs.readFileSync(path.join(root, 'cli/bin/velaro.js'), 'utf8');
|
|
20
|
+
assert.match(cli, /\.command\(commerceRoutingCommand\)/);
|
|
21
|
+
const mcp = fs.readFileSync(path.join(root, 'mcp/parity/commerce-routing.customer.js'), 'utf8');
|
|
22
|
+
assert.match(mcp, /commerce_routing_get/);
|
|
23
|
+
assert.match(mcp, /commerce_routing_set/);
|
|
24
|
+
assert.doesNotMatch(mcp, /siteId/);
|
|
25
|
+
});
|
package/package.json
CHANGED