UNPKG

@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

68 lines (67 loc) • 3.4 kB
/** * OpenCode client configurator. * * Moved verbatim out of `proxy.ts` so that adding a CLI means adding a file * here rather than editing a 5,000-line command module in seven places. * * Two defects made every config this writer produced unusable, and both are * fixed here. They are recorded because each was invisible to the tests that * were supposed to cover this file. * * 1. The snapshot lived in `opencode.json` itself, under two `__proxy_*` keys * at the top level. OpenCode validates its config against a closed schema * and rejects unknown top-level keys outright: * * Error: Configuration is invalid at ~/.config/opencode/opencode.json * ↳ Unrecognized keys: "__proxy_original_neurolink", "__proxy_written_neurolink" * * Every `opencode` invocation failed at startup — not just proxied ones — * so auto-configuration bricked the CLI it was meant to onboard. The * snapshot now lives beside Codex's, in `~/.neurolink/`, which is what * `codex.ts` has always done. Claude Code and Qwen embed a snapshot the * same way and survive it only because their schemas ignore unknown keys; * that is tolerance, not permission, and new writers should not rely on it. * * 2. `models` was written as `{}`. OpenCode resolves `--model provider/id` * against that map and never calls `/v1/models`, so an empty map meant * every id was unknown: * * ProviderModelNotFoundError: providerID "neurolink", suggestions: [] * * Fixing only the keys exposed this one immediately underneath. * * Configs written by the previous version are repaired in place: both apply() * and restore() adopt a legacy in-file snapshot before deleting the keys, so * an existing broken config heals on the next `proxy start` without losing the * user's original provider block. */ import type { CliProxyClientConfigurator } from "../../types/index.js"; declare function getOpenCodeConfigDir(): string; declare function getOpenCodeConfigPath(): string; /** * Where the snapshot of the user's pre-existing `provider.neurolink` lives. * * Outside `opencode.json`, for the reason in the file header. Persisting it on * disk (rather than in process memory) means restoration still works when the * proxy crashes or shutdown runs in a different process — the property the * in-file version was reaching for. */ declare function getOpenCodeSnapshotPath(): string; export declare function setOpenCodeProxySettings(baseUrl: string, proxyKey?: string): Promise<boolean>; export declare function clearOpenCodeProxySettings(expectedBaseUrl?: string): Promise<boolean>; /** * Test-only export (CLAUDE.md rule 15 determinism exception). The OpenCode * client writers resolve paths from the environment and are only reachable * from `proxy start` / `proxy setup`, neither of which can be driven against a * throwaway HOME without starting a real server. Consumed by * test/continuous-test-suite-proxy.ts. */ export declare const __openCodeTestHooks: { getOpenCodeConfigDir: typeof getOpenCodeConfigDir; getOpenCodeConfigPath: typeof getOpenCodeConfigPath; getOpenCodeSnapshotPath: typeof getOpenCodeSnapshotPath; setOpenCodeProxySettings: typeof setOpenCodeProxySettings; clearOpenCodeProxySettings: typeof clearOpenCodeProxySettings; }; export declare const openCodeConfigurator: CliProxyClientConfigurator; export {};