FN-8424: route CLI chat replies through inbox mail

Route agent replies to the correct CLI or dashboard mailbox with bounded polling deadlines.

- add reply-parent routing validation and CLI/dashboard inbox selection
- preserve named mailbox conversations while handling per-message reply deadlines
- document chat and inbox interfaces and cover deadline and routing regressions

Files changed:
 .changeset/fn-8424-cli-chat-reply-routing.md       |   7 +
 docs/agents.md                                     |  20 +-
 docs/cli-reference.md                              |  29 +-
 packages/cli/src/bin.ts                            |  15 +-
 packages/cli/src/commands/__tests__/chat.test.ts   | 262 +++++++++---------
 .../cli/src/commands/__tests__/message.test.ts     |  12 +
 packages/cli/src/commands/chat.ts                  | 293 ++++++++++++---------
 packages/cli/src/commands/message.ts               |  18 +-
 ...tools-send-message-recipient-validation.test.ts |  86 +++++-
 packages/engine/src/agent-heartbeat-prompts.ts     |   8 +-
 packages/engine/src/agent-tools.ts                 |  71 +++--
 11 files changed, 523 insertions(+), 298 deletions(-)

Fusion-Task-Id: FN-8424

Fusion-Task-Lineage: 28d0ef88-717e-4f39-8880-64d2fef94706

Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
This commit is contained in:
gsxdsm
2026-07-20 11:26:08 -07:00
parent 00891c225f
commit 3962222863
11 changed files with 527 additions and 302 deletions

View File

@@ -448,13 +448,14 @@ PR:
Export Fusion agents to an Agent Companies package directory
(agent skills assigned via metadata.skills affect execution-time tools)
fn agent mailbox <id> View an agent's mailbox
fn message inbox List inbox messages
fn message inbox [--user <cli|dashboard>]
List CLI or dashboard operator inbox messages
fn message outbox List sent messages
fn message send <agent-id> <msg> Send a message to an agent
fn message read <id> Read a specific message
fn message delete <id> Delete a message
fn chat <agent-id> [message…] [--once] [--non-interactive] [--poll-ms <n>] [--conversation-id <id>]
Named mailbox conversation; delivers to agent inbox (not a chat room)
fn chat <agent-id> [message…] [--once] [--non-interactive] [--poll-ms <n>] [--reply-timeout-ms <n>] [--conversation-id <id>]
Named mailbox conversation with deadline-bounded inbox replies
fn backup --create Create a database backup immediately
fn backup --list List all database backups
fn backup --restore <file> Restore database from a backup file
@@ -2069,7 +2070,12 @@ async function main() {
const subcommand = args[1];
switch (subcommand) {
case "inbox": {
await runMessageInbox(projectName);
const inboxUser = getFlagValue(args.slice(2), "--user");
if (inboxUser !== undefined && inboxUser !== "cli" && inboxUser !== "dashboard") {
console.error("Usage: fn message inbox [--user <cli|dashboard>]");
process.exit(1);
}
await runMessageInbox(projectName, inboxUser);
break;
}
case "outbox": {
@@ -2119,6 +2125,7 @@ async function main() {
once: parsed.once,
nonInteractive: parsed.nonInteractive,
pollIntervalMs: parsed.pollIntervalMs,
replyTimeoutMs: parsed.replyTimeoutMs,
conversationId: parsed.conversationId,
input,
});