/** * Text helpers for run traces: the `[TRACE:]` prompt marker, the ids a * delivered text refers to, safe summaries, and skill-call path labels. * * All pure; no I/O. * * @module services/trace/trace-markers */ import { type TraceData } from './trace.types.js'; /** * The marker for a trace. * * @param traceId - Trace id * @returns `[TRACE:]` */ export declare function formatTraceMarker(traceId: string): string; /** * Trace ids named by `[TRACE:…]` markers in a text, in order, de-duplicated. * * @param text - Delivered text * @returns Trace ids */ export declare function parseTraceMarkers(text: string): string[]; /** * Append the trace marker as the last line, unless the text already names * this trace. Used where a prefix could disturb routing parsers (status * reports, agent-to-agent messages). * * @param text - Message text * @param traceId - Trace to carry (no-op when absent) * @returns The text with the marker */ export declare function appendTraceMarker(text: string, traceId: string | null | undefined): string; /** * Remove every `[TRACE:…]` marker from text going to the owner or an outside * channel (Slack, chat, the portal). Trace ids are harness plumbing; an * agent that copies a prompt's marker into its reply must not show it. * * @param text - Outgoing text * @returns The text without markers (unchanged when it had none) * * @example * stripTraceMarkers('Done.\n[TRACE:tr-20261003-0123abcd]') // 'Done.' */ export declare function stripTraceMarkers(text: string): string; /** Ids a delivered text refers to, by kind. */ export interface TextRefs { /** Request ids from `[TICKET:TKT-n ]` markers */ requestIds: string[]; /** UUIDs (candidate work item ids) */ workItemIds: string[]; /** `D-n` */ decisionIds: string[]; /** `CE-7`, `TKT-12`, … (not `D-n`) */ ticketIds: string[]; } /** * Every id in a text that the trace index might know. * * @param text - Delivered text * @returns Ids by kind, each de-duplicated */ export declare function extractTextRefs(text: string): TextRefs; /** * A summary safe to store: one line, routing prefixes and trace markers * removed, secrets redacted, cut to {@link TRACE_CONSTANTS.SUMMARY_MAX_CHARS}. * * @param text - Raw text (a message body, an error, a title) * @param max - Character limit * @returns The summary */ export declare function safeSummary(text: string | null | undefined, max?: number): string; /** * Keep only small values in an event's data map: strings are summarised, * non-finite numbers and empty values are dropped. * * @param data - Raw data * @returns Cleaned data, or undefined when nothing is left */ export declare function cleanTraceData(data: Record | undefined): TraceData | undefined; /** * The label of a skill call: method plus API path with ids replaced, so calls * group by endpoint. * * @param method - HTTP method * @param apiPath - Path relative to `/api` (query string ignored) * @returns e.g. `POST /task-pool/:id/complete` * * @example * skillLabel('post', '/terminal/crewly-orc/write?x=1') // 'POST /terminal/:session/write' */ export declare function skillLabel(method: string, apiPath: string): string; /** * Whether a chat-routed delivery was written by an agent, not the owner: * another agent's room post (and the thread digest it carries) or a * context-only room digest. Both share the owner's `[CHAT:…]` prefix * (crewly#1389). * * @param text - Delivered text * @returns True when the owner is not the author */ export declare function isAgentAuthoredChat(text: string): boolean; /** * The agent named in a chat post's sender header. * * @param text - Delivered text * @returns The agent's display name, or undefined */ export declare function agentSenderName(text: string): string | undefined; //# sourceMappingURL=trace-markers.d.ts.map