UNPKG

agents

Version:

A home for your AI agents

42 lines (41 loc) • 1.89 kB
//#region src/agent-tool-types.ts /** * Reserved chunk type a sub-agent emits via `reportProgress` while it runs. * Rides the child's own UI-message stream as a **transient** data part, so it * re-broadcasts to the parent's clients (via the parent's tail) and surfaces in * `useAgentToolEvents` without persisting into the child's stored message parts. * See `design/rfc-detached-agent-tools.md` §"Progress and milestone signaling". */ const AGENT_TOOL_PROGRESS_PART = "data-agent-progress"; /** * Reserved chunk type a sub-agent emits via `reportProgress({ milestone })`. * Unlike the ephemeral progress part this rides the child's stream as a * **persisted** data part, so it survives eviction, replays on drill-in, and * re-resolves milestone waiters. See `design/rfc-detached-agent-tools.md`. */ const AGENT_TOOL_MILESTONE_PART = "data-agent-milestone"; /** * Whether a chunk body is a progress or milestone frame. These are broadcast * but never written to the child's chunk store, so they have no stored-chunk * position and must not take part in stored-position numbering or dedupe. */ function isAgentToolLifecycleChunk(body) { if (!body.includes("data-agent-progress") && !body.includes("data-agent-milestone")) return false; try { const type = JSON.parse(body)?.type; return type === "data-agent-progress" || type === "data-agent-milestone"; } catch { return false; } } /** * Whether a forwarded chunk has no stored-chunk position: a progress or * milestone frame, or a chunk too large to store. Such chunks carry the next * stored position without consuming it. */ function isPositionlessAgentToolChunk(chunk) { return chunk.unstoredId !== void 0 || isAgentToolLifecycleChunk(chunk.body); } //#endregion export { AGENT_TOOL_MILESTONE_PART, AGENT_TOOL_PROGRESS_PART, isAgentToolLifecycleChunk, isPositionlessAgentToolChunk }; //# sourceMappingURL=agent-tool-types.js.map