@xybrid/react-native 0.10.0-rc1
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.
- package/LICENSE +201 -0
- package/README.md +298 -0
- package/android/build.gradle +61 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/ai/xybrid/reactnative/XybridCodec.kt +481 -0
- package/android/src/main/java/ai/xybrid/reactnative/XybridHandles.kt +139 -0
- package/android/src/main/java/ai/xybrid/reactnative/XybridModule.kt +665 -0
- package/android/src/main/java/ai/xybrid/reactnative/XybridPackage.kt +27 -0
- package/ios/XybridCodec.swift +508 -0
- package/ios/XybridHandles.swift +191 -0
- package/ios/XybridModule.mm +494 -0
- package/ios/XybridModuleImpl.swift +887 -0
- package/ios/XybridSwift/Xybrid.swift +1401 -0
- package/ios/XybridSwift/xybrid_bolt.swift +3198 -0
- package/ios/xybrid_natives.rb +178 -0
- package/lib/commonjs/NativeXybrid.js +24 -0
- package/lib/commonjs/base64.js +45 -0
- package/lib/commonjs/cancel.js +35 -0
- package/lib/commonjs/context.js +67 -0
- package/lib/commonjs/envelope.js +79 -0
- package/lib/commonjs/errors.js +61 -0
- package/lib/commonjs/index.js +59 -0
- package/lib/commonjs/model.js +307 -0
- package/lib/commonjs/pipeline.js +55 -0
- package/lib/commonjs/presets.js +32 -0
- package/lib/commonjs/session.js +76 -0
- package/lib/commonjs/types.js +10 -0
- package/lib/commonjs/wire.js +285 -0
- package/lib/commonjs/xybrid.js +133 -0
- package/lib/module/NativeXybrid.js +22 -0
- package/lib/module/base64.js +41 -0
- package/lib/module/cancel.js +29 -0
- package/lib/module/context.js +60 -0
- package/lib/module/envelope.js +73 -0
- package/lib/module/errors.js +56 -0
- package/lib/module/index.js +36 -0
- package/lib/module/model.js +298 -0
- package/lib/module/pipeline.js +48 -0
- package/lib/module/presets.js +27 -0
- package/lib/module/session.js +69 -0
- package/lib/module/types.js +9 -0
- package/lib/module/wire.js +271 -0
- package/lib/module/xybrid.js +127 -0
- package/lib/typescript/NativeXybrid.d.ts +68 -0
- package/lib/typescript/NativeXybrid.d.ts.map +1 -0
- package/lib/typescript/base64.d.ts +5 -0
- package/lib/typescript/base64.d.ts.map +1 -0
- package/lib/typescript/cancel.d.ts +24 -0
- package/lib/typescript/cancel.d.ts.map +1 -0
- package/lib/typescript/context.d.ts +40 -0
- package/lib/typescript/context.d.ts.map +1 -0
- package/lib/typescript/envelope.d.ts +51 -0
- package/lib/typescript/envelope.d.ts.map +1 -0
- package/lib/typescript/errors.d.ts +12 -0
- package/lib/typescript/errors.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +28 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/model.d.ts +211 -0
- package/lib/typescript/model.d.ts.map +1 -0
- package/lib/typescript/pipeline.d.ts +35 -0
- package/lib/typescript/pipeline.d.ts.map +1 -0
- package/lib/typescript/presets.d.ts +21 -0
- package/lib/typescript/presets.d.ts.map +1 -0
- package/lib/typescript/session.d.ts +50 -0
- package/lib/typescript/session.d.ts.map +1 -0
- package/lib/typescript/types.d.ts +313 -0
- package/lib/typescript/types.d.ts.map +1 -0
- package/lib/typescript/wire.d.ts +130 -0
- package/lib/typescript/wire.d.ts.map +1 -0
- package/lib/typescript/xybrid.d.ts +89 -0
- package/lib/typescript/xybrid.d.ts.map +1 -0
- package/package.json +88 -0
- package/react-native-xybrid.podspec +50 -0
- package/src/NativeXybrid.ts +131 -0
- package/src/base64.ts +43 -0
- package/src/cancel.ts +47 -0
- package/src/context.ts +70 -0
- package/src/envelope.ts +115 -0
- package/src/errors.ts +67 -0
- package/src/index.ts +91 -0
- package/src/model.ts +408 -0
- package/src/pipeline.ts +66 -0
- package/src/presets.ts +36 -0
- package/src/session.ts +76 -0
- package/src/types.ts +362 -0
- package/src/wire.ts +408 -0
- package/src/xybrid.ts +176 -0
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
/** Thermal band pushed to the routing engine. */
|
|
2
|
+
export type ThermalState = 'normal' | 'warm' | 'hot' | 'critical';
|
|
3
|
+
/** LLM message role, stored as `xybrid.role` envelope metadata. */
|
|
4
|
+
export type MessageRole = 'system' | 'user' | 'assistant';
|
|
5
|
+
/** Image encodings accepted by vision-language models. */
|
|
6
|
+
export type ImageFormat = 'png' | 'jpeg' | 'webp';
|
|
7
|
+
/** Free-form envelope metadata. Well-known keys have typed fields instead. */
|
|
8
|
+
export type EnvelopeMetadata = Record<string, string>;
|
|
9
|
+
interface EnvelopeBase {
|
|
10
|
+
/** LLM message role (`xybrid.role` metadata). */
|
|
11
|
+
role?: MessageRole;
|
|
12
|
+
/** Raw metadata entries; typed fields win when both are set. */
|
|
13
|
+
metadata?: EnvelopeMetadata;
|
|
14
|
+
}
|
|
15
|
+
/** Text input: an LLM prompt, or text to speak for TTS models. */
|
|
16
|
+
export interface TextEnvelope extends EnvelopeBase {
|
|
17
|
+
kind: 'text';
|
|
18
|
+
text: string;
|
|
19
|
+
/** TTS voice (`voice_id` metadata). */
|
|
20
|
+
voiceId?: string;
|
|
21
|
+
/** TTS speed multiplier (`speed` metadata). */
|
|
22
|
+
speed?: number;
|
|
23
|
+
}
|
|
24
|
+
/** Audio input or output: PCM/WAV bytes. */
|
|
25
|
+
export interface AudioEnvelope extends EnvelopeBase {
|
|
26
|
+
kind: 'audio';
|
|
27
|
+
/** PCM/WAV bytes, base64-encoded. */
|
|
28
|
+
bytesBase64: string;
|
|
29
|
+
/** Sample rate in Hz (`sample_rate` metadata). Defaults to 16000 on input. */
|
|
30
|
+
sampleRate?: number;
|
|
31
|
+
/** Channel count (`channels` metadata). Defaults to 1 on input. */
|
|
32
|
+
channels?: number;
|
|
33
|
+
}
|
|
34
|
+
/** An embedding vector. */
|
|
35
|
+
export interface EmbeddingEnvelope extends EnvelopeBase {
|
|
36
|
+
kind: 'embedding';
|
|
37
|
+
data: number[];
|
|
38
|
+
}
|
|
39
|
+
/** An encoded image for vision-language models. */
|
|
40
|
+
export interface ImageEnvelope extends EnvelopeBase {
|
|
41
|
+
kind: 'image';
|
|
42
|
+
/** PNG, JPEG or WebP bytes, base64-encoded. */
|
|
43
|
+
bytesBase64: string;
|
|
44
|
+
format: ImageFormat;
|
|
45
|
+
}
|
|
46
|
+
/** A multi-part message, e.g. a prompt plus image attachments. */
|
|
47
|
+
export interface MultiPartEnvelope extends EnvelopeBase {
|
|
48
|
+
kind: 'multipart';
|
|
49
|
+
parts: Envelope[];
|
|
50
|
+
}
|
|
51
|
+
/** Input to (and output of) a model. Narrow on `kind`. */
|
|
52
|
+
export type Envelope = TextEnvelope | AudioEnvelope | EmbeddingEnvelope | ImageEnvelope | MultiPartEnvelope;
|
|
53
|
+
/** The payload kinds an {@link Envelope} can carry. */
|
|
54
|
+
export type EnvelopeKind = Envelope['kind'];
|
|
55
|
+
/** A tool (function) the model may ask to call. */
|
|
56
|
+
export interface ToolDefinition {
|
|
57
|
+
name: string;
|
|
58
|
+
description: string;
|
|
59
|
+
/**
|
|
60
|
+
* JSON Schema of the arguments, as an object or a JSON string. Crosses the
|
|
61
|
+
* boundary as a string (`parametersJson` in the other SDKs).
|
|
62
|
+
*/
|
|
63
|
+
parameters: object | string;
|
|
64
|
+
}
|
|
65
|
+
/** A tool call the model emitted. */
|
|
66
|
+
export interface ToolCall {
|
|
67
|
+
/** Echo this back as {@link ToolResult.callId}. */
|
|
68
|
+
id: string;
|
|
69
|
+
name: string;
|
|
70
|
+
/** Arguments as a JSON string, exactly as the model produced them. */
|
|
71
|
+
argumentsJson: string;
|
|
72
|
+
}
|
|
73
|
+
/** The outcome of running one tool, fed back with `Envelope.toolResults`. */
|
|
74
|
+
export interface ToolResult {
|
|
75
|
+
/** The {@link ToolCall.id} this answers. */
|
|
76
|
+
callId: string;
|
|
77
|
+
name: string;
|
|
78
|
+
/**
|
|
79
|
+
* The tool's output: any JSON-serializable value, or an already-encoded
|
|
80
|
+
* JSON string.
|
|
81
|
+
*/
|
|
82
|
+
content: unknown;
|
|
83
|
+
}
|
|
84
|
+
/** Sampling parameters for LLM inference. Unset fields use model defaults. */
|
|
85
|
+
export interface GenerationConfig {
|
|
86
|
+
maxTokens?: number;
|
|
87
|
+
temperature?: number;
|
|
88
|
+
topP?: number;
|
|
89
|
+
minP?: number;
|
|
90
|
+
topK?: number;
|
|
91
|
+
repetitionPenalty?: number;
|
|
92
|
+
stopSequences?: string[];
|
|
93
|
+
/**
|
|
94
|
+
* GBNF grammar constraining output (local llama backend only). Build one
|
|
95
|
+
* from a JSON Schema with `jsonSchemaToGbnf`, or pass raw GBNF.
|
|
96
|
+
*/
|
|
97
|
+
grammar?: string;
|
|
98
|
+
/** Tools the model may call this turn. Empty means no tool calling. */
|
|
99
|
+
tools?: ToolDefinition[];
|
|
100
|
+
}
|
|
101
|
+
/** Device-stress signals that abort a run early (bolt `XybridAbortSignal`). */
|
|
102
|
+
export type AbortSignalKind = 'memoryPressureWarn' | 'memoryPressureCritical' | 'thermalHot' | 'thermalCritical';
|
|
103
|
+
/** Where a result was produced — observed fact, not a routing preference. */
|
|
104
|
+
export type ExecutionTarget = 'local' | 'cloud';
|
|
105
|
+
/** What kind of payload a model produces. */
|
|
106
|
+
export type OutputType = 'text' | 'audio' | 'embedding' | 'unknown';
|
|
107
|
+
/** Latency of one pipeline stage. */
|
|
108
|
+
export interface StageLatency {
|
|
109
|
+
stageId: string;
|
|
110
|
+
latencyMs: number;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Measurements from the native runtime. LLM-only values are absent when the
|
|
114
|
+
* model or backend does not report them.
|
|
115
|
+
*/
|
|
116
|
+
export interface InferenceMetrics {
|
|
117
|
+
/** Total wall-clock inference time in milliseconds. */
|
|
118
|
+
totalMs: number;
|
|
119
|
+
/** Time to first generated token in milliseconds. */
|
|
120
|
+
ttftMs?: number;
|
|
121
|
+
/** Overall generated-token throughput. */
|
|
122
|
+
tokensPerSecond?: number;
|
|
123
|
+
/** Prompt-processing throughput. */
|
|
124
|
+
prefillTps?: number;
|
|
125
|
+
/** Generated-token decode throughput. */
|
|
126
|
+
decodeTps?: number;
|
|
127
|
+
/** Number of generated tokens. */
|
|
128
|
+
tokensOut?: number;
|
|
129
|
+
/** Per-stage measurements in native execution order. */
|
|
130
|
+
stageLatenciesMs: StageLatency[];
|
|
131
|
+
}
|
|
132
|
+
/** The result of one inference. */
|
|
133
|
+
export interface InferenceResult {
|
|
134
|
+
/** The output, losslessly (payload plus metadata). */
|
|
135
|
+
envelope: Envelope;
|
|
136
|
+
outputType: OutputType;
|
|
137
|
+
/** The model that answered — identical on the local and cloud legs. */
|
|
138
|
+
modelId: string;
|
|
139
|
+
/** Text output, when the model produced text. */
|
|
140
|
+
text?: string;
|
|
141
|
+
/** Audio output (base64), when the model produced audio. */
|
|
142
|
+
audioBytesBase64?: string;
|
|
143
|
+
/** Embedding output, when the model produced one. */
|
|
144
|
+
embedding?: number[];
|
|
145
|
+
/**
|
|
146
|
+
* Chain-of-thought (`<think>` blocks) surfaced separately from `text`,
|
|
147
|
+
* which never includes it. Absent when the model emitted none.
|
|
148
|
+
*/
|
|
149
|
+
reasoningContent?: string;
|
|
150
|
+
/** Tool calls the model emitted this turn. Empty unless tools were offered. */
|
|
151
|
+
toolCalls: ToolCall[];
|
|
152
|
+
latencyMs: number;
|
|
153
|
+
metrics: InferenceMetrics;
|
|
154
|
+
/** Where this answer actually came from. */
|
|
155
|
+
executionTarget: ExecutionTarget;
|
|
156
|
+
}
|
|
157
|
+
/** One token from a streaming run. */
|
|
158
|
+
export interface StreamToken {
|
|
159
|
+
/** The decoded text of this step. */
|
|
160
|
+
token: string;
|
|
161
|
+
/** Raw token id, when the backend exposes one. */
|
|
162
|
+
tokenId?: number;
|
|
163
|
+
/** Zero-based position in the generated sequence. */
|
|
164
|
+
index: number;
|
|
165
|
+
/** Every emitted token so far, concatenated (tool-call blocks suppressed). */
|
|
166
|
+
cumulativeText: string;
|
|
167
|
+
/**
|
|
168
|
+
* Set on the final token only: `'stop'`, `'length'`, or `'tool_calls'`
|
|
169
|
+
* when the turn ended on a tool-call block.
|
|
170
|
+
*/
|
|
171
|
+
finishReason?: string;
|
|
172
|
+
/** Tool calls parsed from the turn — terminal token only. */
|
|
173
|
+
toolCalls: ToolCall[];
|
|
174
|
+
/**
|
|
175
|
+
* The turn's raw output, tool-call block included — pass it to
|
|
176
|
+
* `Envelope.toolResults` as `priorAssistantText`. Present only alongside
|
|
177
|
+
* `toolCalls`.
|
|
178
|
+
*/
|
|
179
|
+
rawText?: string;
|
|
180
|
+
}
|
|
181
|
+
/** Lifecycle of a model download. */
|
|
182
|
+
export type DownloadState = 'downloading' | 'ready' | 'failed' | 'cancelled';
|
|
183
|
+
/**
|
|
184
|
+
* Download progress, bytes and state in one consistent read. `progress` is
|
|
185
|
+
* aggregated across every artifact, never moves backwards, and reaches 1.0
|
|
186
|
+
* only alongside `ready`.
|
|
187
|
+
*/
|
|
188
|
+
export interface DownloadStatus {
|
|
189
|
+
state: DownloadState;
|
|
190
|
+
/** 0.0 to 1.0. */
|
|
191
|
+
progress: number;
|
|
192
|
+
/** Bytes written so far, across every artifact. */
|
|
193
|
+
downloadedBytes: number;
|
|
194
|
+
/**
|
|
195
|
+
* Declared total across every artifact; absent when the source publishes
|
|
196
|
+
* no size (a Hugging Face repo, or a registry entry without one).
|
|
197
|
+
*/
|
|
198
|
+
totalBytes?: number;
|
|
199
|
+
}
|
|
200
|
+
/** A TTS voice. */
|
|
201
|
+
export interface VoiceInfo {
|
|
202
|
+
id: string;
|
|
203
|
+
name: string;
|
|
204
|
+
gender?: string;
|
|
205
|
+
language?: string;
|
|
206
|
+
style?: string;
|
|
207
|
+
}
|
|
208
|
+
/** Identity and capabilities of a loaded model. */
|
|
209
|
+
export interface ModelInfo {
|
|
210
|
+
/** Registry / metadata id — not the native handle. */
|
|
211
|
+
modelId: string;
|
|
212
|
+
version: string;
|
|
213
|
+
outputType: OutputType;
|
|
214
|
+
isLlm: boolean;
|
|
215
|
+
supportsStreaming: boolean;
|
|
216
|
+
/** Whether the model emits true token-by-token output. */
|
|
217
|
+
supportsTokenStreaming: boolean;
|
|
218
|
+
/**
|
|
219
|
+
* Whether the bundle declares tool-calling support; `null` when it says
|
|
220
|
+
* nothing. Advisory — enforcement happens at run time.
|
|
221
|
+
*/
|
|
222
|
+
supportsToolCalling: boolean | null;
|
|
223
|
+
hasVoices: boolean;
|
|
224
|
+
/** The model's resolved generation defaults. */
|
|
225
|
+
defaultGenerationConfig: GenerationConfig;
|
|
226
|
+
}
|
|
227
|
+
/** Where a physical cache entry lives. */
|
|
228
|
+
export type CacheEntryLocation = 'registry' | 'extracted' | 'huggingFace' | 'huggingFaceHub';
|
|
229
|
+
/** One physical model entry in managed cache storage. */
|
|
230
|
+
export interface CacheEntry {
|
|
231
|
+
modelId: string;
|
|
232
|
+
location: CacheEntryLocation;
|
|
233
|
+
path: string;
|
|
234
|
+
sizeBytes: number;
|
|
235
|
+
}
|
|
236
|
+
/** Aggregate storage usage across every managed cache location. */
|
|
237
|
+
export interface CacheStatus {
|
|
238
|
+
totalSizeBytes: number;
|
|
239
|
+
entryCount: number;
|
|
240
|
+
modelCount: number;
|
|
241
|
+
extractedModelCount: number;
|
|
242
|
+
cacheRoot: string;
|
|
243
|
+
}
|
|
244
|
+
/** Snapshot of a conversation context. */
|
|
245
|
+
export interface ConversationInfo {
|
|
246
|
+
id: string;
|
|
247
|
+
/** History turns, excluding the system envelope. */
|
|
248
|
+
historyLength: number;
|
|
249
|
+
hasSystem: boolean;
|
|
250
|
+
}
|
|
251
|
+
/** What one pipeline stage produced. */
|
|
252
|
+
export interface StageResult {
|
|
253
|
+
/** The YAML `id:` (or the model id when the stage declares none). */
|
|
254
|
+
stageId: string;
|
|
255
|
+
/** This stage's output — also the next stage's input. */
|
|
256
|
+
envelope: Envelope;
|
|
257
|
+
outputType: OutputType;
|
|
258
|
+
text?: string;
|
|
259
|
+
audioBytesBase64?: string;
|
|
260
|
+
latencyMs: number;
|
|
261
|
+
/** Stages of one pipeline can run in different places. */
|
|
262
|
+
executionTarget: ExecutionTarget;
|
|
263
|
+
metrics: InferenceMetrics;
|
|
264
|
+
}
|
|
265
|
+
/** Result of a pipeline run: the final output plus every stage's own. */
|
|
266
|
+
export interface PipelineResult {
|
|
267
|
+
/** The final stage's output. */
|
|
268
|
+
envelope: Envelope;
|
|
269
|
+
outputType: OutputType;
|
|
270
|
+
text?: string;
|
|
271
|
+
audioBytesBase64?: string;
|
|
272
|
+
/** Wall-clock time of the whole run. */
|
|
273
|
+
latencyMs: number;
|
|
274
|
+
/** Every executed stage, in order. */
|
|
275
|
+
stages: StageResult[];
|
|
276
|
+
}
|
|
277
|
+
/** Static description of a loaded pipeline. */
|
|
278
|
+
export interface PipelineInfo {
|
|
279
|
+
name: string | null;
|
|
280
|
+
stageNames: string[];
|
|
281
|
+
stageCount: number;
|
|
282
|
+
}
|
|
283
|
+
/** Chunking options for a live ASR session. */
|
|
284
|
+
export interface StreamingConfig {
|
|
285
|
+
/** Must be 16000 — the ASR backends are fixed there. Default 16000. */
|
|
286
|
+
sampleRate?: number;
|
|
287
|
+
/**
|
|
288
|
+
* Chunk on speech boundaries with a Silero VAD model in `modelDir`
|
|
289
|
+
* (containing `model.onnx`). Omit for fixed time windows.
|
|
290
|
+
*/
|
|
291
|
+
vad?: {
|
|
292
|
+
modelDir: string;
|
|
293
|
+
} | null;
|
|
294
|
+
/** VAD sensitivity, 0.0–1.0. Default 0.5. Ignored without `vad`. */
|
|
295
|
+
vadThreshold?: number;
|
|
296
|
+
/** Language hint such as `'en'`; omit for the model default. */
|
|
297
|
+
language?: string;
|
|
298
|
+
/** Whisper encoder context in mel frames; omit for the model default. */
|
|
299
|
+
audioCtx?: number;
|
|
300
|
+
}
|
|
301
|
+
/** A partial transcript from a live ASR session. */
|
|
302
|
+
export interface PartialResult {
|
|
303
|
+
/** Transcript so far. Cumulative — replace the previous partial. */
|
|
304
|
+
text: string;
|
|
305
|
+
/** `true` once this span is committed and will not change. */
|
|
306
|
+
isStable: boolean;
|
|
307
|
+
/** Monotonic chunk sequence number. */
|
|
308
|
+
chunkSequence: number;
|
|
309
|
+
/** Audio covered so far, in milliseconds. */
|
|
310
|
+
audioDurationMs: number;
|
|
311
|
+
}
|
|
312
|
+
export {};
|
|
313
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AASA,iDAAiD;AACjD,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,UAAU,CAAC;AAElE,mEAAmE;AACnE,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAC;AAE1D,0DAA0D;AAC1D,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;AAElD,8EAA8E;AAC9E,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEtD,UAAU,YAAY;IACpB,iDAAiD;IACjD,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,gEAAgE;IAChE,QAAQ,CAAC,EAAE,gBAAgB,CAAC;CAC7B;AAED,kEAAkE;AAClE,MAAM,WAAW,YAAa,SAAQ,YAAY;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,uCAAuC;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,4CAA4C;AAC5C,MAAM,WAAW,aAAc,SAAQ,YAAY;IACjD,IAAI,EAAE,OAAO,CAAC;IACd,qCAAqC;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,8EAA8E;IAC9E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mEAAmE;IACnE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,2BAA2B;AAC3B,MAAM,WAAW,iBA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PipelineResult, StreamToken, ToolCall, ToolDefinition, ToolResult } from './types';
|
|
2
|
+
export type WireEnvelope = {
|
|
3
|
+
kind: 'text';
|
|
4
|
+
text: string;
|
|
5
|
+
metadata: EnvelopeMetadata;
|
|
6
|
+
} | {
|
|
7
|
+
kind: 'audio';
|
|
8
|
+
bytesBase64: string;
|
|
9
|
+
metadata: EnvelopeMetadata;
|
|
10
|
+
} | {
|
|
11
|
+
kind: 'embedding';
|
|
12
|
+
data: number[];
|
|
13
|
+
metadata: EnvelopeMetadata;
|
|
14
|
+
} | {
|
|
15
|
+
kind: 'image';
|
|
16
|
+
bytesBase64: string;
|
|
17
|
+
format: string;
|
|
18
|
+
metadata: EnvelopeMetadata;
|
|
19
|
+
} | {
|
|
20
|
+
kind: 'multipart';
|
|
21
|
+
parts: WireEnvelope[];
|
|
22
|
+
metadata: EnvelopeMetadata;
|
|
23
|
+
};
|
|
24
|
+
export interface WireToolDefinition {
|
|
25
|
+
name: string;
|
|
26
|
+
description: string;
|
|
27
|
+
parametersJson: string;
|
|
28
|
+
}
|
|
29
|
+
export interface WireGenerationConfig {
|
|
30
|
+
maxTokens?: number;
|
|
31
|
+
temperature?: number;
|
|
32
|
+
topP?: number;
|
|
33
|
+
minP?: number;
|
|
34
|
+
topK?: number;
|
|
35
|
+
repetitionPenalty?: number;
|
|
36
|
+
stopSequences?: string[];
|
|
37
|
+
grammar?: string;
|
|
38
|
+
tools?: WireToolDefinition[];
|
|
39
|
+
}
|
|
40
|
+
export interface WireRunOptions {
|
|
41
|
+
generationConfig?: WireGenerationConfig;
|
|
42
|
+
abortOn?: string[];
|
|
43
|
+
fallbackToCloud?: boolean;
|
|
44
|
+
maxGraceTokens?: number;
|
|
45
|
+
correlationId?: string;
|
|
46
|
+
/** Conversation-context handle. */
|
|
47
|
+
context?: string;
|
|
48
|
+
/** Cancellation-token handle. */
|
|
49
|
+
cancel?: string;
|
|
50
|
+
}
|
|
51
|
+
export interface WireResult {
|
|
52
|
+
envelope: WireEnvelope;
|
|
53
|
+
outputType: OutputType;
|
|
54
|
+
modelId: string;
|
|
55
|
+
latencyMs: number;
|
|
56
|
+
executionTarget: 'local' | 'cloud';
|
|
57
|
+
metrics: InferenceMetrics;
|
|
58
|
+
toolCalls: ToolCall[];
|
|
59
|
+
reasoningContent?: string;
|
|
60
|
+
}
|
|
61
|
+
export interface WireStreamToken {
|
|
62
|
+
token: string;
|
|
63
|
+
tokenId?: number;
|
|
64
|
+
index: number;
|
|
65
|
+
cumulativeText: string;
|
|
66
|
+
finishReason?: string;
|
|
67
|
+
toolCalls: ToolCall[];
|
|
68
|
+
rawText?: string;
|
|
69
|
+
}
|
|
70
|
+
export type WireStreamEvent = {
|
|
71
|
+
kind: 'token';
|
|
72
|
+
token: WireStreamToken;
|
|
73
|
+
} | {
|
|
74
|
+
kind: 'complete';
|
|
75
|
+
result: WireResult;
|
|
76
|
+
};
|
|
77
|
+
export interface WireStageResult {
|
|
78
|
+
stageId: string;
|
|
79
|
+
envelope: WireEnvelope;
|
|
80
|
+
outputType: OutputType;
|
|
81
|
+
latencyMs: number;
|
|
82
|
+
executionTarget: 'local' | 'cloud';
|
|
83
|
+
metrics: InferenceMetrics;
|
|
84
|
+
}
|
|
85
|
+
export interface WirePipelineResult {
|
|
86
|
+
envelope: WireEnvelope;
|
|
87
|
+
outputType: OutputType;
|
|
88
|
+
latencyMs: number;
|
|
89
|
+
stages: WireStageResult[];
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Fold an envelope's convenience fields into metadata. Typed fields win over
|
|
93
|
+
* raw `metadata` entries for the same key; audio input defaults to 16 kHz
|
|
94
|
+
* mono, like the Swift and Kotlin `Envelope.audio` factories.
|
|
95
|
+
*/
|
|
96
|
+
export declare function toWireEnvelope(envelope: Envelope): WireEnvelope;
|
|
97
|
+
/** Lift well-known metadata keys back into typed fields. Lossless. */
|
|
98
|
+
export declare function fromWireEnvelope(wire: WireEnvelope): Envelope;
|
|
99
|
+
/** Accept `jpg` as an alias and reject anything the core cannot decode. */
|
|
100
|
+
export declare function normalizeImageFormat(format: string): 'png' | 'jpeg' | 'webp';
|
|
101
|
+
export declare function toWireToolDefinition(tool: ToolDefinition): WireToolDefinition;
|
|
102
|
+
export declare function toWireGenerationConfig(config: GenerationConfig): WireGenerationConfig;
|
|
103
|
+
export declare function fromWireGenerationConfig(wire: WireGenerationConfig): GenerationConfig;
|
|
104
|
+
/** Inputs to {@link toWireRunOptions}: the serializable `RunOptions` fields. */
|
|
105
|
+
export interface RunOptionsInput {
|
|
106
|
+
generationConfig?: GenerationConfig;
|
|
107
|
+
abortOn?: string[];
|
|
108
|
+
fallbackToCloud?: boolean;
|
|
109
|
+
maxGraceTokens?: number;
|
|
110
|
+
correlationId?: string;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Build the wire options. Sampling parameters must sit under
|
|
114
|
+
* `generationConfig`; passing them at the top level is a mistake that would
|
|
115
|
+
* otherwise be silently ignored, so it throws.
|
|
116
|
+
*/
|
|
117
|
+
export declare function toWireRunOptions(options: RunOptionsInput | undefined, handles?: {
|
|
118
|
+
context?: string | null;
|
|
119
|
+
cancel?: string | null;
|
|
120
|
+
}): WireRunOptions | null;
|
|
121
|
+
export declare function toWireToolResult(result: ToolResult): {
|
|
122
|
+
callId: string;
|
|
123
|
+
name: string;
|
|
124
|
+
contentJson: string;
|
|
125
|
+
};
|
|
126
|
+
export declare function fromWireResult(wire: WireResult): InferenceResult;
|
|
127
|
+
export declare function fromWireStreamToken(wire: WireStreamToken): StreamToken;
|
|
128
|
+
export declare function fromWirePipelineResult(wire: WirePipelineResult): PipelineResult;
|
|
129
|
+
export declare function fromWireDownloadStatus(wire: DownloadStatus): DownloadStatus;
|
|
130
|
+
//# sourceMappingURL=wire.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wire.d.ts","sourceRoot":"","sources":["../../src/wire.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,cAAc,EACd,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IACpD,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB,CAOA;AAsBD,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,GAAG,eAAe,CAYhE;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,eAAe,GAAG,WAAW,CAEtE;AAkBD,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,kBAAkB,GAAG,cAAc,CAY/E;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,cAAc,GAAG,cAAc,CAK3E"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { ModelLoader } from './model';
|
|
2
|
+
import type { CacheEntry, CacheStatus, ThermalState } from './types';
|
|
3
|
+
/** Options for {@link Xybrid.initialize}. All optional. */
|
|
4
|
+
export interface XybridInitOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Xybrid API key. Enables the platform features on top of local inference:
|
|
7
|
+
* telemetry to the dashboard, cloud fallback, speculative cloud serving.
|
|
8
|
+
* Get one at https://dashboard.xybrid.dev.
|
|
9
|
+
*/
|
|
10
|
+
apiKey?: string;
|
|
11
|
+
/** Override the LLM gateway URL (full URL including `/v1`). */
|
|
12
|
+
gatewayUrl?: string;
|
|
13
|
+
/** Override the telemetry ingest URL (self-hosted dashboards). */
|
|
14
|
+
ingestUrl?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Where downloaded models live. Defaults to `<Caches>/xybrid/models` on
|
|
17
|
+
* iOS and `<filesDir>/xybrid/models` on Android. Only honoured when
|
|
18
|
+
* `initialize` is the first Xybrid call of the process.
|
|
19
|
+
*/
|
|
20
|
+
cacheDir?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Process-wide SDK entry points. Local inference needs no setup at all —
|
|
24
|
+
* `initialize` only matters for the optional platform features.
|
|
25
|
+
*/
|
|
26
|
+
export declare const Xybrid: {
|
|
27
|
+
/**
|
|
28
|
+
* Apply process-wide configuration. The SDK otherwise configures itself
|
|
29
|
+
* anonymously on first use, so call this before anything else when you
|
|
30
|
+
* have options. Configuration is applied once per app process: repeating
|
|
31
|
+
* it with the same options resolves, with different options rejects
|
|
32
|
+
* (`xybrid_config_error`) — restart the app to change them.
|
|
33
|
+
*/
|
|
34
|
+
initialize(options?: XybridInitOptions): Promise<void>;
|
|
35
|
+
/** Whether {@link initialize} has resolved in this JS context. */
|
|
36
|
+
readonly isInitialized: boolean;
|
|
37
|
+
/** Describe a registry model without loading it (same as `ModelLoader.fromRegistry`). */
|
|
38
|
+
model(id: string): ModelLoader;
|
|
39
|
+
/** The native SDK version, e.g. `0.9.0`. */
|
|
40
|
+
version(): Promise<string>;
|
|
41
|
+
/** Whether an API key resolves, from {@link initialize} or the environment. */
|
|
42
|
+
hasApiKey(): Promise<boolean>;
|
|
43
|
+
/** Set the key for a cloud provider the gateway forwards to (not the Xybrid key). */
|
|
44
|
+
setProviderApiKey(provider: string, apiKey: string): Promise<void>;
|
|
45
|
+
/** Point the cloud gateway at a platform base URL; the `/v1` suffix is added for you. */
|
|
46
|
+
setPlatformUrl(url: string): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Default speculative cloud serving on or off for loads that don't opt in
|
|
49
|
+
* per load (`ModelLoader.fromRegistrySpeculative` always speculates). Needs
|
|
50
|
+
* an API key. LLM/chat only — prefer the per-load form when the app also
|
|
51
|
+
* loads ASR/TTS models.
|
|
52
|
+
*/
|
|
53
|
+
setSpeculativeCloud(enabled: boolean): Promise<void>;
|
|
54
|
+
isSpeculativeCloudEnabled(): Promise<boolean>;
|
|
55
|
+
/**
|
|
56
|
+
* Release every idle model's memory; resolves how many were released. Runs
|
|
57
|
+
* in flight are skipped, and a released model reloads itself on next use.
|
|
58
|
+
*/
|
|
59
|
+
releaseMemory(): Promise<number>;
|
|
60
|
+
/**
|
|
61
|
+
* Call {@link releaseMemory} on every OS memory warning (React Native
|
|
62
|
+
* `AppState` `memoryWarning`, iOS and Android). Returns the unsubscribe
|
|
63
|
+
* function.
|
|
64
|
+
*/
|
|
65
|
+
releaseMemoryOnWarning(): () => void;
|
|
66
|
+
/** Release least-recently-used idle models before loads under memory pressure. */
|
|
67
|
+
setAutoRelease(enabled: boolean): Promise<void>;
|
|
68
|
+
isAutoReleaseEnabled(): Promise<boolean>;
|
|
69
|
+
/** Push a battery percentage (0–100) to the routing engine. */
|
|
70
|
+
setBatteryLevel(percent: number): Promise<void>;
|
|
71
|
+
clearBatteryLevel(): Promise<void>;
|
|
72
|
+
setThermalState(state: ThermalState): Promise<void>;
|
|
73
|
+
clearThermalState(): Promise<void>;
|
|
74
|
+
/** Aggregate storage usage across every managed cache location. */
|
|
75
|
+
modelCacheStatus(): Promise<CacheStatus>;
|
|
76
|
+
/** Physical entries; a model can appear more than once. */
|
|
77
|
+
modelCacheEntries(): Promise<CacheEntry[]>;
|
|
78
|
+
/** Whether `modelId` occupies any cache entry. */
|
|
79
|
+
hasCachedModelData(modelId: string): Promise<boolean>;
|
|
80
|
+
/** A local path for `modelId`, or `null`. Presence does not mean extracted. */
|
|
81
|
+
cachedModelPath(modelId: string): Promise<string | null>;
|
|
82
|
+
/** Models extracted, validated and ready to run offline. */
|
|
83
|
+
extractedModelIds(): Promise<string[]>;
|
|
84
|
+
/** Remove every cache entry for `modelId`. Don't race a load of the same model. */
|
|
85
|
+
removeCachedModel(modelId: string): Promise<number>;
|
|
86
|
+
/** Clear all managed cache storage. Don't race any model load. */
|
|
87
|
+
clearModelCache(): Promise<number>;
|
|
88
|
+
};
|
|
89
|
+
//# sourceMappingURL=xybrid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xybrid.d.ts","sourceRoot":"","sources":["../../src/xybrid.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAErE,2DAA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IAIrD,+EAA+E;6BACtD,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAIxD,4DAA4D;yBACvC,OAAO,CAAC,MAAM,EAAE,CAAC;IAItC,mFAAmF;+BACxD,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAInD,kEAAkE;uBAC/C,OAAO,CAAC,MAAM,CAAC;CAGnC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xybrid/react-native",
|
|
3
|
+
"version": "0.10.0-rc1",
|
|
4
|
+
"description": "On-device (and optionally cloud) ML inference for React Native: LLM, ASR, TTS, embeddings and vision, backed by the Xybrid Rust SDK",
|
|
5
|
+
"main": "lib/commonjs/index.js",
|
|
6
|
+
"module": "lib/module/index.js",
|
|
7
|
+
"types": "lib/typescript/index.d.ts",
|
|
8
|
+
"react-native": "src/index.ts",
|
|
9
|
+
"source": "src/index.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"src",
|
|
12
|
+
"lib",
|
|
13
|
+
"android/build.gradle",
|
|
14
|
+
"android/src",
|
|
15
|
+
"ios/*.h",
|
|
16
|
+
"ios/*.mm",
|
|
17
|
+
"ios/*.swift",
|
|
18
|
+
"ios/xybrid_natives.rb",
|
|
19
|
+
"ios/XybridSwift",
|
|
20
|
+
"react-native-xybrid.podspec",
|
|
21
|
+
"README.md",
|
|
22
|
+
"LICENSE"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"typecheck": "tsc --noEmit && tsc --noEmit -p tests/types",
|
|
26
|
+
"test": "npm run typecheck && node tests/run.mjs",
|
|
27
|
+
"test:ios": "scripts/test-ios.sh",
|
|
28
|
+
"test:android": "scripts/test-android.sh",
|
|
29
|
+
"build": "rm -rf lib && tsc -p tsconfig.build.json --module commonjs --outDir lib/commonjs && tsc -p tsconfig.build.json --module esnext --outDir lib/module && tsc -p tsconfig.build.json --emitDeclarationOnly --declaration --declarationMap --outDir lib/typescript",
|
|
30
|
+
"prepack": "scripts/prepack.sh",
|
|
31
|
+
"clean": "rm -rf lib"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [
|
|
34
|
+
"react-native",
|
|
35
|
+
"ios",
|
|
36
|
+
"android",
|
|
37
|
+
"ml",
|
|
38
|
+
"ai",
|
|
39
|
+
"on-device",
|
|
40
|
+
"inference",
|
|
41
|
+
"llm",
|
|
42
|
+
"asr",
|
|
43
|
+
"tts",
|
|
44
|
+
"whisper",
|
|
45
|
+
"llama",
|
|
46
|
+
"xybrid"
|
|
47
|
+
],
|
|
48
|
+
"repository": {
|
|
49
|
+
"type": "git",
|
|
50
|
+
"url": "git+https://github.com/xybrid-ai/xybrid.git",
|
|
51
|
+
"directory": "bindings/react-native"
|
|
52
|
+
},
|
|
53
|
+
"author": "Xybrid AI <support@xybrid.dev>",
|
|
54
|
+
"license": "Apache-2.0",
|
|
55
|
+
"homepage": "https://github.com/xybrid-ai/xybrid/tree/master/bindings/react-native#readme",
|
|
56
|
+
"bugs": {
|
|
57
|
+
"url": "https://github.com/xybrid-ai/xybrid/issues"
|
|
58
|
+
},
|
|
59
|
+
"publishConfig": {
|
|
60
|
+
"access": "public"
|
|
61
|
+
},
|
|
62
|
+
"peerDependencies": {
|
|
63
|
+
"react": "*",
|
|
64
|
+
"react-native": ">=0.76.0"
|
|
65
|
+
},
|
|
66
|
+
"devDependencies": {
|
|
67
|
+
"@types/react": "^18.2.0",
|
|
68
|
+
"react": "18.3.1",
|
|
69
|
+
"react-native": "0.76.9",
|
|
70
|
+
"typescript": "^5.9.3"
|
|
71
|
+
},
|
|
72
|
+
"xybrid": {
|
|
73
|
+
"iosXcframeworkSha256": "801b4dac0bdf7b199276d8366615141ddd60e3108f6a602f94270b2730ae3a78"
|
|
74
|
+
},
|
|
75
|
+
"codegenConfig": {
|
|
76
|
+
"name": "RNXybridSpec",
|
|
77
|
+
"type": "modules",
|
|
78
|
+
"jsSrcsDir": "src",
|
|
79
|
+
"android": {
|
|
80
|
+
"javaPackageName": "ai.xybrid.reactnative"
|
|
81
|
+
},
|
|
82
|
+
"ios": {
|
|
83
|
+
"modulesProvider": {
|
|
84
|
+
"RNXybrid": "XybridModule"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|