@kynver-app/runtime 0.2.23 → 0.2.24

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.
@@ -2,19 +2,42 @@ import { type CodexOrchestrationPath } from "./codex-orchestration-adapter.js";
2
2
  import { type HermesCliAdapterStatus } from "./hermes-cli-adapter.js";
3
3
  import { type HermesOpenAiCodexBindingStatus } from "./hermes-openai-codex-binding.js";
4
4
  import type { OrchestrationProviderBindingStatus, OrchestrationProviderId } from "./types.js";
5
+ /**
6
+ * PRESENCE-ONLY report of cloud API keys on the daemon host env.
7
+ *
8
+ * Honesty note (model-freedom audit gap 8): these keys are NOT usable by
9
+ * harness CLI workers — the worker-env scrub (`worker-env.ts`) strips every
10
+ * `*_API_KEY` from worker child environments by design. Presence here means
11
+ * only "the key exists on the daemon host" (e.g. for daemon-side HTTP paths);
12
+ * it must never be advertised as spendable worker credit.
13
+ */
5
14
  export interface OrchestrationCloudApiCredits {
6
- /** ANTHROPIC_API_KEY configured on host (cloud billing — not BYO OAuth). */
15
+ /** ANTHROPIC_API_KEY present on the daemon host env (scrubbed from worker children). */
7
16
  anthropicApiKey: boolean;
8
- /** OPENAI_API_KEY configured on host (cloud billing — distinct from Codex OAuth). */
17
+ /** OPENAI_API_KEY present on the daemon host env (scrubbed from worker children). */
9
18
  openaiApiKey: boolean;
10
- /** CODEX_API_KEY configured on host (OpenAI Codex cloud path). */
19
+ /** CODEX_API_KEY present on the daemon host env (scrubbed from worker children). */
11
20
  codexApiKey: boolean;
12
21
  }
22
+ /**
23
+ * W2a — generic `openai-compatible` worker provider endpoint presence.
24
+ * Unlike the cloud API keys above, this path IS worker-usable: the daemon
25
+ * builds the request (headers include the key) and hands it to its own runner
26
+ * child over stdin, so the scrub never blocks it.
27
+ */
28
+ export interface OrchestrationWorkerEndpoint {
29
+ /** KYNVER_WORKER_BASE_URL present — the generic provider is endpoint-configured. */
30
+ baseUrlConfigured: boolean;
31
+ /** KYNVER_WORKER_API_KEY present (optional — many local servers need none). */
32
+ apiKeyConfigured: boolean;
33
+ }
13
34
  export interface OrchestrationProviderInventory {
14
35
  generatedAt: string;
15
36
  bindings: Record<OrchestrationProviderId, OrchestrationProviderBindingStatus>;
16
- /** API-key cloud paths — separate from local OAuth CLI sessions. */
37
+ /** API-key PRESENCE on the daemon host — not worker-usable credit (see type doc). */
17
38
  cloudApiCredits: OrchestrationCloudApiCredits;
39
+ /** Generic openai-compatible worker endpoint presence (optional for snapshots from older runtimes). */
40
+ workerEndpoint?: OrchestrationWorkerEndpoint;
18
41
  hermes: HermesCliAdapterStatus;
19
42
  hermesOpenAiCodex: HermesOpenAiCodexBindingStatus;
20
43
  codexAdapterPath: CodexOrchestrationPath;
@@ -30,4 +30,12 @@ export declare function preflightClaudeModel(model: string | undefined, defaultM
30
30
  */
31
31
  /** Preflight for `codex` provider — accepts OpenAI/Codex model ids; rejects Claude-family ids. */
32
32
  export declare function preflightCodexModel(model: string | undefined, defaultModel: string): ModelPreflightResult;
33
+ /**
34
+ * Preflight for the generic `openai-compatible` provider. The endpoint behind
35
+ * `KYNVER_WORKER_BASE_URL` is the only judge of model validity — llama, qwen,
36
+ * mistral, deepseek, gpt-* and anything else all pass. The ONLY structural
37
+ * failure is having no model at all (no request and no provider default): a
38
+ * chat-completions call cannot be issued without one.
39
+ */
40
+ export declare function preflightOpenAiCompatibleModel(model: string | undefined, defaultModel: string | undefined): ModelPreflightResult;
33
41
  export declare function preflightCursorModel(model: string | undefined, defaultModel: string): ModelPreflightResult;
@@ -0,0 +1,23 @@
1
+ export interface OpenAiCompatibleUsage {
2
+ inputTokens?: number;
3
+ outputTokens?: number;
4
+ }
5
+ export interface OpenAiCompatibleCompletion {
6
+ ok: true;
7
+ /** Assistant message text (choices[0].message.content, string-joined). */
8
+ content: string;
9
+ /** Model id the endpoint reports serving (may differ from the requested id). */
10
+ model?: string;
11
+ /** usage.prompt_tokens / usage.completion_tokens when the endpoint reports them. */
12
+ usage?: OpenAiCompatibleUsage;
13
+ }
14
+ export interface OpenAiCompatibleCompletionError {
15
+ ok: false;
16
+ error: string;
17
+ }
18
+ /**
19
+ * Extract the assistant output + usage from a chat-completions response body.
20
+ * Tolerant of the shape variance across Ollama/vLLM/OpenRouter/Together/OpenAI —
21
+ * the caller only needs `content` (the work product) and optional usage/model.
22
+ */
23
+ export declare function extractOpenAiCompatibleCompletion(body: unknown): OpenAiCompatibleCompletion | OpenAiCompatibleCompletionError;
@@ -0,0 +1 @@
1
+ export declare function runOpenAiCompatibleWorkUnit(): Promise<void>;
@@ -0,0 +1,46 @@
1
+ import type { WorkerProvider, WorkerProviderStartOptions } from "./types.js";
2
+ export declare const OPENAI_COMPATIBLE_PROVIDER = "openai-compatible";
3
+ export declare function resolveOpenAiCompatibleDefaultModel(env?: NodeJS.ProcessEnv): string | undefined;
4
+ export interface OpenAiCompatibleEndpoint {
5
+ /** Normalized base URL without a trailing slash, e.g. http://localhost:11434/v1 */
6
+ baseUrl: string;
7
+ /** Raw API key when configured; never placed in a child env. */
8
+ apiKey?: string;
9
+ timeoutMs: number;
10
+ }
11
+ export declare class OpenAiCompatibleConfigError extends Error {
12
+ }
13
+ /**
14
+ * Resolve the endpoint from the DAEMON host env. Throws a remediation-quality
15
+ * error when `KYNVER_WORKER_BASE_URL` is unset or not an http(s) URL.
16
+ */
17
+ export declare function resolveOpenAiCompatibleEndpoint(env?: NodeJS.ProcessEnv): OpenAiCompatibleEndpoint;
18
+ export declare const OPENAI_COMPATIBLE_SYSTEM_PROMPT: string;
19
+ export interface OpenAiCompatibleChatRequest {
20
+ url: string;
21
+ /** Fully constructed headers — the Authorization bearer is baked in here. */
22
+ headers: Record<string, string>;
23
+ body: {
24
+ model: string;
25
+ temperature: number;
26
+ stream: false;
27
+ messages: Array<{
28
+ role: "system" | "user";
29
+ content: string;
30
+ }>;
31
+ };
32
+ }
33
+ /** Build the single chat-completions request for a work unit. Pure — testable. */
34
+ export declare function buildOpenAiCompatibleChatRequest(endpoint: Pick<OpenAiCompatibleEndpoint, "baseUrl" | "apiKey">, model: string, prompt: string): OpenAiCompatibleChatRequest;
35
+ /** Config the runner child receives over STDIN (never argv/env/disk — carries the key). */
36
+ export interface OpenAiCompatibleRunnerConfig {
37
+ provider: typeof OPENAI_COMPATIBLE_PROVIDER;
38
+ model: string;
39
+ request: OpenAiCompatibleChatRequest;
40
+ timeoutMs: number;
41
+ heartbeatPath: string;
42
+ /** Redacted origin for log/error messages (no path, no credentials). */
43
+ endpointOrigin: string;
44
+ }
45
+ export declare function buildOpenAiCompatibleRunnerConfig(opts: Pick<WorkerProviderStartOptions, "prompt" | "heartbeatPath">, endpoint: OpenAiCompatibleEndpoint, model: string): OpenAiCompatibleRunnerConfig;
46
+ export declare const openAiCompatibleProvider: WorkerProvider;