@juspay/neurolink
Version:
The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002
75 lines (74 loc) • 3.36 kB
TypeScript
/**
* Line-level TOML reading for the proxy's client-config writers.
*
* Grok and Codex keep their settings in TOML files the user and the CLI
* itself also edit, and the writers must find what the proxy wrote there
* without trusting its comment markers: Grok's own save drops every comment.
* No TOML parser is a dependency, and a parse-and-serialize round trip would
* reformat the user's file anyway, so this reads just enough structure to
* edit text in place: table headers, strings, keys and assignments. Every
* line keeps its own terminator, so text a writer does not own round-trips
* byte for byte.
*/
import type { CliTomlSection } from "../../types/index.js";
export declare function splitTomlSections(text: string): CliTomlSection[];
/**
* A line of TOML with every string replaced by `@<n>@` and any comment
* dropped, so text inside a string can never read as a key or an assignment.
* `strings[n]` is the decoded value. `@` cannot occur outside a string in
* valid TOML.
*/
export declare function maskTomlStrings(line: string): {
masked: string;
strings: string[];
};
export declare function parseMaskedAssignment(masked: string, strings: readonly string[]): {
path: string[];
value: string;
} | null;
/**
* The string a masked value starts with. Only the start counts, so a value
* with damage after it (a literal `\n` left by a bad paste) is still read.
*/
export declare function maskedStringValue(value: string, strings: readonly string[]): string | undefined;
/** The pairs directly inside a one-line inline table. */
export declare function inlineTablePairs(value: string, strings: readonly string[]): {
path: string[];
value: string;
}[];
/** The dotted key a statement assigns, and its value when that is a string. */
export declare function readTomlAssignment(line: string): {
path: string[];
value: string | undefined;
} | null;
/**
* The lines of a section that are TOML rather than the inside of a
* multi-line string; `statement` marks those that start a key/value pair
* rather than continue an array or inline table.
*/
export declare function tomlCodeLines(section: CliTomlSection): {
line: string;
statement: boolean;
}[];
export declare function readStringValue(section: CliTomlSection, key: string): string | undefined;
/**
* Names of the `<parent>.<name>` tables defined by dotted keys instead of a
* `[<parent>.<name>]` header: `claude-opus-4-6.base_url = ...` under
* `[model]`, or `model.claude-opus-4-6.base_url = ...` before the first
* header.
*/
export declare function dottedTableIds(sections: readonly CliTomlSection[], parent: string): string[];
/**
* How many of an owned section's lines are the writer's. Comments after its
* last key belong to what follows, so a note the user wrote above their own
* next table survives. `managedLines` are the writer's own comment lines,
* which are dropped wherever they sit.
*/
export declare function ownedLineCount(section: CliTomlSection, managedLines: ReadonlySet<string>): number;
/**
* A table declared twice is a TOML error, and neither Grok nor Codex will
* start on one.
* Each `[[array]]` element opens a fresh scope for everything under it, so
* `[mcp_servers.env]` under two elements is not a repeat.
*/
export declare function findDuplicateTable(text: string): string | undefined;