@machina.ai/ch-llm-reboot 0.1.5-alpha.1.c1

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,136 @@
1
+ /**
2
+ * OpenAI & xAI (Grok) Chat Completions Request Serializer and Stream Normalizer.
3
+ *
4
+ * @module @machina.ai/ch-llm-reboot/formatters/openai
5
+ */
6
+ import type { FinishReason, GenerateOptions, TokenUsage } from '@deepseek-ai/dsh-llm';
7
+ /**
8
+ * One Chat Completions message in the request. Assistant `content` is null when the turn carries only tool calls,
9
+ * and `reasoning_content` preserves the xAI/Grok reasoning extension across replay.
10
+ */
11
+ export interface OpenAiMessage {
12
+ role: 'system' | 'user' | 'assistant' | 'tool';
13
+ content: string | Array<{
14
+ type: string;
15
+ text?: string;
16
+ image_url?: {
17
+ url: string;
18
+ };
19
+ }> | null;
20
+ reasoning_content?: string | undefined;
21
+ tool_calls?: Array<{
22
+ id: string;
23
+ type: 'function';
24
+ function: {
25
+ name: string;
26
+ arguments: string;
27
+ };
28
+ }> | undefined;
29
+ tool_call_id?: string | undefined;
30
+ }
31
+ /**
32
+ * One function tool in the request; `parameters` is forwarded unchanged as a JSON Schema object.
33
+ */
34
+ export interface OpenAiTool {
35
+ type: 'function';
36
+ function: {
37
+ name: string;
38
+ description?: string | undefined;
39
+ parameters?: Record<string, unknown> | undefined;
40
+ };
41
+ }
42
+ /**
43
+ * JSON body posted to the OpenAI-compatible chat completions endpoint. Streaming with usage reporting is fixed,
44
+ * so `stream` and `stream_options.include_usage` are always true.
45
+ */
46
+ export interface OpenAiRequestPayload {
47
+ model: string;
48
+ messages: OpenAiMessage[];
49
+ stream: boolean;
50
+ stream_options?: {
51
+ include_usage?: boolean | undefined;
52
+ } | undefined;
53
+ temperature?: number | undefined;
54
+ max_tokens?: number | undefined;
55
+ max_completion_tokens?: number | undefined;
56
+ stop?: string[] | undefined;
57
+ tools?: OpenAiTool[] | undefined;
58
+ reasoning_effort?: string | undefined;
59
+ }
60
+ /**
61
+ * Normalized content of one OpenAI or xAI stream chunk. A chunk usually carries one delta kind, and `finishReason`
62
+ * or `usage` appear only on the chunk that reports them.
63
+ */
64
+ export interface ParsedOpenAiChunk {
65
+ textDelta?: string | undefined;
66
+ reasoningDelta?: string | undefined;
67
+ toolCalls: Array<{
68
+ index: number;
69
+ id?: string | undefined;
70
+ name?: string | undefined;
71
+ argumentsDelta?: string | undefined;
72
+ }>;
73
+ usage?: TokenUsage | undefined;
74
+ finishReason?: FinishReason | undefined;
75
+ }
76
+ /**
77
+ * One tool-call fragment in a stream delta. The name and id arrive on the call's first fragment and later fragments
78
+ * carry only `arguments`, which the dispatcher concatenates by `index`.
79
+ */
80
+ export interface RawOpenAiToolCall {
81
+ index?: number;
82
+ id?: string;
83
+ function?: {
84
+ name?: string;
85
+ arguments?: string;
86
+ };
87
+ }
88
+ /**
89
+ * One streamed choice as received, unvalidated. Providers disagree on the reasoning field name, so both
90
+ * `reasoning_content` and `thought` are read.
91
+ */
92
+ export interface RawOpenAiChoice {
93
+ delta?: {
94
+ content?: string;
95
+ reasoning_content?: string;
96
+ thought?: string;
97
+ tool_calls?: RawOpenAiToolCall[];
98
+ };
99
+ finish_reason?: string;
100
+ }
101
+ /**
102
+ * Upstream token counters. `prompt_tokens` includes cached tokens, which the parser subtracts to produce `inputTokens`.
103
+ */
104
+ export interface RawOpenAiUsage {
105
+ prompt_tokens?: number;
106
+ completion_tokens?: number;
107
+ total_tokens?: number;
108
+ prompt_tokens_details?: {
109
+ cached_tokens?: number;
110
+ };
111
+ completion_tokens_details?: {
112
+ reasoning_tokens?: number;
113
+ };
114
+ }
115
+ /**
116
+ * Raw stream chunk as parsed from JSON. The final usage-only chunk carries no choices.
117
+ */
118
+ export interface RawOpenAiChunk {
119
+ choices?: RawOpenAiChoice[];
120
+ usage?: RawOpenAiUsage;
121
+ }
122
+ /**
123
+ * Formats GenerateOptions into OpenAI Chat Completions JSON request payload.
124
+ *
125
+ * @param options Fully assembled model request.
126
+ * @returns OpenAI wire request payload.
127
+ */
128
+ export declare function formatOpenAiRequest(options: GenerateOptions): OpenAiRequestPayload;
129
+ /**
130
+ * Parses raw OpenAI / xAI SSE chunk into normalized components.
131
+ *
132
+ * @param chunk Raw parsed OpenAI JSON chunk.
133
+ * @returns Normalized chunk items.
134
+ */
135
+ export declare function parseOpenAiChunk(chunk: unknown): ParsedOpenAiChunk;
136
+ //# sourceMappingURL=openai.d.ts.map
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Reboot Multi-Model LLM Provider plugin for DeepSeek Harness.
3
+ *
4
+ * @module @machina.ai/ch-llm-reboot
5
+ */
6
+ import type { Context } from '@deepseek-ai/cordis';
7
+ import z from '@deepseek-ai/schemastery';
8
+ import type { RebootLlmConfig, ResolvedRebootLlmConfig } from './types.ts';
9
+ export * from './types.ts';
10
+ export * from './catalog.ts';
11
+ export * from './adapter.ts';
12
+ export * from './sse-parser.ts';
13
+ export * from './dispatcher.ts';
14
+ export * from './formatters/index.ts';
15
+ /** Upstream Reboot AI Gateway base URL applied when `agent.agent_api_url` is absent from plugin config and ~/.cell-harness/config.yaml. */
16
+ export declare const DEFAULT_AGENT_API_URL = "https://api.machina.ai";
17
+ /**
18
+ * Upstream request timeout in seconds applied when `agent.timeout_seconds` is absent; resolved configs reject
19
+ * non-positive or fractional values.
20
+ */
21
+ export declare const DEFAULT_TIMEOUT_SECONDS = 1200;
22
+ /** Startup model or routing alias applied when `default_model` is absent, before the catalog resolves it to a provider model. */
23
+ export declare const DEFAULT_MODEL = "auto-gemini-3.8";
24
+ /** Provider name prefix applied when `provider_name` is absent; it builds the per-family route keys registered with `ctx.llm`. */
25
+ export declare const DEFAULT_PROVIDER_NAME = "reboot";
26
+ /**
27
+ * Plugin configuration accepted by `apply`. Fields omitted here fall back to ~/.cell-harness/config.yaml and then to
28
+ * the `DEFAULT_*` values, so a plugin declaration sets only the values it overrides.
29
+ */
30
+ export interface Config extends RebootLlmConfig {
31
+ }
32
+ export declare const Config: z<Config>;
33
+ /**
34
+ * Validates and normalizes raw configuration.
35
+ *
36
+ * @param raw Raw input configuration.
37
+ * @returns Resolved configuration.
38
+ */
39
+ export declare function resolveRebootLlmConfig(raw: RebootLlmConfig): ResolvedRebootLlmConfig;
40
+ export declare const name = "llm-reboot";
41
+ export declare const inject: string[];
42
+ /**
43
+ * Mounts the Reboot LLM provider adapter into the Cordis context.
44
+ *
45
+ * @param ctx The Cordis context.
46
+ * @param config Plugin configuration.
47
+ */
48
+ export declare function apply(ctx: Context, config?: Config): void;
49
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Server-Sent Events (SSE) Stream Parser.
3
+ *
4
+ * @module @machina.ai/ch-llm-reboot/sse-parser
5
+ */
6
+ export interface SseEvent {
7
+ event?: string | undefined;
8
+ data: string;
9
+ }
10
+ /**
11
+ * Parses a byte ReadableStream into an async iterable of parsed SSE events.
12
+ * Handles boundary splitting, CRLF / LF line endings, and multiline data payloads.
13
+ *
14
+ * @param stream Raw Uint8Array stream from response body.
15
+ * @returns Async iterable yielding individual parsed SseEvent objects.
16
+ */
17
+ export declare function parseSseStream(stream: ReadableStream<Uint8Array>): AsyncIterable<SseEvent>;
18
+ //# sourceMappingURL=sse-parser.d.ts.map
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Type declarations and configuration interfaces for Reboot LLM Provider plugin.
3
+ *
4
+ * @module @machina.ai/ch-llm-reboot/types
5
+ */
6
+ import type { ModelModality, RetryPolicyConfig, ResolvedRetryPolicy } from '@deepseek-ai/dsh-llm';
7
+ /** Supported provider family taxonomy. */
8
+ export type ProviderFamily = 'anthropic' | 'bedrock' | 'gemini' | 'openai' | 'xai';
9
+ /** Reasoning and thinking budget level for models supporting extended thinking. */
10
+ export type ThinkingLevel = 'MINIMAL' | 'LOW' | 'MEDIUM' | 'HIGH' | 'MAX';
11
+ /** Definition of a supported model in the Reboot catalog. */
12
+ export interface RebootModelDefinition {
13
+ /** Target model identifier. */
14
+ readonly id: string;
15
+ /** Canonical canonicalized model identifier. */
16
+ readonly canonicalId: string;
17
+ /** Display name. */
18
+ readonly name: string;
19
+ /** Provider family handling request serialization. */
20
+ readonly family: ProviderFamily;
21
+ /** Context window capacity in tokens. */
22
+ readonly contextWindow: number;
23
+ /** Maximum output tokens. */
24
+ readonly maxTokens: number;
25
+ /** Input and output modalities supported by the model. */
26
+ readonly modalities: readonly ModelModality[];
27
+ /** Whether the model supports extended thinking or reasoning. */
28
+ readonly supportsThinking: boolean;
29
+ /** Default reasoning budget level. */
30
+ readonly defaultThinkingLevel?: ThinkingLevel | undefined;
31
+ /** Supported thinking levels. */
32
+ readonly supportedThinkingLevels?: readonly ThinkingLevel[] | undefined;
33
+ /** Aliases resolving to this model definition. */
34
+ readonly aliases?: readonly string[] | undefined;
35
+ /** Whether this model is currently enabled for discovery and invocation. */
36
+ readonly enabled?: boolean | undefined;
37
+ }
38
+ /** Agent gateway configuration options. */
39
+ export interface RebootAgentConfig {
40
+ /**
41
+ * Root API URL of the upstream Reboot AI gateway.
42
+ *
43
+ * @default 'https://api.machina.ai'
44
+ */
45
+ readonly agent_api_url?: string | undefined;
46
+ /**
47
+ * Request timeout in seconds.
48
+ *
49
+ * @default 1200
50
+ */
51
+ readonly timeout_seconds?: number | undefined;
52
+ }
53
+ /** Plugin configuration schema for Reboot LLM Provider. */
54
+ export interface RebootLlmConfig {
55
+ /** Agent gateway connection parameters. */
56
+ readonly agent?: RebootAgentConfig | undefined;
57
+ /**
58
+ * Default startup model or alias when none is specified.
59
+ *
60
+ * @default 'auto-gemini-3.8'
61
+ */
62
+ readonly default_model?: string | undefined;
63
+ /**
64
+ * Provider name registered into Cordis LLM runtime.
65
+ *
66
+ * @default 'reboot'
67
+ */
68
+ readonly provider_name?: string | undefined;
69
+ /**
70
+ * Whether to enable multi-tier dynamic alias routing.
71
+ *
72
+ * @default true
73
+ */
74
+ readonly enable_dynamic_routing?: boolean | undefined;
75
+ /** Retry and backoff policy for upstream HTTP calls. */
76
+ readonly retryPolicy?: RetryPolicyConfig | undefined;
77
+ }
78
+ /** Resolved and validated configuration for Reboot LLM Provider. */
79
+ export interface ResolvedRebootLlmConfig {
80
+ /** Resolved agent gateway settings. */
81
+ readonly agent: {
82
+ readonly agent_api_url: string;
83
+ readonly timeout_seconds: number;
84
+ };
85
+ /** Resolved default model identifier. */
86
+ readonly default_model: string;
87
+ /** Resolved provider registration name. */
88
+ readonly provider_name: string;
89
+ /** Resolved dynamic routing flag. */
90
+ readonly enable_dynamic_routing: boolean;
91
+ /** Resolved retry and backoff policy. */
92
+ readonly retryPolicy: ResolvedRetryPolicy;
93
+ }
94
+ /** Resolved endpoint URL and provider family for a model request. */
95
+ export interface ResolvedEndpointRoute {
96
+ /** Target provider family. */
97
+ readonly family: ProviderFamily;
98
+ /** Upstream model identifier. */
99
+ readonly modelId: string;
100
+ /** Fully qualified target URL. */
101
+ readonly targetUrl: string;
102
+ }
103
+ //# sourceMappingURL=types.d.ts.map
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@machina.ai/ch-llm-reboot",
3
+ "version": "0.1.5-alpha.1.c1",
4
+ "license": "MIT",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "description": "Zero-API-Key multi-model LLM provider plugin for DeepSeek Harness routed through Reboot AI Gateway",
9
+ "type": "module",
10
+ "main": "lib/index.js",
11
+ "types": "lib/types/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./lib/types/index.d.ts",
15
+ "default": "./lib/index.js"
16
+ },
17
+ "./src/*": "./src/*",
18
+ "./package.json": "./package.json"
19
+ },
20
+ "files": [
21
+ "lib/index.js",
22
+ "lib/types/**/*.d.ts"
23
+ ],
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/deepseek-ai/deepseek-harness.git",
27
+ "directory": "packages/llm/llm-reboot"
28
+ },
29
+ "peerDependencies": {
30
+ "@deepseek-ai/cordis": "^4.0.2"
31
+ },
32
+ "dependencies": {
33
+ "@deepseek-ai/dsh-timeout": "0.1.5-alpha.1",
34
+ "@deepseek-ai/dsh-llm": "0.1.5-alpha.1",
35
+ "@deepseek-ai/dsh-util-values": "0.1.5-alpha.1",
36
+ "@machina.ai/ch-auth-reboot-sso": "^0.1.5-alpha.1.c1",
37
+ "@deepseek-ai/schemastery": "3.18.2"
38
+ },
39
+ "devDependencies": {
40
+ "@deepseek-ai/dsh-llm": "^0.1.5-alpha.1",
41
+ "@deepseek-ai/cordis": "^4.0.2",
42
+ "@machina.ai/ch-auth-reboot-sso": "^0.1.5-alpha.1.c1",
43
+ "@deepseek-ai/dsh-timeout": "^0.1.5-alpha.1",
44
+ "@deepseek-ai/dsh-util-values": "^0.1.5-alpha.1",
45
+ "@deepseek-ai/schemastery": "^3.18.2"
46
+ }
47
+ }