Rebrand NetAnalyzer -> StoreHealthAnalyzer and consolidate the store
reporting surface into a single `st [number]` command with focused
sub-modes.
Commands
- st [number] - general info (SIW + brands + Meraki net link)
- st [number] network - switches, APs, store server
- st [number] pos - registers, payment terminals, customer display
- st [number] ios - MDM-tracked iOS hardware
- st [number] phone - wired 78xx + DECT basestations/handsets with
registration state, extensions and main DID
- st [number] av - Atlas AMPs + MDM-tracked Apple TVs, video
walls, music players, LED displays
- Removed `analyze` in favor of the unified `st` surface
Integrations
- integrations/webex: Service App OAuth with rotating refresh tokens,
seed + cleanup scripts, tokens/ storage (git-ignored)
- integrations/atlas: Xyte client + cached device discovery keyed on
zero-padded 6-digit store numbers, cold-cache failure -> unavailable
banner instead of a misleading empty result
- services/webexPhone, services/webexService, services/avService: shape
raw upstream data into the report layer's contract
- utils/merakiMatcher: FQDN hostname extraction so payment terminals
match Meraki descriptions; case-insensitive lookup
- utils/chunkReport: split long markdown replies at 7000-char boundaries
Reliability / ops
- server.js: awaited framework.stop() + 8s hard-kill timer so nodemon /
Docker restarts don't leak WDM device registrations ("excessive device
registrations")
- nodemon.json: SIGINT so the graceful path always runs
- scripts/cleanupWebexDevices.js: one-shot WDM cleanup utility
- Group-space routing: hears() regexes tolerate the leading @BotName
prefix Webex prepends to mentions
- Replaced HTML-unsafe <number> placeholders with [number] in all help
strings
Remote agent containerization
- docker/remote-agent/: multi-stage node:22-alpine image, non-root user,
tini for signal handling, minimal deps (ws/axios/dotenv)
- docker/remote-agent/package.sh: docker buildx build defaulting to
linux/amd64 (with override), saves image + assembles deploy/ + writes
SHA256 + zips for offline transfer
- docker/remote-agent/deploy/: runtime docker-compose.yml, install.sh
with platform sanity check, remote-host README
- .dockerignore + .gitignore updates for build artifacts and dist bundles
- npm run agent:package convenience script
Cleanup
- Dropped storeHealth.js / HealthReport.js and their tests/mocks in favor
of the shared storeDetail pipeline
- Store model handles null SIW records gracefully; toSummary always
ends with a newline so the Meraki link sits on its own line
Tests
- 144 tests across 14 suites passing; new coverage for atlasClient,
atlasDevices, avService, avCategory classification, webexPhone,
webexServiceAppAuth, storeDetail integration, siw, chunkReport and
the updated meraki matcher
Co-authored-by: Cursor <cursoragent@cursor.com>
55 lines
1.8 KiB
JavaScript
55 lines
1.8 KiB
JavaScript
/**
|
|
* Split a markdown report into Webex-message-sized chunks.
|
|
*
|
|
* Webex caps message bodies at ~7439 chars; we round down to 7000 to leave
|
|
* headroom for the bot framework and any wrapping the client may add.
|
|
*
|
|
* Strategy:
|
|
* 1. If the whole report fits, return it as a single chunk.
|
|
* 2. Otherwise, prefer breaking on section boundaries (`\n\n` immediately
|
|
* followed by `**`, which is how every section header in our reports is
|
|
* delimited). This keeps markdown intact across chunks.
|
|
* 3. If a single section is itself larger than the limit, fall back to a
|
|
* hard slice on the limit so we never lose data.
|
|
*/
|
|
|
|
const DEFAULT_LIMIT = 7000;
|
|
|
|
function chunkReport(report, maxLen = DEFAULT_LIMIT) {
|
|
if (!report) return [];
|
|
|
|
const trimmed = report.trim();
|
|
if (trimmed.length <= maxLen) return [trimmed];
|
|
|
|
// Split on `\n\n**` but keep the `**` (consume only the leading `\n\n`).
|
|
const sections = trimmed.split(/\n\n(?=\*\*)/);
|
|
const sectionChunks = [];
|
|
let current = '';
|
|
|
|
for (const section of sections) {
|
|
const candidate = current ? `${current}\n\n${section}` : section;
|
|
if (candidate.length > maxLen && current) {
|
|
sectionChunks.push(current);
|
|
current = section;
|
|
} else {
|
|
current = candidate;
|
|
}
|
|
}
|
|
if (current) sectionChunks.push(current);
|
|
|
|
// Hard-split any chunk still over the limit (rare — only happens if one
|
|
// section by itself exceeds maxLen, e.g. a store with hundreds of clients).
|
|
const finalChunks = [];
|
|
for (const c of sectionChunks) {
|
|
if (c.length <= maxLen) {
|
|
finalChunks.push(c);
|
|
} else {
|
|
for (let i = 0; i < c.length; i += maxLen) {
|
|
finalChunks.push(c.slice(i, i + maxLen));
|
|
}
|
|
}
|
|
}
|
|
return finalChunks;
|
|
}
|
|
|
|
module.exports = { chunkReport, DEFAULT_LIMIT };
|