JsonFrameLimits
SUPPORT · interface · Type contract
Bounds applied while scanning a streamed text.
Import
ts
import type { JsonFrameLimits } from '@jangts/agent-core/json-transport';js
/** @typedef {import('@jangts/agent-core/json-transport').JsonFrameLimits} JsonFrameLimits */Other public entry points:@jangts/agent-core, @jangts/agent-core/types, @jangts/agent-core/structs, @jangts/agent-core/json-transport, @jangts/agent-core/support.
Definition
ts
interface JsonFrameLimitsField structure
| Field | Type | Required | Description |
|---|---|---|---|
maxFrames | number | Required | Maximum number of complete frames accepted. |
maxExtraClosings | number | Required | Stray closing braces tolerated outside frames, covering transports that repeat a delimiter. |
maxFrameChars | number | undefined | Optional | Optional per-frame character cap so a single frame cannot amplify into an oversized parse. |
Examples
- SSE, JSON frames, and bounded event streams: Reuse transport mechanics while preserving cancellation and backpressure; protocol parsing and business validation remain separate.
Parse one SSE frame locally
Beginner · Node.js
ts
import { Support } from '@jangts/agent-core';
const frame = Support.encodeSseEvent({ event: 'status', data: JSON.stringify({ phase: 'thinking' }) });
const body = new Response(frame).body!;
for await (const event of Support.readSse(body)) console.log(event.event, event.data);js
import { Support } from '@jangts/agent-core';
const frame = Support.encodeSseEvent({ event: 'status', data: JSON.stringify({ phase: 'thinking' }) });
const body = new Response(frame).body;
for await (const event of Support.readSse(body))
console.log(event.event, event.data);Producer waits for each event delivery
Configuration · Node.js
ts
import { Support } from '@jangts/agent-core';
const signal = new AbortController().signal;
const stream = Support.streamEvents<{ phase: string }>(async emit => {
await emit({ phase: 'preparing' });
await emit({ phase: 'complete' });
}, { signal });
for await (const event of stream) console.log(event.phase);js
import { Support } from '@jangts/agent-core';
const signal = new AbortController().signal;
const stream = Support.streamEvents(async (emit) => {
await emit({ phase: 'preparing' });
await emit({ phase: 'complete' });
}, { signal });
for await (const event of stream)
console.log(event.phase);