/* tslint:disable */ /* eslint-disable */ /** * WASM handle for a loaded v2 model. */ export class NeedleV2Wasm { private constructor(); free(): void; [Symbol.dispose](): void; /** * Raw confidence logit for an arbitrary string, or `null` without a * confidence head. Higher is more confident; apply a sigmoid. * * This is the primitive. A bare query reads near zero however answerable * it is, because the completion is what gets scored — prefer * [`confidence_for`] unless you are assembling the prompt yourself. * * [`confidence_for`]: NeedleV2Wasm::confidence_for */ confidence(text: string): number | undefined; /** * Probability in `(0, 1)` that `completion` is the right answer for this * query, or `null` without a confidence head. * * The head scores a judgement already made, so it needs the completion: * pass what [`run`] returned. Gate execution on it — act above a threshold * you pick, escalate below it. * * [`run`]: NeedleV2Wasm::run */ confidence_for(query: string, tools_json: string, completion: string): number | undefined; /** * Width of the contrastive embedding, 0 without such a head. */ contrastive_dim(): number; /** * L2-normalised contrastive embedding, or `null` without such a head. */ encode_contrastive(text: string): Float32Array | undefined; /** * Generation with explicit settings. `temperature <= 0` is greedy. */ generate(query: string, tools_json: string, max_new_tokens: number, temperature: number, seed: number, constrain: boolean): string; /** * Load from a `.cact` image. Returns `null` on failure. */ static load(cact_bytes: Uint8Array): NeedleV2Wasm | undefined; /** * Rank tool descriptions against a query. * * `tool_descs_json` is a JSON array of strings; the result is a JSON array * of `[index, score]` pairs, descending. */ retrieve_tools(query: string, tool_descs_json: string, top_k: number): string; /** * Greedy tool call; returns the full decoded text. */ run(query: string, tools_json: string): string; /** * Just the `` payload, or an empty string if none was emitted. */ run_json(query: string, tools_json: string): string; /** * Streaming generation. `on_token(tokenId, piece)` fires per token. */ run_stream(query: string, tools_json: string, on_token: Function): string; } /** * A loaded Needle 3 model. */ export class NeedleV3Wasm { private constructor(); free(): void; [Symbol.dispose](): void; /** * How confident the model is in a completion it produced. * * **Pass the completion, not the query.** The head scores a finished * judgement. On the shipped checkpoint a correct call scores 0.93, a * wrong one 0.26 — and a bare query scores 0.80, which looks like a * confident answer and is not one. v2 collapsed to near zero on a bare * query, so the misuse announced itself; v3 does not. * * Returns `undefined` if the container exports no confidence head. */ confidence_for(query: string, tools_json: string, completion: string): number | undefined; /** * Generate with explicit settings. * * `kv_int8` stores the key/value cache as 8-bit — the width the container * declares and upstream's engine runs — for roughly a quarter of the * memory. See [`Self::kv_bytes`]. */ generate(query: string, tools_json: string, max_new_tokens: number, temperature: number, seed: number, constrain: boolean, kv_int8: boolean): string; /** * Whether this container carries a confidence head. */ has_confidence(): boolean; /** * Working-set estimate in bytes for a session of `seq_len` positions. * * Browser tabs have a memory budget and v3's container is 35 MB, so this * is exposed rather than left for a page to guess. Counts the key/value * cache only; the packed weights are a separate, fixed cost. */ kv_bytes(seq_len: number): number; /** * The same estimate for a cache stored at int8. * * Not a flat quarter of [`Self::kv_bytes`]: every stored head vector also * carries an `f32` scale. At full context it is 27% of the f32 figure. */ kv_bytes_int8(seq_len: number): number; /** * Load from the bytes of a `needle3.cact` container. * * Returns `undefined` if the bytes are not a v3 container — including * when they are a *v2* container, which has its own class. */ static load(cact_bytes: Uint8Array): NeedleV3Wasm | undefined; /** * Load the `layers`-block ladder rung of the same container. * * Needle 3 is trained so that every depth from 2 blocks up is a usable * model. A tab can hold one 35 MB download and pick its depth: a shallow * pass for a simple command, the full stack for a hard one. Shallower * rungs also cost proportionally less key/value cache. * * Quality falls with depth, steeply at the bottom — on the shipped * weights 2 and 4 blocks do not produce usable tool calls, 6 upward do. * Returns `undefined` for a depth outside `2..=num_layers`. */ static load_with_depth(cact_bytes: Uint8Array, layers: number): NeedleV3Wasm | undefined; /** * Context limit in tokens. */ max_seq_len(): number; /** * How many blocks this engine is running. */ num_layers(): number; /** * The model's chain-of-thought, if it produced any. * * v3 reasons on essentially every query; v2 only sometimes, and v1 never. * A `` block is not a reliable marker of which generation ran. */ reasoning(text: string): string | undefined; /** * The full completion, reasoning included. */ run(query: string, tools_json: string): string; /** * Just the tool-call payload. * * `"[]"` is a deliberate abstention — the model considered the tools and * declined — and `""` means no `` markers were emitted at all. * Treating the first as a failure turns a considered "no" into an error. */ run_json(query: string, tools_json: string): string; /** * Generate, invoking `on_token(text)` with each decoded delta. * * The callback receives decoded text, not raw pieces — a newline arrives * as the byte-fallback token `<0x0A>`, and appending raw pieces would * render that literally. Concatenating every delta reproduces the return * value exactly. */ run_stream(query: string, tools_json: string, on_token: Function): string; } /** * WASM-exposed inference engine handle. */ export class NeedleWasm { private constructor(); free(): void; [Symbol.dispose](): void; /** * Return the contrastive embedding dimension (0 if no contrastive head loaded). */ contrastive_dim(): number; /** * Encode text to a L2-normalized contrastive embedding. * * Returns a `Float32Array` of length `contrastive_dim()`, or `null` if the * model was loaded without a contrastive head. * * Cosine similarity between query and tool embeddings equals the dot product * (both vectors are already L2-normalized). */ encode_contrastive(text: string): Float32Array | undefined; /** * Load the engine from raw bytes. * * `weights_bytes`: ArrayBuffer / Uint8Array containing the .safetensors file. * `vocab_text`: String content of vocab.txt (one piece per line). */ static load(weights_bytes: Uint8Array, vocab_text: string): NeedleWasm | undefined; /** * Rank tool descriptions by contrastive similarity to a query. * * `tool_descs_json`: JSON array of description strings, e.g. * `'["Get current weather", "Search the web", "Send email"]'` * * Returns a JSON string `[{"index":0,"score":0.95},{"index":2,"score":0.71}]` * sorted by descending score, or `"[]"` if the model has no contrastive head. * * Mirrors Python `retrieve_tools(query, tools, top_k)` from `run.py`. */ retrieve_tools(query: string, tool_descs_json: string, top_k: number): string; /** * Run inference and return the output JSON string. * * Returns e.g. `[{"name":"get_weather","arguments":{"location":"Paris"}}]`. */ run(query: string, tools_json: string): string; /** * Run inference on multiple examples and return a JS Array of output strings. * * Input: JS Array of `{query: string, tools: string}` objects. * Output: JS Array of output strings, one per input. */ run_batch(examples: Array): Array; /** * Run inference with a per-token streaming callback. * * `on_token(tokenId: number, piece: string)` fires for each generated token * in decode order. Returns the final post-processed output string. */ run_stream(query: string, tools_json: string, on_token: Function): string; } /** * Pull the payload out of a completion the caller already has. */ export function extract_tool_call_v3(text: string): string | undefined; export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module; export interface InitOutput { readonly memory: WebAssembly.Memory; readonly __wbg_needlev2wasm_free: (a: number, b: number) => void; readonly __wbg_needlev3wasm_free: (a: number, b: number) => void; readonly __wbg_needlewasm_free: (a: number, b: number) => void; readonly extract_tool_call_v3: (a: number, b: number, c: number) => void; readonly needlev2wasm_confidence: (a: number, b: number, c: number) => number; readonly needlev2wasm_confidence_for: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number; readonly needlev2wasm_contrastive_dim: (a: number) => number; readonly needlev2wasm_encode_contrastive: (a: number, b: number, c: number, d: number) => void; readonly needlev2wasm_generate: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void; readonly needlev2wasm_load: (a: number, b: number) => number; readonly needlev2wasm_retrieve_tools: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void; readonly needlev2wasm_run: (a: number, b: number, c: number, d: number, e: number, f: number) => void; readonly needlev2wasm_run_json: (a: number, b: number, c: number, d: number, e: number, f: number) => void; readonly needlev2wasm_run_stream: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void; readonly needlev3wasm_confidence_for: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number; readonly needlev3wasm_generate: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => void; readonly needlev3wasm_has_confidence: (a: number) => number; readonly needlev3wasm_kv_bytes: (a: number, b: number) => number; readonly needlev3wasm_kv_bytes_int8: (a: number, b: number) => number; readonly needlev3wasm_load: (a: number, b: number) => number; readonly needlev3wasm_load_with_depth: (a: number, b: number, c: number) => number; readonly needlev3wasm_max_seq_len: (a: number) => number; readonly needlev3wasm_num_layers: (a: number) => number; readonly needlev3wasm_reasoning: (a: number, b: number, c: number, d: number) => void; readonly needlev3wasm_run: (a: number, b: number, c: number, d: number, e: number, f: number) => void; readonly needlev3wasm_run_json: (a: number, b: number, c: number, d: number, e: number, f: number) => void; readonly needlev3wasm_run_stream: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void; readonly needlewasm_contrastive_dim: (a: number) => number; readonly needlewasm_encode_contrastive: (a: number, b: number, c: number, d: number) => void; readonly needlewasm_load: (a: number, b: number, c: number, d: number) => number; readonly needlewasm_retrieve_tools: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void; readonly needlewasm_run: (a: number, b: number, c: number, d: number, e: number, f: number) => void; readonly needlewasm_run_batch: (a: number, b: number) => number; readonly needlewasm_run_stream: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void; readonly __wbindgen_export: (a: number, b: number) => number; readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number; readonly __wbindgen_export3: (a: number) => void; readonly __wbindgen_add_to_stack_pointer: (a: number) => number; readonly __wbindgen_export4: (a: number, b: number, c: number) => void; } export type SyncInitInput = BufferSource | WebAssembly.Module; /** * Instantiates the given `module`, which can either be bytes or * a precompiled `WebAssembly.Module`. * * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated. * * @returns {InitOutput} */ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput; /** * If `module_or_path` is {RequestInfo} or {URL}, makes a request and * for everything else, calls `WebAssembly.instantiate` directly. * * @param {{ module_or_path: InitInput | Promise }} module_or_path - Passing `InitInput` directly is deprecated. * * @returns {Promise} */ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise } | InitInput | Promise): Promise;