@hraness/sys1 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,54 @@
1
+ import { type Sys1Config } from "./config.ts";
2
+ import { type InstalledModel } from "./local/store.ts";
3
+ import type { BackendCandidate, BackendCapabilities } from "./router.ts";
4
+ export declare const HOSTED_BACKEND_NAME = "typesafe";
5
+ export interface RuntimeBackend extends BackendCandidate {
6
+ adapter?: "systemone" | "kev";
7
+ base_url: string;
8
+ headers: Record<string, string>;
9
+ /** Model id forwarded in the request body when the caller did not pin one. */
10
+ default_model: string;
11
+ /**
12
+ * Present when this backend is a builtin local model served by the
13
+ * in-process runner rather than an HTTP endpoint. `base_url` is empty.
14
+ */
15
+ builtin?: {
16
+ model: InstalledModel;
17
+ path: string;
18
+ };
19
+ }
20
+ export interface ProbeResult {
21
+ available: boolean;
22
+ models: string[];
23
+ latency_ms: number | null;
24
+ detail: string | null;
25
+ }
26
+ export declare function extractModelIds(body: unknown): string[];
27
+ export declare function extractBackendCapabilities(body: unknown): BackendCapabilities | null;
28
+ /**
29
+ * Build the runtime backend list from config and environment. The hosted Jev
30
+ * backend exists only when enabled and an API key is present in the configured
31
+ * env var; keys are read from the environment, never from the config file.
32
+ * When `home` is given and `local.enabled` is on, every installed GGUF joins
33
+ * as a builtin `local-<id>` pseudo-backend served by the in-process runner.
34
+ * Only config.local.model is eligible for automatic local routing. Other
35
+ * installed models and URL-registered backends require an explicit request pin.
36
+ */
37
+ export declare function runtimeBackends(config: Sys1Config, env: NodeJS.ProcessEnv, home?: string): RuntimeBackend[];
38
+ export declare function probeBackend(backend: RuntimeBackend, timeoutMs: number, fetchFn?: typeof fetch, signal?: AbortSignal): Promise<ProbeResult>;
39
+ export declare function probeAll(backends: RuntimeBackend[], timeoutMs: number, fetchFn?: typeof fetch, signal?: AbortSignal): Promise<Map<string, ProbeResult>>;
40
+ export type ForwardResult = {
41
+ kind: "response";
42
+ status: number;
43
+ body: string;
44
+ content_type: string;
45
+ } | {
46
+ kind: "transport";
47
+ detail: string;
48
+ };
49
+ /**
50
+ * Forward one already-validated System One request body to a backend. Only
51
+ * transport failures (no HTTP response at all) report `transport`; any HTTP
52
+ * response — including backend errors — is definitive and passed through.
53
+ */
54
+ export declare function forwardToBackend(backend: RuntimeBackend, rawBody: string, resolvedModel: string | undefined, timeoutMs: number, fetchFn?: typeof fetch, signal?: AbortSignal): Promise<ForwardResult>;