export interface AgentPromptIdentity {
workflow: string;
phase: string;
index: number;
}
export interface AgentPromptSource {
agentId: string;
task: string;
}
function escapeAttribute(value: string): string {
return value
.replaceAll("&", "&")
.replaceAll('"', """)
.replaceAll("<", "<")
.replaceAll(">", ">");
}
function cdata(value: string): string {
return `", "]]]]>")}]]>`;
}
export function quoteAgentOutput(
content: string,
sources: AgentPromptSource[],
): string {
if (sources.length === 0) return content;
const sourceLines = sources.map(
(source) =>
` `,
);
return [
"",
...sourceLines,
` ${cdata(content)}`,
"
",
].join("\n");
}
export function assignmentPrompt(
identity: AgentPromptIdentity,
assignment: string,
): string {
const agentId = `${identity.phase}#${identity.index}`;
return [
``,
' ',
assignment,
" ",
"",
].join("\n");
}
export function resumePrompt(
agentId: string,
phase: string,
message: string,
): string {
return [
``,
' ',
message,
" ",
"",
].join("\n");
}