@adonis-agora/agent
Version:
Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.
28 lines • 1.59 kB
TypeScript
/**
* A JSON document cut off somewhere in the middle — a tool call's arguments while the model is still
* writing them — read as far as it goes.
*
* What it returns is what a reader can trust about the prefix, and no more:
* - an object or array whose closing bracket has not arrived is returned with what it holds so far,
* and listed in {@link PartialJson.open};
* - a string cut mid-way is returned as written so far, and the member holding it is named by
* {@link PartialJson.pendingMember} (so `"type": "Car` is never mistaken for a finished `"Car"`);
* - a number, `true`, `false` or `null` at the cut is LEFT OUT (`12` may yet be `123`), and so is a
* key with no value yet; the member is named by `pendingMember` all the same.
*/
export interface PartialJson {
/** The value read so far. `undefined` when not even its first character has arrived. */
value: unknown;
/** Whether the document is complete: the root value closed (trailing whitespace allowed). */
complete: boolean;
/** Is this object or array (one of `value`'s) still open? */
isOpen(container: object): boolean;
/** The key (object) or index (array) of `container` whose value is still being written. */
pendingMember(container: object): string | number | undefined;
}
/**
* Parse a JSON prefix (see {@link PartialJson}). `undefined` when the text is not the beginning of a
* JSON document at all — a syntax error before the cut.
*/
export declare function parsePartialJson(text: string): PartialJson | undefined;
//# sourceMappingURL=partial-json.d.ts.map