MCPcopy Create free account
hub / github.com/Noumena-Network/code / buildTranscriptEntries

Function buildTranscriptEntries

src/utils/permissions/yoloClassifier.ts:303–361  ·  view source on GitHub ↗
(messages: Message[])

Source from the content-addressed store, hash-verified

301 * and emitted as user turns.
302 */
303export function buildTranscriptEntries(messages: Message[]): TranscriptEntry[] {
304 const transcript: TranscriptEntry[] = []
305 for (const msg of messages) {
306 if (msg.type === 'attachment' && msg.attachment.type === 'queued_command') {
307 const prompt = msg.attachment.prompt
308 let text: string | null = null
309 if (typeof prompt === 'string') {
310 text = prompt
311 } else if (Array.isArray(prompt)) {
312 text =
313 prompt
314 .filter(
315 (block): block is { type: 'text'; text: string } =>
316 block.type === 'text',
317 )
318 .map(block => block.text)
319 .join('\n') || null
320 }
321 if (text !== null) {
322 transcript.push({
323 role: 'user',
324 content: [{ type: 'text', text }],
325 })
326 }
327 } else if (msg.type === 'user') {
328 const content = msg.message.content
329 const textBlocks: TranscriptBlock[] = []
330 if (typeof content === 'string') {
331 textBlocks.push({ type: 'text', text: content })
332 } else if (Array.isArray(content)) {
333 for (const block of content) {
334 if (block.type === 'text') {
335 textBlocks.push({ type: 'text', text: block.text })
336 }
337 }
338 }
339 if (textBlocks.length > 0) {
340 transcript.push({ role: 'user', content: textBlocks })
341 }
342 } else if (msg.type === 'assistant') {
343 const blocks: TranscriptBlock[] = []
344 for (const block of msg.message.content) {
345 // Only include tool_use blocks — assistant text is model-authored
346 // and could be crafted to influence the classifier's decision.
347 if (block.type === 'tool_use') {
348 blocks.push({
349 type: 'tool_use',
350 name: block.name,
351 input: block.input,
352 })
353 }
354 }
355 if (blocks.length > 0) {
356 transcript.push({ role: 'assistant', content: blocks })
357 }
358 }
359 }
360 return transcript

Callers 2

classifyYoloActionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected