quoxcli 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/README.md +2 -2
  3. package/bin/quox.js +19 -1
  4. package/bin/quoxon.js +6 -1
  5. package/lib/api/endpoints/admin.js +7 -0
  6. package/lib/api/endpoints/agent-attach.js +7 -0
  7. package/lib/api/endpoints/compliance.js +25 -0
  8. package/lib/api/endpoints/inbox.js +6 -0
  9. package/lib/api/endpoints/inboxq.js +19 -0
  10. package/lib/api/endpoints/index.js +2 -0
  11. package/lib/api/endpoints/mon.js +122 -0
  12. package/lib/api/endpoints/tools.js +13 -0
  13. package/lib/api/endpoints/v1.js +13 -0
  14. package/lib/commands/admin.js +35 -0
  15. package/lib/commands/agentAttach.js +15 -0
  16. package/lib/commands/approvals.js +193 -3
  17. package/lib/commands/ask.js +1 -1
  18. package/lib/commands/auth.js +64 -11
  19. package/lib/commands/backup.js +11 -4
  20. package/lib/commands/capabilities.js +3 -2
  21. package/lib/commands/chat.js +15 -0
  22. package/lib/commands/claude.js +4 -1
  23. package/lib/commands/compliance.js +109 -0
  24. package/lib/commands/connect.js +69 -0
  25. package/lib/commands/dev.js +6 -8
  26. package/lib/commands/doctor.js +22 -3
  27. package/lib/commands/evidence.js +2 -1
  28. package/lib/commands/gripe.js +24 -13
  29. package/lib/commands/inbox.js +37 -3
  30. package/lib/commands/inboxq.js +147 -0
  31. package/lib/commands/kuma.js +78 -5
  32. package/lib/commands/licenceLinkView.js +311 -0
  33. package/lib/commands/linkedin.js +19 -0
  34. package/lib/commands/loop.js +30 -3
  35. package/lib/commands/lucid.js +1 -0
  36. package/lib/commands/mail.js +161 -20
  37. package/lib/commands/memory.js +68 -4
  38. package/lib/commands/memorySync.js +158 -0
  39. package/lib/commands/mon.js +55 -144
  40. package/lib/commands/notes.js +29 -7
  41. package/lib/commands/notesSeal.js +259 -0
  42. package/lib/commands/objective.js +5 -2
  43. package/lib/commands/offload.js +2 -3
  44. package/lib/commands/plan.js +17 -0
  45. package/lib/commands/provider.js +29 -8
  46. package/lib/commands/qlarity.js +32 -1
  47. package/lib/commands/run.js +2 -1
  48. package/lib/commands/server.js +37 -0
  49. package/lib/commands/setup.js +127 -75
  50. package/lib/commands/skills.js +4 -1
  51. package/lib/commands/slot.js +49 -9
  52. package/lib/commands/status.js +92 -44
  53. package/lib/commands/tool.js +30 -0
  54. package/lib/commands/vault.js +6 -3
  55. package/lib/commands/walkthrough.js +14 -2
  56. package/lib/commands/watch.js +11 -2
  57. package/lib/commands/wazuh.js +824 -0
  58. package/lib/commands/wazuhIntake.js +317 -0
  59. package/lib/commands/wazuhReport.js +192 -0
  60. package/lib/commands/workflow.js +47 -4
  61. package/lib/commands/x.js +50 -0
  62. package/lib/core/announce.js +86 -0
  63. package/lib/core/auth.js +20 -2
  64. package/lib/core/callMe.js +118 -0
  65. package/lib/core/client.js +27 -1
  66. package/lib/core/commandRegistrars.js +8 -0
  67. package/lib/core/config.js +28 -2
  68. package/lib/core/confirm.js +68 -7
  69. package/lib/core/crossOrgApprovals.js +69 -0
  70. package/lib/core/errors.js +52 -1
  71. package/lib/core/governedSession.js +135 -5
  72. package/lib/core/inboxResolution.js +3 -2
  73. package/lib/core/loginGuard.js +73 -0
  74. package/lib/core/offload.js +37 -0
  75. package/lib/core/org-override.js +5 -1
  76. package/lib/core/output.js +1 -1
  77. package/lib/core/profileTrust.js +182 -0
  78. package/lib/core/quoxglyph.js +22 -1
  79. package/lib/core/router.js +14 -0
  80. package/lib/core/stepUpPrompt.js +99 -0
  81. package/lib/core/version.js +1 -1
  82. package/lib/core/walkthrough.js +9 -5
  83. package/lib/dragon/select.js +2 -2
  84. package/lib/quoxon/EXTENSIONS.md +142 -19
  85. package/lib/quoxon/api.js +185 -34
  86. package/lib/quoxon/app.js +1032 -152
  87. package/lib/quoxon/approvalBatch.js +117 -0
  88. package/lib/quoxon/approvalFacts.js +56 -2
  89. package/lib/quoxon/approvalSentence.js +8 -4
  90. package/lib/quoxon/approvalsView.js +69 -11
  91. package/lib/quoxon/autoOpen.js +94 -0
  92. package/lib/quoxon/backgroundWork.js +59 -0
  93. package/lib/quoxon/bang.js +1 -1
  94. package/lib/quoxon/capabilities.js +7 -2
  95. package/lib/quoxon/commandShort.js +7 -0
  96. package/lib/quoxon/commands.js +40 -10
  97. package/lib/quoxon/connect.js +5 -3
  98. package/lib/quoxon/deckLazy.js +58 -0
  99. package/lib/quoxon/destructive.js +35 -0
  100. package/lib/quoxon/dnd.js +71 -0
  101. package/lib/quoxon/dragonCompanion.js +37 -7
  102. package/lib/quoxon/dragonMoments.js +78 -0
  103. package/lib/quoxon/echo.js +1 -0
  104. package/lib/quoxon/events.js +43 -7
  105. package/lib/quoxon/extensions.js +398 -38
  106. package/lib/quoxon/gripeQueue.js +135 -0
  107. package/lib/quoxon/inboxView.js +125 -22
  108. package/lib/quoxon/keys.js +2 -2
  109. package/lib/quoxon/loopCard.js +5 -1
  110. package/lib/quoxon/loopCards.js +17 -8
  111. package/lib/quoxon/loopStream.js +20 -9
  112. package/lib/quoxon/mailView.js +71 -0
  113. package/lib/quoxon/main.js +20 -5
  114. package/lib/quoxon/markdown.js +1 -1
  115. package/lib/quoxon/model.js +15 -0
  116. package/lib/quoxon/neverAnswered.js +20 -0
  117. package/lib/quoxon/objects/away.js +43 -5
  118. package/lib/quoxon/onboarding/connectServer.js +162 -0
  119. package/lib/quoxon/onboarding/copy.js +6 -0
  120. package/lib/quoxon/onboarding/index.js +5 -43
  121. package/lib/quoxon/onboarding/probe.js +20 -1
  122. package/lib/quoxon/onboarding/view.js +16 -3
  123. package/lib/quoxon/orgSwitch.js +22 -0
  124. package/lib/quoxon/print.js +2 -0
  125. package/lib/quoxon/profileSwitch.js +7 -0
  126. package/lib/quoxon/promptHistory.js +3 -1
  127. package/lib/quoxon/render.js +63 -14
  128. package/lib/quoxon/roster.js +10 -5
  129. package/lib/quoxon/rosterSessions.js +44 -0
  130. package/lib/quoxon/screenContext.js +1 -1
  131. package/lib/quoxon/secretShape.js +86 -0
  132. package/lib/quoxon/slash/agents.js +2 -1
  133. package/lib/quoxon/slash/argSources.js +9 -2
  134. package/lib/quoxon/slash/args.js +4 -2
  135. package/lib/quoxon/slash/broadcast.js +18 -5
  136. package/lib/quoxon/slash/broadcastRun.js +13 -2
  137. package/lib/quoxon/slash/cliLeaves.json +63 -1
  138. package/lib/quoxon/slash/hatWalk.js +1 -1
  139. package/lib/quoxon/slash/palette.js +22 -1
  140. package/lib/quoxon/slash/paletteController.js +10 -4
  141. package/lib/quoxon/slash/restart.js +7 -4
  142. package/lib/quoxon/slash/stepUp.js +5 -5
  143. package/lib/quoxon/slash/stepUpCmds.js +74 -1
  144. package/lib/quoxon/slashSpinner.js +35 -0
  145. package/lib/quoxon/slotAttach.js +8 -0
  146. package/lib/quoxon/slotChat.js +17 -0
  147. package/lib/quoxon/slotFormat.js +1 -1
  148. package/lib/quoxon/slotOutbox.js +113 -0
  149. package/lib/quoxon/suggestCommand.js +1 -1
  150. package/lib/quoxon/term.js +25 -1
  151. package/lib/quoxon/transcript.js +2 -1
  152. package/lib/quoxon/welcome.js +1 -1
  153. package/lib/quoxon/whatsnew.js +1 -1
  154. package/lib/quoxon/whatsnew.jsonl +36 -0
  155. package/lib/server/installFlow.js +168 -0
  156. package/lib/server/status.js +15 -1
  157. package/lib/toolOutputShape.js +55 -0
  158. package/package.json +3 -2
  159. package/vendor/dragonlab/SOURCE +3 -3
  160. package/vendor/dragonlab/design/quoxperticus/v2/quoxperticus-master.svg +59 -0
  161. package/vendor/dragonlab/design/quoxperticus/v3/character.mjs +43 -0
  162. package/vendor/dragonlab/design/quoxperticus/v4/character.mjs +57 -0
  163. package/vendor/dragonlab/design/quoxperticus/v4/review.mjs +35 -0
  164. package/vendor/dragonlab/design/quoxperticus/v4/watch.mjs +56 -0
  165. package/vendor/dragonlab/design/vulcan/v1/character.mjs +34 -0
  166. package/vendor/dragonlab/design/vulcan/v1/vulcan-master.svg +57 -0
  167. package/vendor/dragonlab/design/vulcan/v2/character.mjs +39 -0
  168. package/vendor/dragonlab/design/vulcan/v3/character.mjs +41 -0
  169. package/vendor/dragonlab/design/vulcan/v3/review.mjs +35 -0
  170. package/vendor/dragonlab/design/vulcan/v3/watch.mjs +56 -0
  171. package/vendor/dragonlab/factory/svg-rig-contour.mjs +64 -0
  172. package/vendor/dragonlab/integration/companions-v1/characters.mjs +20 -0
  173. package/vendor/dragonlab/integration/companions-v1/quoxperticus.mjs +2 -0
  174. package/vendor/dragonlab/integration/companions-v1/view.mjs +1 -1
  175. package/vendor/dragonlab/integration/companions-v1/vulcan.mjs +2 -0
@@ -8,6 +8,9 @@ import { resolveEndpoint } from '../api/endpoints.js';
8
8
  import { QuoxApiError, QuoxValidationError } from '../core/errors.js';
9
9
  import { confirmDestructive } from '../core/confirm.js';
10
10
  import { passwordProblem } from '../quoxon/onboarding/finish.js';
11
+ import {
12
+ renderLinkCard, renderLinkedCard, linkedDetails, startWaiting, colorFor, animateFor,
13
+ } from './licenceLinkView.js';
11
14
 
12
15
  // The auth service's rule (services/auth/utils/passwordValidation.js), said up front.
13
16
  export const PASSWORD_POLICY = 'Passwords need at least 12 characters, with an uppercase letter, a lowercase letter, a number and a special character (for example - or !).';
@@ -348,93 +351,142 @@ export function registerSetupCommands(program, ctx) {
348
351
  interval,
349
352
  });
350
353
 
354
+ // QUOXON (owner 2026-11-05): a framed card with the code, the full
355
+ // link and a countdown, then a live waiting line on a TTY. Not a TTY
356
+ // (CI, logs): plain lines, no ANSI, nothing animated.
357
+ const term = ctx.term || process.stdout;
358
+ const format = program.opts().output;
359
+ const pretty = !json && (format === undefined || format === 'table');
360
+ const color = pretty && colorFor(term);
361
+ const verificationUrl = started.verification_url || 'https://quox.ai/link';
362
+ let waiting = null;
351
363
  if (!json) {
352
- printInfo(`Open ${started.verification_url || 'https://quox.ai/link'} and enter this code:`);
353
- console.log('');
354
- console.log(chalk.bold.cyan(` ${started.user_code}`));
355
- console.log('');
356
- printInfo(`The code is good for ${Math.round(expiresIn / 60)} minutes. Waiting for approval...`);
364
+ if (pretty) {
365
+ console.log(renderLinkCard({
366
+ userCode: started.user_code, url: verificationUrl, remainingMs: expiresIn * 1000, color, cols: term.columns || 80,
367
+ }));
368
+ if (term.isTTY) {
369
+ waiting = startWaiting({ term, deadline, totalMs: expiresIn * 1000, color, animate: animateFor(term) });
370
+ }
371
+ } else {
372
+ printInfo(`Open ${verificationUrl} and enter this code:`);
373
+ console.log('');
374
+ console.log(chalk.bold.cyan(` ${started.user_code}`));
375
+ console.log('');
376
+ printInfo(`The code is good for ${Math.round(expiresIn / 60)} minutes. Waiting for approval...`);
377
+ }
357
378
  }
358
-
359
- const pollEp = resolveEndpoint('setup.licensing.device.poll');
360
- let lastState = 'started';
361
-
362
- while (Date.now() < deadline) {
363
- await sleepFn(interval * 1000);
364
-
365
- let result;
366
- try {
367
- result = await client.post(pollEp.path, {
368
- service: pollEp.service,
369
- body: { device_code: deviceCode, interval },
370
- });
371
- } catch (err) {
372
- // 503 means quox.ai blipped, NOT that the activation died: the code
373
- // is still live upstream and the customer may still be approving it.
374
- // Anything else (409 seat_limit_reached, 403, 400) is terminal.
375
- if (err instanceof QuoxApiError && err.status === 503) {
376
- if (lastState !== 'unreachable') {
377
- emit({ state: 'unreachable', message: err.message });
378
- if (!json) printInfo('The licence server is unreachable right now. Still waiting...');
379
- lastState = 'unreachable';
379
+ try {
380
+ await pollUntilDone();
381
+ } finally {
382
+ if (waiting) waiting.stop();
383
+ }
384
+ return;
385
+
386
+ async function pollUntilDone() {
387
+ const pollEp = resolveEndpoint('setup.licensing.device.poll');
388
+ let lastState = 'started';
389
+
390
+ while (Date.now() < deadline) {
391
+ await sleepFn(interval * 1000);
392
+
393
+ let result;
394
+ try {
395
+ result = await client.post(pollEp.path, {
396
+ service: pollEp.service,
397
+ body: { device_code: deviceCode, interval },
398
+ });
399
+ } catch (err) {
400
+ // 503 means quox.ai blipped, NOT that the activation died: the code
401
+ // is still live upstream and the customer may still be approving it.
402
+ // Anything else (409 seat_limit_reached, 403, 400) is terminal.
403
+ if (err instanceof QuoxApiError && err.status === 503) {
404
+ if (lastState !== 'unreachable') {
405
+ emit({ state: 'unreachable', message: err.message });
406
+ if (waiting) waiting.note('licence server unreachable, still waiting');
407
+ else if (!json) printInfo('The licence server is unreachable right now. Still waiting...');
408
+ lastState = 'unreachable';
409
+ }
410
+ continue;
380
411
  }
381
- continue;
412
+ throw enrichLicenseError(err);
382
413
  }
383
- throw enrichLicenseError(err);
384
- }
385
414
 
386
- const state = result.state || 'pending';
415
+ const state = result.state || 'pending';
387
416
 
388
- if (state === 'slow_down') {
389
- interval = Number(result.interval) > 0 ? Number(result.interval) : interval + 5;
390
- } else if (Number(result.interval) > 0) {
391
- interval = Number(result.interval);
392
- }
417
+ if (state === 'slow_down') {
418
+ interval = Number(result.interval) > 0 ? Number(result.interval) : interval + 5;
419
+ } else if (Number(result.interval) > 0) {
420
+ interval = Number(result.interval);
421
+ }
393
422
 
394
- if (state !== lastState) {
395
- emit({ state, interval, ...(result.error ? { error: result.error } : {}) });
396
- lastState = state;
397
- }
423
+ if (state !== lastState) {
424
+ emit({ state, interval, ...(result.error ? { error: result.error } : {}) });
425
+ lastState = state;
426
+ }
398
427
 
399
- if (state === 'approved') {
400
- const lease = result.lease || {};
401
- emit({ state: 'approved', lease });
402
- if (!json) {
403
- formatDetail({
404
- license_id: lease.license_id || null,
405
- entitlements: lease.entitlements || [],
406
- lease_expires_at: lease.expires_at || null,
407
- }, { format: program.opts().output, title: 'Licence activated' });
408
- printSuccess('This instance is activated. No key was ever pasted into it.');
428
+ if (state === 'approved') {
429
+ const lease = result.lease || {};
430
+ // QUOXON (owner 2026-11-05): read the licence back through the
431
+ // route `quox licence status` uses, so the run NAMES what was
432
+ // linked (plan, plugins, seats). A failed read never hides the
433
+ // activation: the lease is the fallback, and the failure is said.
434
+ let status = null;
435
+ let readBackError = null;
436
+ if (json || pretty) {
437
+ try {
438
+ const readEp = resolveEndpoint('setup.licensing.entitlements.list');
439
+ status = await client.get(readEp.path, { service: readEp.service });
440
+ } catch (err) {
441
+ readBackError = err && err.message ? err.message : String(err);
442
+ }
443
+ }
444
+ const details = linkedDetails(lease, status, result);
445
+ // --json: the pre-existing { state, lease } plus an ADDITIVE `licence`.
446
+ emit({ state: 'approved', lease, licence: details });
447
+ if (waiting) { waiting.stop(); waiting = null; }
448
+ if (pretty) {
449
+ console.log(renderLinkedCard(details, {
450
+ color, cols: term.columns || 80, leaseExpiresAt: lease.expires_at || null,
451
+ profile: program.opts().profile || null, readBackError,
452
+ }));
453
+ } else if (!json) {
454
+ formatDetail({
455
+ license_id: lease.license_id || null,
456
+ entitlements: lease.entitlements || [],
457
+ lease_expires_at: lease.expires_at || null,
458
+ }, { format: program.opts().output, title: 'Licence activated' });
459
+ printSuccess('This instance is activated. No key was ever pasted into it.');
460
+ }
461
+ return;
409
462
  }
410
- return;
411
- }
412
463
 
413
- if (state === 'denied') {
414
- throw new QuoxApiError(403, 'access_denied',
415
- 'The activation was denied on quox.ai. Nothing was activated on this instance.');
416
- }
417
- if (state === 'expired') {
418
- throw new QuoxApiError(410, 'expired_token',
419
- 'The code expired before it was approved. Run `quox setup license link` again for a fresh one.');
420
- }
421
- if (state === 'consumed') {
422
- throw new QuoxApiError(409, 'consumed',
423
- 'That code was already used. Run `quox setup license link` again for a fresh one.');
424
- }
425
- if (state === 'activation_failed') {
426
- throw new QuoxApiError(502, result.error || 'activation_failed',
427
- `The approval landed but the licence could not be stored on this instance: ${result.message || result.error || 'unknown error'}. `
428
- + 'Run `quox setup license link` again.');
429
- }
430
- if (state === 'error') {
431
- throw new QuoxApiError(502, result.error || 'device_poll_failed',
432
- result.message || 'Device activation failed.');
464
+ if (state === 'denied') {
465
+ throw new QuoxApiError(403, 'access_denied',
466
+ 'The activation was denied on quox.ai. Nothing was activated on this instance.');
467
+ }
468
+ if (state === 'expired') {
469
+ throw new QuoxApiError(410, 'expired_token',
470
+ 'The code expired before it was approved. Run `quox setup license link` again for a fresh one.');
471
+ }
472
+ if (state === 'consumed') {
473
+ throw new QuoxApiError(409, 'consumed',
474
+ 'That code was already used. Run `quox setup license link` again for a fresh one.');
475
+ }
476
+ if (state === 'activation_failed') {
477
+ throw new QuoxApiError(502, result.error || 'activation_failed',
478
+ `The approval landed but the licence could not be stored on this instance: ${result.message || result.error || 'unknown error'}. `
479
+ + 'Run `quox setup license link` again.');
480
+ }
481
+ if (state === 'error') {
482
+ throw new QuoxApiError(502, result.error || 'device_poll_failed',
483
+ result.message || 'Device activation failed.');
484
+ }
433
485
  }
434
- }
435
486
 
436
- throw new QuoxApiError(410, 'expired_token',
437
- 'The code expired before it was approved. Run `quox setup license link` again for a fresh one.');
487
+ throw new QuoxApiError(410, 'expired_token',
488
+ 'The code expired before it was approved. Run `quox setup license link` again for a fresh one.');
489
+ }
438
490
  });
439
491
 
440
492
  license
@@ -84,6 +84,8 @@ export function registerSkillsCommands(program, ctx) {
84
84
  for (const it of Array.isArray(items) ? items : []) if (it && it.skill_id) active.set(it.skill_id, it.status || status);
85
85
  }
86
86
  rows = rows.map((r) => ({ ...r, review_status: active.get(r.id) || null, runnable: !active.has(r.id) }));
87
+ // Runnable first (stable): a skill that can run leads, so the first row is never one skill_view must refuse.
88
+ rows = [...rows.filter((r) => r.runnable), ...rows.filter((r) => !r.runnable)];
87
89
  } catch (err) {
88
90
  printWarning(`Skill review queue could not be read, so which skills can run is unknown: ${err.message}`);
89
91
  }
@@ -641,7 +643,8 @@ export function registerSkillsCommands(program, ctx) {
641
643
  try {
642
644
  const ep = resolveEndpoint('skills.sealed.create');
643
645
  const data = await client.post(ep.path, { service: ep.service, body });
644
- printSuccess(`Sealed. sealedId ${data.sealedId}`);
646
+ // the collector answers { sealed: {...}, evidence }; an older/flat body carries sealedId at the top
647
+ printSuccess(`Sealed. sealedId ${(data && data.sealed && data.sealed.sealedId) || (data && data.sealedId)}`);
645
648
  formatDetail(data, { format: program.opts().output, title: 'Sealed skill' });
646
649
  printInfo(SEALED_SECTION_G_SENTENCE);
647
650
  } catch (err) {
@@ -19,6 +19,7 @@ import { dirname, join } from 'node:path';
19
19
 
20
20
  import { formatDetail, formatOutput, printSuccess, printWarning, printInfo } from '../core/output.js';
21
21
  import { events, printEvent } from '../core/quoxglyph.js';
22
+ import { announce, announceOnFail } from '../core/announce.js';
22
23
  import { resolveEndpoint } from '../api/endpoints.js';
23
24
  import { QuoxApiError, QuoxNetworkError } from '../core/errors.js';
24
25
  import { resolveOrgId } from './helpers.js';
@@ -400,6 +401,23 @@ export function registerSlotCommands(program, ctx) {
400
401
  }
401
402
  }
402
403
 
404
+ // SLOT-FROM: the session name this process holds a slot under (held-slots.json lists it, or QUOX_SLOT
405
+ // names a held slot), sent as holder_session so the server's hold record stamps from_slot even when
406
+ // senderSlot() could not bind a live process. The server re-checks identity + session; never trusted.
407
+ function heldSessionFor(from) {
408
+ try {
409
+ const all = readHeldSlots();
410
+ const want = from ? String(from).toLowerCase() : null;
411
+ const bySlot = process.env.QUOX_SLOT ? all[String(process.env.QUOX_SLOT).trim()] : null;
412
+ if (bySlot && !bySlot.member && bySlot.session && (!want || String(bySlot.session).toLowerCase() === want)) return bySlot.session;
413
+ if (!want) return null;
414
+ const hit = Object.values(all).find((e) => e && !e.member && String(e.session || '').toLowerCase() === want);
415
+ return hit ? hit.session : null;
416
+ } catch {
417
+ return null;
418
+ }
419
+ }
420
+
403
421
  // P10: the collector recognises splinter members only via the ATTACH token.
404
422
  // When this Claude session is attached to an agent whose recorded slot is
405
423
  // `name`, send that token (same noAuth + Authorization pattern as
@@ -866,7 +884,7 @@ export function registerSlotCommands(program, ctx) {
866
884
  .option('--session <s>', 'session name to speak as (default: $QUOX_STREAM)')
867
885
  .option('--room', 'post as a joined room member (no hold needed); signed "session (person)" by the server')
868
886
  .option('--run <command>', 'ask the human to run ONE command in their own terminal (the text is why); the quox TUI shows it in full and runs it only on their y. Never run server-side')
869
- .action(async (name, textParts, options) => {
887
+ .action(announceOnFail('quoxslots', (name) => `say into ${name}`, async (name, textParts, options) => {
870
888
  auth.requireAuth();
871
889
  // SLOT-RUN: same rule as the collector (one line, max 2000, no control/bidi characters), checked before sending.
872
890
  if (options.run !== undefined) {
@@ -900,6 +918,8 @@ export function registerSlotCommands(program, ctx) {
900
918
  // A room post already has its address (the room), so it carries none.
901
919
  const fromSlot = options.room ? null : senderSlot(from);
902
920
  if (fromSlot) body.from_slot = fromSlot;
921
+ const heldAs = options.room ? null : heldSessionFor(from);
922
+ if (heldAs) body.holder_session = heldAs;
903
923
  // A freshly created slot gets its Matrix room a few seconds AFTER
904
924
  // checkout returns (provisioning is async), so a say straight after
905
925
  // checkout used to fail with 409 "no Matrix room yet" (slots audit
@@ -952,6 +972,7 @@ export function registerSlotCommands(program, ctx) {
952
972
  throw err;
953
973
  }
954
974
  }
975
+ announce('quoxslots', `said into ${name}`, { result: data?.presence?.state === 'listening' ? 'delivered, listening' : 'posted' });
955
976
  printSuccess(`Said into ${name}.`);
956
977
  if (!options.room && !fromSlot) {
957
978
  printWarning(`${from || 'This session'} holds no slot, so replies cannot reach it. Claim one: quox slot checkout <name> --create --session ${from || '<session>'}`);
@@ -962,7 +983,7 @@ export function registerSlotCommands(program, ctx) {
962
983
  reportHumanPresence(data?.human_presence);
963
984
  reportBridgeDelivery(data?.bridges);
964
985
  if (program.opts().output === 'json') formatDetail(data, { format: 'json' });
965
- });
986
+ }));
966
987
 
967
988
  // QUOXON-BROADCAST: one call fans a message out to every held slot in the org (or --slots).
968
989
  slot
@@ -972,24 +993,38 @@ export function registerSlotCommands(program, ctx) {
972
993
  .option('--slots <list>', 'comma-separated slot names instead of every held slot')
973
994
  .option('--priority <p>', 'normal or urgent', 'normal')
974
995
  .option('--ack', 'ask recipients to acknowledge with /ack <id>')
996
+ .option('--active', 'only sessions listening right now; dormant slots are skipped, not woken')
997
+ .option('--dry-run', 'with --active: print who would be reached and who is skipped dormant, send nothing')
975
998
  .option('--session <s>', 'session name to sign as (default: $QUOX_STREAM)')
976
- .action(async (textParts, options) => {
999
+ .action(announceOnFail('quoxslots', 'broadcast', async (textParts, options) => {
977
1000
  auth.requireAuth();
978
1001
  const parsed = parseBroadcastArgs([
979
- options.slots ? `--slots ${options.slots}` : '', `--priority ${options.priority}`, options.ack ? '--ack' : '', textParts.join(' '),
1002
+ options.slots ? `--slots ${options.slots}` : '', `--priority ${options.priority}`, options.ack ? '--ack' : '', options.active ? '--active' : '', options.dryRun ? '--dry-run' : '', textParts.join(' '),
980
1003
  ].filter(Boolean).join(' '));
981
1004
  if (!parsed.ok) throw new Error(parsed.message);
982
1005
  const from = options.session || process.env.QUOX_STREAM || null;
1006
+ const bcFromSlot = senderSlot(from);
1007
+ const bcHeldAs = heldSessionFor(from);
983
1008
  const ep = resolveEndpoint('v1.slots.broadcast');
984
1009
  const data = await client.post(ep.path, {
985
1010
  service: ep.service, retries: 0,
986
- body: { text: parsed.text, priority: parsed.priority, ack: parsed.ack, ...(parsed.slots ? { slots: parsed.slots } : {}), ...(from ? { from } : {}), org_id: resolveOrgId(auth, program) },
1011
+ body: { text: parsed.text, priority: parsed.priority, ack: parsed.ack, ...(parsed.active ? { active: true } : {}), ...(parsed.dryRun ? { dry_run: true } : {}), ...(parsed.slots ? { slots: parsed.slots } : {}), ...(from ? { from } : {}), ...(bcFromSlot ? { from_slot: bcFromSlot } : {}), ...(bcHeldAs ? { holder_session: bcHeldAs } : {}), org_id: resolveOrgId(auth, program) },
987
1012
  });
988
1013
  if (program.opts().output === 'json') return formatDetail(data, { format: 'json' });
1014
+ if (data?.dry_run) { // BROADCAST-ACTIVE --dry-run: nothing was sent
1015
+ const would = data.would_reach || []; const dorm = data.skipped_dormant || [];
1016
+ announce('quoxslots', 'broadcast to active', { result: `${would.length} would reach \u00B7 ${dorm.length} skipped dormant` });
1017
+ if (would.length) printInfo(` would reach: ${would.join(', ')}`);
1018
+ if (dorm.length) printInfo(` skipped dormant: ${dorm.join(', ')}`);
1019
+ return printInfo('Dry run: nothing was sent.');
1020
+ }
1021
+ if (parsed.active && data?.skipped_dormant) {
1022
+ announce('quoxslots', 'broadcast to active', { result: `${data.counts?.delivered || 0} reached \u00B7 ${data.skipped_dormant.length} skipped dormant` });
1023
+ } else announce('quoxslots', 'broadcast sent', { result: data?.id || data?.broadcast?.id });
989
1024
  for (const [line, kind] of broadcastSummary(data)) (kind === 'warn' ? printWarning : printInfo)(line);
990
1025
  reportHumanPresence(data?.human_presence);
991
1026
  return undefined;
992
- });
1027
+ }));
993
1028
 
994
1029
  slot
995
1030
  .command('broadcast-status')
@@ -1052,12 +1087,14 @@ export function registerSlotCommands(program, ctx) {
1052
1087
  }
1053
1088
  function reportBridgeDelivery(bridges) {
1054
1089
  if (!Array.isArray(bridges) || bridges.length === 0) return;
1055
- for (const b of bridges) {
1056
- const where = b.target ? `${b.platform} (${b.target})` : b.platform || 'bridge';
1090
+ // Two bridges that both report "still sending" with no platform/target printed two identical "bridge:" lines;
1091
+ // number them so each line says which bridge it is about.
1092
+ bridges.forEach((b, i) => {
1093
+ const where = b.target ? `${b.platform} (${b.target})` : b.platform || (bridges.length > 1 ? `bridge ${i + 1} of ${bridges.length}` : 'bridge');
1057
1094
  if (b.ok === true) printInfo(` rendered to ${where}`);
1058
1095
  else if (b.ok === null) printInfo(` ${where}: still sending, check \`quox slot read\``);
1059
1096
  else printWarning(` NOT rendered to ${where}: ${b.reason}`);
1060
- }
1097
+ });
1061
1098
  }
1062
1099
 
1063
1100
  async function readMessages(name, options) {
@@ -1134,6 +1171,7 @@ export function registerSlotCommands(program, ctx) {
1134
1171
  let cursor = options.since || null;
1135
1172
  let netFailures = 0;
1136
1173
  let authSince = null; // start of the current run of consecutive 401/403s
1174
+ let downSince = null; // start of the current outage, for the single resume line
1137
1175
 
1138
1176
  for (;;) {
1139
1177
  const query = { org_id: resolveOrgId(auth, program), timeout_ms: 50000 };
@@ -1145,6 +1183,7 @@ export function registerSlotCommands(program, ctx) {
1145
1183
  let data;
1146
1184
  try {
1147
1185
  data = await client.get(ep.path, { service: ep.service, ...attachAuthFor(name), query, timeout: 65000 });
1186
+ if (downSince !== null) { printInfo(`reconnected after ${Math.round((Date.now() - downSince) / 1000)}s`); downSince = null; }
1148
1187
  netFailures = 0;
1149
1188
  authSince = null;
1150
1189
  } catch (err) {
@@ -1182,6 +1221,7 @@ export function registerSlotCommands(program, ctx) {
1182
1221
  authSince = null;
1183
1222
  }
1184
1223
  netFailures += 1;
1224
+ if (downSince === null) downSince = Date.now();
1185
1225
  let delay = Math.min(2000 * 2 ** Math.min(netFailures - 1, 5), 60000);
1186
1226
  delay = Math.round(delay * (0.75 + Math.random() * 0.5));
1187
1227
  if (Number.isFinite(err.retryAfterMs)) delay = Math.min(Math.max(delay, err.retryAfterMs), 300000);
@@ -10,6 +10,8 @@
10
10
  import chalk from 'chalk';
11
11
  import { emitCliEvent } from '../core/aee.js';
12
12
  import { resolveEndpoint } from '../api/endpoints.js';
13
+ import { probeService } from './watch.js';
14
+ import { joinServiceUrl } from '../core/config.js';
13
15
 
14
16
  const STATUS_ICON = {
15
17
  ok: chalk.green('●'),
@@ -21,13 +23,66 @@ function statusDot(status) {
21
23
  return STATUS_ICON[status] || chalk.dim('○');
22
24
  }
23
25
 
26
+ const OK_STATES = new Set(['ok', 'healthy', 'up']);
27
+
28
+ /**
29
+ * Health percentage computed from the same data the screen shows (services plus
30
+ * fleet agents), so it can never say 100% beside "1 degraded, 1 down".
31
+ * Returns null when there is nothing to compute from.
32
+ */
33
+ export function computeHealth(data) {
34
+ let total = 0;
35
+ let good = 0;
36
+ for (const s of Object.values(data?.services || {})) {
37
+ total += 1;
38
+ if (OK_STATES.has(s?.status)) good += 1;
39
+ }
40
+ const f = data?.fleet;
41
+ if (f && f.total) {
42
+ total += f.total;
43
+ good += Math.min(f.total, f.healthy || 0);
44
+ }
45
+ if (!total) return typeof data?.score === 'number' ? data.score : null;
46
+ return Math.round((100 * good) / total);
47
+ }
48
+
49
+ /**
50
+ * Get status without letting one slow source sink the verb: the aggregate and a
51
+ * set of quick direct service probes run in parallel. Aggregate answers -> full
52
+ * result. Aggregate fails but probes answer -> partial result (exit 0). Nothing
53
+ * answers -> error object (exit 1).
54
+ */
55
+ export async function resolveStatus({ aggregate, probes }) {
56
+ const [agg, prb] = await Promise.allSettled([aggregate(), probes()]);
57
+ const probeMap = prb.status === 'fulfilled' ? prb.value : {};
58
+ if (agg.status === 'fulfilled' && agg.value) {
59
+ return { exitCode: 0, data: { ...agg.value, partial: false, sources: { aggregate: { status: 'ok' } } } };
60
+ }
61
+ const message = agg.reason?.message || 'no answer';
62
+ const sources = {
63
+ aggregate: { status: 'failed', error: message },
64
+ probes: { status: Object.values(probeMap).some((p) => p.status === 'healthy') ? 'ok' : 'failed' },
65
+ };
66
+ const services = {};
67
+ for (const [name, p] of Object.entries(probeMap)) {
68
+ services[name] = { status: p.status === 'healthy' ? 'ok' : p.status === 'down' ? 'down' : 'degraded', latency_ms: p.latency_ms ?? null };
69
+ }
70
+ if (sources.probes.status !== 'ok') {
71
+ return { exitCode: 1, data: { error: 'collector_unavailable', message, sources } };
72
+ }
73
+ return { exitCode: 0, data: { partial: true, degraded: true, score: null, timestamp: new Date().toISOString(), services, sources } };
74
+ }
75
+
24
76
  function renderPulse(data) {
25
77
  const lines = [];
26
78
 
27
79
  // Header
28
- const scoreColor = data.score >= 90 ? chalk.green : data.score >= 70 ? chalk.yellow : chalk.red;
80
+ const score = computeHealth(data);
81
+ const scoreColor = score >= 90 ? chalk.green : score >= 70 ? chalk.yellow : chalk.red;
82
+ const scoreText = score == null ? chalk.yellow('Health: partial') : scoreColor(`Health: ${score}%`);
29
83
  lines.push('');
30
- lines.push(chalk.bold(` QUOX PLATFORM STATUS`) + chalk.dim(` ${scoreColor(`Health: ${data.score}%`)} ${data.timestamp || ''}`));
84
+ lines.push(chalk.bold(` QUOX PLATFORM STATUS`) + chalk.dim(` ${scoreText} ${data.timestamp || ''}`));
85
+ if (data.partial) lines.push(chalk.yellow(` Partial: the full status did not answer in time (${data.sources?.aggregate?.error || 'no answer'}); showing live service checks only.`));
31
86
  lines.push(chalk.dim(' ' + '─'.repeat(60)));
32
87
 
33
88
  // Services
@@ -43,7 +98,7 @@ function renderPulse(data) {
43
98
  // Sessions
44
99
  const s = data.sessions || {};
45
100
  const providers = Object.entries(s.providers || {}).map(([k, v]) => `${v} ${k}`).join(', ');
46
- lines.push(` Sessions ${s.active || 0} active ${providers ? `(${providers})` : ''} ${chalk.dim(`$${(s.cost_today_usd || 0).toFixed(2)} today`)}`);
101
+ lines.push(` Sessions ${s.active || 0} active (usage sessions; "quox active" lists workers) ${providers ? `(${providers})` : ''} ${chalk.dim(`$${(s.cost_today_usd || 0).toFixed(2)} today`)}`);
47
102
 
48
103
  // Workflows
49
104
  const w = data.workflows || {};
@@ -78,60 +133,53 @@ function renderPulse(data) {
78
133
  }
79
134
 
80
135
  export function registerStatusCommand(program, ctx) {
81
- const { client } = ctx;
136
+ const { client, config } = ctx;
82
137
 
83
138
  program
84
139
  .command('status')
85
140
  .description('Show platform health and status overview')
141
+ .addHelpText('after', '\nAdd --json for machine output. If the full status is slow, a partial answer (live service checks, partial: true) is returned with exit 0; only a total failure exits 1 with an error object.')
86
142
  .action(async (opts, cmd) => {
87
143
  const outputFormat = cmd.parent?.opts()?.output || 'table';
88
144
  const isJson = outputFormat === 'json' || cmd.parent?.opts()?.json;
89
145
 
90
- try {
91
- // fleet #602: this used to pass noAuth: true, which suppressed the
92
- // Authorization header the client would otherwise attach. The TUI's
93
- // useHealth/HealthView poll this same endpoint WITH the normal client
94
- // auth, as does a comparable authenticated route (backup.js).
95
- // (monitoring.js's `health` verb had the identical noAuth bug — fixed
96
- // in the same change.) Dropping noAuth here matches that pattern: the
97
- // request still works
98
- // for a logged-out session (client.js sends no Authorization header
99
- // when there's nothing stored), but a logged-in session's token now
100
- // actually reaches the collector instead of being withheld.
101
- const data = await client.get(resolveEndpoint('v1.health.aggregate.list').path, {
102
- service: resolveEndpoint('v1.health.aggregate.list').service,
103
- timeout: 15000, // #930: the aggregate fans out to several services; 5s was too tight under load
104
- });
105
-
106
- if (isJson) {
107
- console.log(JSON.stringify(data, null, 2));
108
- } else {
109
- console.log(renderPulse(data));
110
- }
146
+ const ep = resolveEndpoint('v1.health.aggregate.list');
147
+ const names = ['auth', 'memory', 'collector', 'quoxflow', 'files'];
148
+ const { exitCode, data } = await resolveStatus({
149
+ // fleet #602: the normal client auth applies (no noAuth). #930: the aggregate fans out to
150
+ // several services; it gets 8s here because direct probes cover a slow answer.
151
+ aggregate: () => client.get(ep.path, { service: ep.service, timeout: 8000 }),
152
+ probes: async () => {
153
+ const out = await Promise.all(names.map(async (n) => {
154
+ try {
155
+ return [n, await probeService(joinServiceUrl(config.getServiceUrl(n), '/health').href, fetch, 3000)];
156
+ } catch (err) {
157
+ return [n, { status: 'down', reason: err.message }];
158
+ }
159
+ }));
160
+ return Object.fromEntries(out);
161
+ },
162
+ });
163
+
164
+ if (isJson) {
165
+ console.log(JSON.stringify(data, null, 2));
166
+ } else if (data.error) {
167
+ console.log('');
168
+ console.log(chalk.red(' Platform status unavailable'));
169
+ console.log(chalk.dim(` Collector not reachable: ${data.message}`));
170
+ console.log('');
171
+ } else {
172
+ console.log(renderPulse(data));
173
+ }
111
174
 
175
+ if (!data.error) {
112
176
  emitCliEvent(client, {
113
177
  command: 'status',
114
178
  intent: 'quox.cli.status',
115
- payload: { score: data.score, services: Object.keys(data.services || {}).length },
179
+ payload: { score: computeHealth(data), services: Object.keys(data.services || {}).length, partial: Boolean(data.partial) },
116
180
  });
117
- } catch (err) {
118
- if (isJson) {
119
- console.log(JSON.stringify({ error: 'collector_unavailable', message: err.message }));
120
- } else {
121
- console.log('');
122
- console.log(chalk.red(' Platform status unavailable'));
123
- console.log(chalk.dim(` Collector not reachable: ${err.message}`));
124
- console.log('');
125
- }
126
- // fleet #602: a real request failure (network error, non-2xx from
127
- // the collector) was printing the message above and still exiting
128
- // 0, hiding the failure from scripts/CI that check the exit code.
129
- // client.get only reaches this catch on an actual error (thrown
130
- // QuoxApiError / QuoxNetworkError / QuoxAuthError, see
131
- // lib/core/client.js) — never on a successful 2xx — so it's safe to
132
- // fail the process here without risking a false failure on a
133
- // legitimately-empty-but-200 status payload.
134
- process.exitCode = 1;
135
181
  }
182
+ // Only a total failure exits non-zero; a partial answer is still an answer.
183
+ if (exitCode) process.exitCode = exitCode;
136
184
  });
137
185
  }
@@ -199,6 +199,8 @@ export function registerToolCommands(program, ctx) {
199
199
  // success on failure. A HELD (pending) call awaits a human, so it stays 0.
200
200
  const failed = failedOf(data);
201
201
  if (failed && !(data && data.pending)) process.exitCode = 1;
202
+ // A held call exits 0 (chat relies on it) but must not read as a success: say so on stderr.
203
+ { const heldId = data && data.pending && (data.approvalId || (data._approval && data._approval.id)); if (heldId) console.error(`HELD, not run: approval ${heldId}`); }
202
204
 
203
205
  if (program.opts().output === 'json') {
204
206
  console.log(JSON.stringify(shown, null, 2));
@@ -225,6 +227,34 @@ export function registerToolCommands(program, ctx) {
225
227
  });
226
228
  printSuccess('Tool installed.');
227
229
  });
230
+
231
+ // CLI-COV 2026-11-05: `tool list` shows the org's own tool definitions, never catalog installations, so
232
+ // an install had no CLI read-back and no undo. These read and soft-disable the tool_installations row.
233
+ tool
234
+ .command('installed')
235
+ .description('List catalog tools installed in this organization (what `tool install` added)')
236
+ .action(async () => {
237
+ auth.requireAuth();
238
+ const ep = resolveEndpoint('tools.installed');
239
+ const data = await client.get(ep.path, { service: ep.service });
240
+ formatOutput({
241
+ columns: ['tool_id', 'name', 'category', 'enabled', 'installed_at'],
242
+ headers: ['Tool ID', 'Name', 'Category', 'Enabled', 'Installed'],
243
+ rows: (data && data.installations) || [],
244
+ }, { format: program.opts().output });
245
+ });
246
+
247
+ tool
248
+ .command('uninstall')
249
+ .description('Disable a catalog tool installed with `tool install` (soft: the row is kept, marked disabled)')
250
+ .argument('<toolId>', 'catalog tool_id, as `tool installed` lists it')
251
+ .action(async (toolId) => {
252
+ auth.requireAuth();
253
+ const ep = resolveEndpoint('tools.uninstall-from-scope', { toolId });
254
+ const data = await client.delete(ep.path, { service: ep.service });
255
+ if (data && data.removed) printSuccess(`Tool ${toolId} uninstalled (disabled for this organization).`);
256
+ else console.log(`Tool ${toolId} was not installed in this organization; nothing changed.`);
257
+ });
228
258
  }
229
259
 
230
260
  /**