/** * The destination a message carries: where the answer to it goes * (message-routing audit 2026-10-18, invariant). * * Every input an agent answers names its route: an owner message (its * conversation and thread), a work item, or another agent. The route of the * input an agent is working from is copied onto everything it sends on: * the `[MESSAGE from …]` header of `send-message`, the `parentRoute` of a * work item it delegates, and the `[RESULT]` relay its delegate's answer * comes back with. So the owner's thread travels across every agent hop, * and the final answer lands where the owner asked, without the harness * guessing "the newest owner turn" or "the newest work item". * * Pure helpers: the text token, parsing it back, and the reply command that * answers a route. * * @module services/orc/message-route */ import type { TurnTrigger } from '../trace/turn-trigger.js'; import type { TurnOrigin } from './orc-reply-route.service.js'; /** Where the answer to a message goes. */ export type MessageRoute = /** A work item: its origin decides (owner thread, ticket thread, delegator, …) */ { kind: 'work-item'; workItemId: string; } /** An owner message: its conversation and thread (Slack thread key or chat-v2 thread root) */ | { kind: 'owner'; conversationId: string; thread?: string; }; /** * Shape check. * * @param value - Anything * @returns True for a {@link MessageRoute} */ export declare function isMessageRoute(value: unknown): value is MessageRoute; /** * The text token for a route, e.g. `{route: owner room-1 thread C0A:1.2}`. * Text survives every queue a message may wait in, and the harness reads * it back with {@link parseRouteToken}. * * @param route - The route * @returns The token * * @example * ```typescript * formatRouteToken({ kind: 'work-item', workItemId: 'wi-1' }); // '{route: work-item wi-1}' * ``` */ export declare function formatRouteToken(route: MessageRoute): string; /** * The route a text carries (the first token in it). * * @param text - Delivered text * @returns The route, or null when the text carries none */ export declare function parseRouteToken(text: string): MessageRoute | null; /** * The reply command that answers a route. * * @param route - The route * @returns An English command line */ export declare function replyCommandFor(route: MessageRoute): string; /** * A route in words, for notes to agents. * * @param route - The route * @returns E.g. `work item wi-1` / `the owner's thread C0A:1.2 in conversation room-1` */ export declare function describeRoute(route: MessageRoute): string; /** * Whether two routes name the same place. * * @param a - Route * @param b - Route * @returns True when equal */ export declare function sameRoute(a: MessageRoute | null | undefined, b: MessageRoute | null | undefined): boolean; /** A place a post landed in (or is expected in). */ export interface PostPlace { /** chat-v2 conversation */ conversationId?: string; /** Thread in it: Slack thread key or chat-v2 thread root id */ thread?: string; /** Slack channel */ slackChannelId?: string; /** Slack thread ts (undefined: top level) */ threadTs?: string; } /** Outcome of {@link comparePostPlace}. */ export type RouteCheckOutcome = 'match' | 'mismatch' | 'unknown'; /** * Compare where a post landed with where the request it answers came from * (the regression check of the routing invariant). Places are compared on * the Slack thread when both know one, else on the chat conversation and * thread; anything the two do not both know is `unknown`, never a mismatch. * * @param expected - The originating request's place * @param landed - Where the post landed * @returns The outcome */ export declare function comparePostPlace(expected: PostPlace | null | undefined, landed: PostPlace | null | undefined): RouteCheckOutcome; /** * The place an owner route names. * * @param route - An owner route * @returns Its place */ export declare function placeOfOwnerRoute(route: Extract): PostPlace; /** * The route of what an agent is answering, from its latest routed trigger * (turn-trigger.ts `routedTrigger`): the owner message (with the thread its * turn origin knows), the route an agent message or result carries, or the * work item a dispatch handed over. This is what the agent's own messages * carry onward. * * @param trigger - The agent's latest routed trigger, or null * @param origin - Its turn origin (the thread of the owner message), if any * @returns The route, or null when the input names none */ export declare function routeOfTrigger(trigger: TurnTrigger | null, origin?: TurnOrigin): MessageRoute | null; //# sourceMappingURL=message-route.d.ts.map