1212
1313import * as path from "node:path" ;
1414import type { CommsStore } from "./comms-store.js" ;
15- import type { CommsAction , DeliveryEvent , Visibility } from "./types.js" ;
15+ import type {
16+ CommsAction ,
17+ DeliveryEvent ,
18+ StreamingBehavior ,
19+ Visibility ,
20+ } from "./types.js" ;
1621import { z } from "zod" ;
1722
1823// ---------------------------------------------------------------------------
@@ -80,6 +85,7 @@ export const MCP_TOOL_PARAMS = z.object({
8085 id : z . string ( ) . optional ( ) ,
8186 meshVisibility : MeshVisibilityEnum . optional ( ) ,
8287 connectionId : z . string ( ) . optional ( ) ,
88+ streamingBehavior : z . enum ( [ "steer" , "followUp" , "info" ] ) . optional ( ) ,
8389} ) ;
8490
8591export type ToolParams = z . infer < typeof MCP_TOOL_PARAMS > ;
@@ -156,6 +162,8 @@ export function buildAction(params: Record<string, unknown>): CommsAction {
156162 content : p . content ,
157163 } ;
158164 if ( p . replyTo !== undefined ) send . replyTo = p . replyTo ;
165+ if ( p . streamingBehavior !== undefined )
166+ send . streamingBehavior = p . streamingBehavior ;
159167 return send ;
160168 }
161169 if ( p . room !== undefined ) {
@@ -165,17 +173,33 @@ export function buildAction(params: Record<string, unknown>): CommsAction {
165173 content : p . content ,
166174 } ;
167175 if ( p . replyTo !== undefined ) send . replyTo = p . replyTo ;
176+ if ( p . streamingBehavior !== undefined )
177+ send . streamingBehavior = p . streamingBehavior ;
168178 return send ;
169179 }
170180 throw new BuildActionError ( "send" , "target" ) ;
171181 }
172182 case "dm" : {
173183 if ( p . content === undefined ) throw new BuildActionError ( "dm" , "content" ) ;
174184 if ( p . target !== undefined ) {
175- return { action : "dm" , target : p . target , content : p . content } ;
185+ const dm : CommsAction & { action : "dm" } = {
186+ action : "dm" ,
187+ target : p . target ,
188+ content : p . content ,
189+ } ;
190+ if ( p . streamingBehavior !== undefined )
191+ dm . streamingBehavior = p . streamingBehavior ;
192+ return dm ;
176193 }
177194 if ( p . agent !== undefined ) {
178- return { action : "dm" , target : p . agent , content : p . content } ;
195+ const dm : CommsAction & { action : "dm" } = {
196+ action : "dm" ,
197+ target : p . agent ,
198+ content : p . content ,
199+ } ;
200+ if ( p . streamingBehavior !== undefined )
201+ dm . streamingBehavior = p . streamingBehavior ;
202+ return dm ;
179203 }
180204 throw new BuildActionError ( "dm" , "target" ) ;
181205 }
@@ -314,16 +338,32 @@ export function buildAction(params: Record<string, unknown>): CommsAction {
314338 }
315339}
316340
341+ // ---------------------------------------------------------------------------
342+ // extractStreamingBehavior — pull hint from message envelope if present
343+ // ---------------------------------------------------------------------------
344+
345+ export function extractStreamingBehavior (
346+ event : DeliveryEvent ,
347+ ) : StreamingBehavior | undefined {
348+ if ( event . type === "dm" || event . type === "room_message" ) {
349+ return event . message . streamingBehavior ;
350+ }
351+ return undefined ;
352+ }
353+
317354// ---------------------------------------------------------------------------
318355// formatDeliveryEvent — DeliveryEvent → human-readable string
319356// ---------------------------------------------------------------------------
320357
321358export function formatDeliveryEvent ( event : DeliveryEvent ) : string {
359+ const hint = extractStreamingBehavior ( event ) ;
360+ const pfx =
361+ hint === "steer" ? "[STEER] " : hint === "followUp" ? "[FOLLOWUP] " : "" ;
322362 switch ( event . type ) {
323363 case "room_message" :
324- return `[${ event . message . room } ] ${ event . message . from } : ${ event . message . content } ` ;
364+ return `${ pfx } [${ event . message . room } ] ${ event . message . from } : ${ event . message . content } ` ;
325365 case "dm" :
326- return `DM from ${ event . message . from } : ${ event . message . content } ` ;
366+ return `${ pfx } DM from ${ event . message . from } : ${ event . message . content } ` ;
327367 case "room_invite" : {
328368 const desc = event . roomDescription ? ` — ${ event . roomDescription } ` : "" ;
329369 const who = event . fromCwd
0 commit comments