@velaro/cli 1.4.111 → 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/agent.js +108 -2
- 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/migrate.js +7 -1
- package/lib/commands/outbound-activity.js +28 -0
- package/lib/commands/parity-staff-tools.js +2 -2
- 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
|
+
});
|
package/lib/commands/agent.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { get, post, messagingGet, messagingPost, messagingPut, getCredentials } from '../api.js';
|
|
1
|
+
import { get, post, messagingGet, messagingPost, messagingPut, messagingDel, getCredentials } from '../api.js';
|
|
2
2
|
import { runCommand } from '../run.js';
|
|
3
3
|
|
|
4
4
|
const VALID_STATUSES = ['Available', 'Busy', 'Away', 'Offline'];
|
|
@@ -264,5 +264,111 @@ export const agentCommand = {
|
|
|
264
264
|
console.log(r.summary);
|
|
265
265
|
}),
|
|
266
266
|
})
|
|
267
|
-
|
|
267
|
+
// Agent CRM logins (velaro-messaging api/v1/AgentCrmIdentities): which NetSuite / Dynamics / HubSpot user is
|
|
268
|
+
// which Velaro agent. Drives the CRM call pop and the owner of calls logged to the CRM. Site from the key.
|
|
269
|
+
.command({
|
|
270
|
+
command: 'crm-identity <action>',
|
|
271
|
+
describe: 'Link CRM logins (NetSuite, Dynamics, HubSpot) to agents for the CRM call pop and call owner',
|
|
272
|
+
builder: (y) => y
|
|
273
|
+
.command({
|
|
274
|
+
command: 'list',
|
|
275
|
+
describe: 'List linked CRM logins (all agents, or one with --agent / --agent-email)',
|
|
276
|
+
builder: (z) => z
|
|
277
|
+
.option('agent', { type: 'number', describe: 'Agent WorkspaceUser id' })
|
|
278
|
+
.option('agent-email', { type: 'string', describe: 'Agent Velaro email (alternative to --agent)' })
|
|
279
|
+
.option('json', { type: 'boolean', default: false }),
|
|
280
|
+
handler: runCommand(async (argv) => {
|
|
281
|
+
let agentId = argv.agent;
|
|
282
|
+
if (!agentId && argv['agent-email']) agentId = await agentIdByEmail(argv['agent-email']);
|
|
283
|
+
const r = await messagingGet(`/api/v1/AgentCrmIdentities${agentId ? `?workspaceUserId=${agentId}` : ''}`);
|
|
284
|
+
const rows = r?.data?.identities ?? [];
|
|
285
|
+
if (argv.json) { console.log(JSON.stringify(rows, null, 2)); return; }
|
|
286
|
+
if (!rows.length) { console.log('No CRM logins linked.'); return; }
|
|
287
|
+
for (const x of rows) {
|
|
288
|
+
console.log(`#${x.id} ${x.provider.padEnd(10)} ${String(x.loginEmail ?? '-').padEnd(32)} id=${x.crmUserId ?? '-'} -> agent ${x.workspaceUserId} ${x.agentEmail ?? ''} (${x.source})`);
|
|
289
|
+
}
|
|
290
|
+
}),
|
|
291
|
+
})
|
|
292
|
+
.command({
|
|
293
|
+
command: 'add',
|
|
294
|
+
describe: 'Link a CRM login to an agent',
|
|
295
|
+
builder: (z) => z
|
|
296
|
+
.option('agent', { type: 'number', describe: 'Agent WorkspaceUser id' })
|
|
297
|
+
.option('agent-email', { type: 'string', describe: 'Agent Velaro email (alternative to --agent)' })
|
|
298
|
+
.option('provider', { type: 'string', demandOption: true, describe: 'netsuite | dynamics | hubspot | salesforce | zoho | other' })
|
|
299
|
+
.option('login', { type: 'string', describe: 'CRM login email' })
|
|
300
|
+
.option('crm-user-id', { type: 'string', describe: 'CRM user id (NetSuite employee id, Dynamics systemuserid, HubSpot owner id)' })
|
|
301
|
+
.check((a) => {
|
|
302
|
+
if (!a.agent && !a['agent-email']) throw new Error('Pass --agent <id> or --agent-email <email>.');
|
|
303
|
+
if (!a.login && !a['crm-user-id']) throw new Error('Pass --login, --crm-user-id, or both.');
|
|
304
|
+
return true;
|
|
305
|
+
}),
|
|
306
|
+
handler: runCommand(async (argv) => {
|
|
307
|
+
const body = {
|
|
308
|
+
workspaceUserId: argv.agent ?? null,
|
|
309
|
+
agentEmail: argv['agent-email'] ?? null,
|
|
310
|
+
provider: argv.provider,
|
|
311
|
+
loginEmail: argv.login ?? null,
|
|
312
|
+
crmUserId: argv['crm-user-id'] ?? null,
|
|
313
|
+
};
|
|
314
|
+
const r = await messagingPost('/api/v1/AgentCrmIdentities', body);
|
|
315
|
+
const x = r?.data;
|
|
316
|
+
console.log(`Linked ${x?.provider} login ${x?.loginEmail ?? x?.crmUserId} to agent ${x?.workspaceUserId} (${x?.agentEmail ?? ''}), id #${x?.id}.`);
|
|
317
|
+
}),
|
|
318
|
+
})
|
|
319
|
+
.command({
|
|
320
|
+
command: 'remove <id>',
|
|
321
|
+
describe: 'Unlink a CRM login by its id (from list)',
|
|
322
|
+
builder: (z) => z.positional('id', { type: 'number' }),
|
|
323
|
+
handler: runCommand(async (argv) => {
|
|
324
|
+
await messagingDel(`/api/v1/AgentCrmIdentities/${encodeURIComponent(argv.id)}`);
|
|
325
|
+
console.log(`Removed CRM login #${argv.id}.`);
|
|
326
|
+
}),
|
|
327
|
+
})
|
|
328
|
+
.command({
|
|
329
|
+
command: 'unlinked',
|
|
330
|
+
describe: 'CRM logins that polled the call pop but are linked to no agent',
|
|
331
|
+
builder: (z) => z.option('json', { type: 'boolean', default: false }),
|
|
332
|
+
handler: runCommand(async (argv) => {
|
|
333
|
+
const r = await messagingGet('/api/v1/AgentCrmIdentities/unlinked-logins');
|
|
334
|
+
const rows = r?.data?.logins ?? [];
|
|
335
|
+
if (argv.json) { console.log(JSON.stringify(rows, null, 2)); return; }
|
|
336
|
+
if (!rows.length) { console.log('No unlinked CRM logins.'); return; }
|
|
337
|
+
for (const x of rows) {
|
|
338
|
+
console.log(`#${x.id} ${x.provider.padEnd(10)} ${String(x.loginEmail ?? '-').padEnd(32)} id=${x.crmUserId ?? '-'} last seen ${x.lastSeenAt}`);
|
|
339
|
+
}
|
|
340
|
+
}),
|
|
341
|
+
})
|
|
342
|
+
.command({
|
|
343
|
+
command: 'link <id>',
|
|
344
|
+
describe: 'Link an unlinked CRM login (id from "unlinked") to an agent',
|
|
345
|
+
builder: (z) => z
|
|
346
|
+
.positional('id', { type: 'number' })
|
|
347
|
+
.option('agent', { type: 'number', describe: 'Agent WorkspaceUser id' })
|
|
348
|
+
.option('agent-email', { type: 'string', describe: 'Agent Velaro email (alternative to --agent)' })
|
|
349
|
+
.check((a) => {
|
|
350
|
+
if (!a.agent && !a['agent-email']) throw new Error('Pass --agent <id> or --agent-email <email>.');
|
|
351
|
+
return true;
|
|
352
|
+
}),
|
|
353
|
+
handler: runCommand(async (argv) => {
|
|
354
|
+
const r = await messagingPost(`/api/v1/AgentCrmIdentities/unlinked-logins/${encodeURIComponent(argv.id)}/link`, {
|
|
355
|
+
workspaceUserId: argv.agent ?? null,
|
|
356
|
+
agentEmail: argv['agent-email'] ?? null,
|
|
357
|
+
});
|
|
358
|
+
const x = r?.data;
|
|
359
|
+
console.log(`Linked ${x?.provider} login ${x?.loginEmail ?? x?.crmUserId} to agent ${x?.workspaceUserId}, id #${x?.id}.`);
|
|
360
|
+
}),
|
|
361
|
+
})
|
|
362
|
+
.demandCommand(1, 'Specify an action: list | add | remove | unlinked | link'),
|
|
363
|
+
})
|
|
364
|
+
.demandCommand(1, 'Specify a subcommand: list | set-status | missed-chats | availability | ai-summary | crm-identity'),
|
|
268
365
|
};
|
|
366
|
+
|
|
367
|
+
/** WorkspaceUser id of the agent with this email on the caller's site (messaging Users/List). */
|
|
368
|
+
async function agentIdByEmail(email) {
|
|
369
|
+
const users = await messagingGet('/Users/List');
|
|
370
|
+
const list = Array.isArray(users) ? users : (users?.data ?? users?.users ?? []);
|
|
371
|
+
const hit = list.find((u) => String(u.email ?? '').toLowerCase() === String(email).toLowerCase());
|
|
372
|
+
if (!hit) throw new Error(`No agent with email ${email} on this site.`);
|
|
373
|
+
return hit.id;
|
|
374
|
+
}
|
|
@@ -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}`);
|
package/lib/commands/migrate.js
CHANGED
|
@@ -26,11 +26,13 @@ const migrateExportCommand = {
|
|
|
26
26
|
y
|
|
27
27
|
.positional('v10SiteId', { type: 'number', describe: 'V10 site ID to export from' })
|
|
28
28
|
.option('v20-site-id', { type: 'number', alias: 's', describe: 'V20 site ID for auto-matching teams/AI configs' })
|
|
29
|
-
.option('include-non-routing', { type: 'boolean', default: false, describe: 'Also include v10 rules with IsRouting=false (group-assignment rules)' })
|
|
29
|
+
.option('include-non-routing', { type: 'boolean', default: false, describe: 'Also include v10 rules with IsRouting=false (group-assignment rules)' })
|
|
30
|
+
.option('path-only-urls', { type: 'boolean', default: false, describe: 'Strip v10 URL terms to their path (demo-page testing only). Default keeps the host, like v10.' }),
|
|
30
31
|
handler: runCommand(async (argv) => {
|
|
31
32
|
const params = [];
|
|
32
33
|
if (argv['v20-site-id']) params.push(`v20SiteId=${argv['v20-site-id']}`);
|
|
33
34
|
if (argv['include-non-routing']) params.push('includeNonRouting=true');
|
|
35
|
+
if (argv['path-only-urls']) params.push('pathOnlyUrls=true');
|
|
34
36
|
const qs = params.length ? `?${params.join('&')}` : '';
|
|
35
37
|
const data = await get(`/DatabaseTool/V10Export/${argv.v10SiteId}${qs}`);
|
|
36
38
|
|
|
@@ -89,6 +91,8 @@ const migrateLivefluenceCommand = {
|
|
|
89
91
|
.option('enable', { type: 'boolean', default: false, describe: 'Enable created workflows immediately (default: disabled; workflows with unconverted v10 terms always stay disabled)' })
|
|
90
92
|
.option('include-non-routing', { type: 'boolean', default: false, describe: 'Also migrate v10 rules with IsRouting=false (group-assignment rules)' })
|
|
91
93
|
.option('route-bot-groups-to-team', { type: 'boolean', default: false, describe: 'Route to the v20 team named after the v10 group even if the group had a v10 bot' })
|
|
94
|
+
.option('path-only-urls', { type: 'boolean', default: false, describe: 'Strip v10 URL terms to their path (demo-page testing only). Default keeps the host, like v10.' })
|
|
95
|
+
.option('page-team-availability', { type: 'boolean', default: true, describe: "Launcher availability follows the page's team like v10 (page-load Route to Team workflows + chat window flag). --no-page-team-availability to skip." })
|
|
92
96
|
.option('team-map', { type: 'string', describe: 'JSON: [{"v10GroupId":1,"v20TeamId":5},...] override auto-resolution for teams' })
|
|
93
97
|
.option('ai-config-map',{ type: 'string', describe: 'JSON: [{"v10GroupId":2,"v20AiConfigId":3},...] override auto-resolution for AI configs' }),
|
|
94
98
|
handler: runCommand(async (argv) => {
|
|
@@ -102,6 +106,8 @@ const migrateLivefluenceCommand = {
|
|
|
102
106
|
enable: argv.enable,
|
|
103
107
|
includeNonRouting: argv['include-non-routing'],
|
|
104
108
|
routeBotGroupsToTeam: argv['route-bot-groups-to-team'],
|
|
109
|
+
pathOnlyUrls: argv['path-only-urls'],
|
|
110
|
+
pageTeamAvailability: argv['page-team-availability'] !== false,
|
|
105
111
|
teamMappings: argv['team-map'] ? JSON.parse(argv['team-map']) : [],
|
|
106
112
|
aiConfigMappings: argv['ai-config-map'] ? JSON.parse(argv['ai-config-map']) : [],
|
|
107
113
|
};
|
|
@@ -82,6 +82,27 @@ async function listHandler(argv) {
|
|
|
82
82
|
render(data, 'Outbound activity');
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
async function volumeHandler(argv) {
|
|
86
|
+
const days = Math.min(90, Math.max(1, Number(argv.days ?? 30)));
|
|
87
|
+
const data = await request('GET', `/Marketing/OutboundActivity/Volume?days=${days}`);
|
|
88
|
+
const byDay = new Map();
|
|
89
|
+
for (const b of data?.buckets ?? []) {
|
|
90
|
+
const d = byDay.get(b.date) ?? { sent: 0, failed: 0 };
|
|
91
|
+
if (b.status === 'Failed') d.failed += b.count;
|
|
92
|
+
else if (b.status === 'Sent') d.sent += b.count;
|
|
93
|
+
byDay.set(b.date, d);
|
|
94
|
+
}
|
|
95
|
+
console.log(`\n${BOLD}Outbound volume, last ${days} days (campaign + broadcast)${RST}\n`);
|
|
96
|
+
if (data?.degradedSources?.length) {
|
|
97
|
+
console.log(`${YEL} ! Not counted: ${data.degradedSources.join(', ')}${RST}\n`);
|
|
98
|
+
}
|
|
99
|
+
for (const [date, d] of [...byDay.entries()].sort(([a], [b]) => a.localeCompare(b))) {
|
|
100
|
+
console.log(` ${date} ${GRN}sent ${d.sent}${RST} ${RED}failed ${d.failed}${RST}`);
|
|
101
|
+
}
|
|
102
|
+
if (!byDay.size) console.log(` ${DIM}No campaign or broadcast sends in this window.${RST}`);
|
|
103
|
+
console.log('');
|
|
104
|
+
}
|
|
105
|
+
|
|
85
106
|
async function contactHandler(argv) {
|
|
86
107
|
const email = String(argv.email || '').trim();
|
|
87
108
|
// The scoping identifier is required, never optional — an omitted email must never silently
|
|
@@ -112,6 +133,13 @@ export const outboundActivityCommand = {
|
|
|
112
133
|
.option('search', { describe: 'Match recipient or subject', type: 'string' }),
|
|
113
134
|
handler: listHandler,
|
|
114
135
|
})
|
|
136
|
+
.command({
|
|
137
|
+
command: 'volume',
|
|
138
|
+
describe: 'Daily sent vs failed counts for campaign and broadcast sends',
|
|
139
|
+
builder: yy => yy
|
|
140
|
+
.option('days', { describe: 'Window in days (1-90)', type: 'number', default: 30 }),
|
|
141
|
+
handler: volumeHandler,
|
|
142
|
+
})
|
|
115
143
|
.command({
|
|
116
144
|
command: 'contact <email>',
|
|
117
145
|
describe: 'Every email sent to ONE address, across all three send systems',
|
|
@@ -95,7 +95,7 @@ const SCRAPER_EXTRA = [
|
|
|
95
95
|
];
|
|
96
96
|
|
|
97
97
|
const LIVEFLUENCE = [
|
|
98
|
-
{ name: 'export', desc: 'Export V10 routing rules for a V10 site', opts: { 'v10-site-id': N('V10 site id', true), 'v20-site-id': N('V20 site id'), 'include-non-routing': B('Include non-routing rules') }, path: (a) => `DatabaseTool/V10Export/${a.v10SiteId}${qs({ v20SiteId: a.v20SiteId, includeNonRouting: a.includeNonRouting ? 'true' : undefined })}` },
|
|
98
|
+
{ name: 'export', desc: 'Export V10 routing rules for a V10 site', opts: { 'v10-site-id': N('V10 site id', true), 'v20-site-id': N('V20 site id'), 'include-non-routing': B('Include non-routing rules'), 'path-only-urls': B('Strip URL terms to path (demo testing only)') }, path: (a) => `DatabaseTool/V10Export/${a.v10SiteId}${qs({ v20SiteId: a.v20SiteId, includeNonRouting: a.includeNonRouting ? 'true' : undefined, pathOnlyUrls: a.pathOnlyUrls ? 'true' : undefined })}` },
|
|
99
99
|
{ name: 'create-teams', desc: 'Create V20 teams from V10 groups (use --dry-run first)', method: 'POST', needsYes: (a) => !a.dryRun, opts: { 'v10-site-id': N('V10 site id', true), 'v20-site-id': N('V20 site id', true), 'dry-run': B('Preview only'), 'group-names': S('Comma list of V10 group names') }, path: () => 'DatabaseTool/V10CreateTeams', body: (a) => ({ v10SiteId: a.v10SiteId, v20SiteId: a.v20SiteId, dryRun: !!a.dryRun, groupNames: csv(a.groupNames) ?? [] }) },
|
|
100
100
|
{ name: 'site-workflows-list', desc: 'List a site workflows', opts: { 'site-id': N('Site id', true) }, path: (a) => `DatabaseTool/SiteWorkflows/${a.siteId}` },
|
|
101
101
|
{ name: 'site-workflows-set-enabled', desc: 'Enable/disable workflows by id or name (use --dry-run first)', method: 'POST', needsYes: (a) => !a.dryRun, opts: { 'site-id': N('Site id', true), 'workflow-ids': S('Comma list of ids'), names: S('Comma list of names'), enabled: B('Enable (omit to disable)'), 'dry-run': B('Preview only'), 'force-partial': B('Allow partial match'), 'v10-site-id': N('V10 site id') }, path: () => 'DatabaseTool/SiteWorkflows/SetEnabled', body: (a) => ({ siteId: a.siteId, workflowIds: csvN(a.workflowIds) ?? [], names: csv(a.names) ?? [], enabled: !!a.enabled, dryRun: !!a.dryRun, forcePartial: !!a.forcePartial, v10SiteId: a.v10SiteId ?? null }) },
|
|
@@ -105,7 +105,7 @@ const LIVEFLUENCE = [
|
|
|
105
105
|
{ name: 'site-rules-set-enabled', desc: 'Enable/disable routing rules', method: 'POST', needsYes: (a) => !a.dryRun, opts: { 'site-id': N('Site id', true), 'rule-ids': S('Comma list of ids'), trigger: S('Trigger filter'), enabled: B('Enable (omit to disable)'), 'dry-run': B('Preview only') }, path: () => 'DatabaseTool/SiteRules/SetEnabled', body: (a) => ({ siteId: a.siteId, ruleIds: csvN(a.ruleIds) ?? [], trigger: a.trigger ?? null, enabled: !!a.enabled, dryRun: !!a.dryRun }) },
|
|
106
106
|
{ name: 'seed-url-rules', desc: 'Seed URL rules for an AI config', method: 'POST', needsYes: (a) => !a.dryRun, opts: { 'site-id': N('Site id', true), 'ai-config-id': N('AI config id', true), rules: S('Rules JSON or @file.json', true), 'dry-run': B('Preview only') }, path: () => 'DatabaseTool/V10SeedUrlRules', body: (a) => ({ siteId: a.siteId, aiConfigId: a.aiConfigId, dryRun: !!a.dryRun, rules: json(a.rules) }) },
|
|
107
107
|
{ name: 'conversion-advisor', desc: 'Advise on V10 to V20 conversion (apply with --apply --yes)', method: 'POST', needsYes: (a) => !!a.apply, opts: { 'v10-site-id': N('V10 site id'), 'v20-site-id': N('V20 site id', true), apply: B('Apply recommendations'), 'include-non-routing': B('Include non-routing'), intents: S('Intents JSON array') }, path: () => 'DatabaseTool/ConversionAdvisor', body: (a) => { const intents = json(a.intents); return { v10SiteId: intents?.length ? null : (a.v10SiteId ?? null), v20SiteId: a.v20SiteId, apply: !!a.apply, includeNonRouting: !!a.includeNonRouting, intents: intents ?? null }; } },
|
|
108
|
-
{ name: 'migrate', desc: 'Migrate V10 routing to V20 workflows (use --dry-run first)', method: 'POST', needsYes: (a) => !a.dryRun, opts: { 'v10-site-id': N('V10 site id', true), 'v20-site-id': N('V20 site id'), 'dry-run': B('Preview only'), enable: B('Enable created workflows'), 'include-non-routing': B('Include non-routing'), 'route-bot-groups-to-team': B('Route bot groups to team'), 'team-mappings': S('JSON or @file'), 'ai-config-mappings': S('JSON or @file') }, path: () => 'DatabaseTool/V10Migrate', body: (a) => ({ v10SiteId: a.v10SiteId, v20SiteId: a.v20SiteId ?? null, dryRun: !!a.dryRun, enable: !!a.enable, includeNonRouting: !!a.includeNonRouting, routeBotGroupsToTeam: !!a.routeBotGroupsToTeam, teamMappings: json(a.teamMappings) ?? [], aiConfigMappings: json(a.aiConfigMappings) ?? [] }) },
|
|
108
|
+
{ name: 'migrate', desc: 'Migrate V10 routing to V20 workflows (use --dry-run first)', method: 'POST', needsYes: (a) => !a.dryRun, opts: { 'v10-site-id': N('V10 site id', true), 'v20-site-id': N('V20 site id'), 'dry-run': B('Preview only'), enable: B('Enable created workflows'), 'include-non-routing': B('Include non-routing'), 'route-bot-groups-to-team': B('Route bot groups to team'), 'path-only-urls': B('Strip URL terms to path (demo testing only)'), 'page-team-availability': B('Launcher availability follows the page team like v10 (default on; --no-page-team-availability to skip)'), 'team-mappings': S('JSON or @file'), 'ai-config-mappings': S('JSON or @file') }, path: () => 'DatabaseTool/V10Migrate', body: (a) => ({ v10SiteId: a.v10SiteId, v20SiteId: a.v20SiteId ?? null, dryRun: !!a.dryRun, enable: !!a.enable, includeNonRouting: !!a.includeNonRouting, routeBotGroupsToTeam: !!a.routeBotGroupsToTeam, pathOnlyUrls: !!a.pathOnlyUrls, pageTeamAvailability: a.pageTeamAvailability !== false, teamMappings: json(a.teamMappings) ?? [], aiConfigMappings: json(a.aiConfigMappings) ?? [] }) },
|
|
109
109
|
];
|
|
110
110
|
|
|
111
111
|
const TABLES = {
|
|
@@ -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