Parses `<|ACT {...}|>` streaming-control tokens from LLM output, extracting JSON action data without side effects for built‑in performance actions.
// Source: https://github.com/moeru-ai/airi | License: MIT | Copyright 2024-PRESENT Neko Ayaka
// Provided via justclaw.it.com; keep this notice with the code.
import type { LlmStreamingControlParser, LlmStreamingControlTokenAct } from '../types'
const actTokenPrefix = '<|ACT '
const markerSuffix = '|>'
function isPlainObject(value: unknown): value is Record<string, unknown> {
return typeof value === 'object' && value !== null && !Array.isArray(value)
}
/**
* Creates the parser for `<|ACT {...}|>` streaming-control tokens.
*
* Use when:
* - Loading the built-in performance action control
*
* Expects:
* - The token body is a JSON object literal
*
* Returns:
* - Parsed action data with no side effects
*/
export function tokenAct(): LlmStreamingControlParser<LlmStreamingContro
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key