(input: {
skills: PiSkill[]
initialMessages: PiMessage[]
task: string
guidance?: string
})
| 69 | * then skills, prior memory, and the task. |
| 70 | */ |
| 71 | export function buildPiPrompt(input: { |
| 72 | skills: PiSkill[] |
| 73 | initialMessages: PiMessage[] |
| 74 | task: string |
| 75 | guidance?: string |
| 76 | }): string { |
| 77 | const parts: string[] = [] |
| 78 | |
| 79 | if (input.guidance) { |
| 80 | parts.push(`# Operating instructions\n${input.guidance}`) |
| 81 | } |
| 82 | |
| 83 | if (input.skills.length > 0) { |
| 84 | parts.push('# Available skills') |
| 85 | for (const skill of input.skills) { |
| 86 | parts.push(`## ${skill.name}\n${skill.content}`) |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | if (input.initialMessages.length > 0) { |
| 91 | parts.push('# Prior conversation') |
| 92 | for (const message of input.initialMessages) { |
| 93 | parts.push(`${message.role}: ${message.content}`) |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | parts.push('# Task') |
| 98 | parts.push(input.task) |
| 99 | return parts.join('\n\n') |
| 100 | } |
| 101 | |
| 102 | /** Persists the user task and the agent's final message to memory. */ |
| 103 | export async function appendPiMemory( |
no test coverage detected