@qvac/sdk 0.8.0 → 0.8.2
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/NOTICE +337 -0
- package/README.md +58 -294
- package/dist/client/api/cancel.d.ts +9 -0
- package/dist/client/api/cancel.js +9 -0
- package/dist/client/api/heartbeat.d.ts +30 -0
- package/dist/client/api/heartbeat.js +38 -0
- package/dist/client/api/index.d.ts +1 -1
- package/dist/client/api/index.js +1 -1
- package/dist/examples/embed-p2p.d.ts +2 -0
- package/dist/examples/llamacpp-p2p.d.ts +2 -0
- package/dist/examples/seed-p2p.d.ts +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/models/registry/models.d.ts +64 -64
- package/dist/models/registry/models.js +108 -108
- package/dist/schemas/cancel.d.ts +12 -0
- package/dist/schemas/cancel.js +2 -0
- package/dist/schemas/common.d.ts +39 -2
- package/dist/schemas/common.js +4 -3
- package/dist/schemas/delegate.d.ts +8 -0
- package/dist/schemas/delegate.js +5 -2
- package/dist/schemas/heartbeat.d.ts +17 -0
- package/dist/schemas/heartbeat.js +10 -0
- package/dist/schemas/index.d.ts +1 -1
- package/dist/schemas/index.js +1 -1
- package/dist/schemas/load-model.d.ts +113 -0
- package/dist/server/bare/delegate-rpc-client.js +42 -11
- package/dist/server/bare/plugins/nmtcpp-translation/plugin.js +1 -4
- package/dist/server/bare/registry/model-registry.d.ts +2 -0
- package/dist/server/bare/registry/model-registry.js +2 -1
- package/dist/server/rpc/delegate-transport.js +65 -44
- package/dist/server/rpc/delegate-utils.d.ts +2 -0
- package/dist/server/rpc/delegate-utils.js +5 -0
- package/dist/server/rpc/handler-registry.js +26 -3
- package/dist/server/rpc/handler-utils.js +43 -1
- package/dist/server/rpc/handlers/cancel-delegated.d.ts +4 -0
- package/dist/server/rpc/handlers/cancel-delegated.js +71 -0
- package/dist/server/rpc/handlers/completion-stream-delegated.js +2 -2
- package/dist/server/rpc/handlers/heartbeat-delegated.d.ts +4 -0
- package/dist/server/rpc/handlers/heartbeat-delegated.js +32 -0
- package/dist/server/rpc/handlers/heartbeat.d.ts +3 -0
- package/dist/server/rpc/handlers/heartbeat.js +3 -0
- package/dist/server/rpc/handlers/index.d.ts +2 -2
- package/dist/server/rpc/handlers/index.js +2 -2
- package/dist/server/rpc/handlers/load-model/registry.js +25 -41
- package/dist/server/rpc/handlers/load-model-delegated.js +6 -4
- package/dist/server/rpc/handlers/unload-model-delegated.js +3 -3
- package/package.json +10 -3
- package/dist/client/api/ping.d.ts +0 -11
- package/dist/client/api/ping.js +0 -19
- package/dist/examples/embed-hyperdrive.d.ts +0 -2
- package/dist/examples/llamacpp-hyperdrive.d.ts +0 -2
- package/dist/examples/seed-hyperdrive.d.ts +0 -2
- package/dist/schemas/ping.d.ts +0 -11
- package/dist/schemas/ping.js +0 -8
- package/dist/server/rpc/handlers/ping.d.ts +0 -3
- package/dist/server/rpc/handlers/ping.js +0 -3
- /package/dist/examples/{embed-hyperdrive.js → embed-p2p.js} +0 -0
- /package/dist/examples/{llamacpp-hyperdrive.js → llamacpp-p2p.js} +0 -0
- /package/dist/examples/{seed-hyperdrive.js → seed-p2p.js} +0 -0
package/README.md
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
[](https://qvac.tether.dev)
|
|
2
|
-
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
**QVAC** is an open-source, cross-platform **ecosystem** for local-first, peer-to-peer **AI**. QVAC runs on [**Bare**](https://bare.pears.com) by [Holepunch](https://holepunch.to), a lightweight, cross-platform JavaScript runtime.
|
|
6
|
-
|
|
7
1
|
# QVAC SDK
|
|
8
2
|
|
|
9
3
|
**QVAC SDK** is the canonical entry point to develop AI applications with QVAC.
|
|
@@ -11,140 +5,73 @@
|
|
|
11
5
|
> _Part of **QVAC** ecosystem_
|
|
12
6
|
> <br>
|
|
13
7
|
> <sup>
|
|
14
|
-
> <a href="https://qvac.tether.
|
|
15
|
-
> <a href="https://qvac.tether.
|
|
16
|
-
> <a href="https://
|
|
8
|
+
> <a href="https://qvac.tether.io/" >Home</a> •
|
|
9
|
+
> <a href="https://docs.qvac.tether.io/" >Docs</a> •
|
|
10
|
+
> <a href="https://discord.com/channels/1425125849346216029/1445400675189264516" >Support</a> •
|
|
17
11
|
> <a href="https://discord.com/invite/tetherdev" >Discord</a>
|
|
18
|
-
> </sup>
|
|
19
|
-
|
|
20
|
-
Written in TypeScript, it provides all QVAC capabilities through a unified interface while also abstracting away the complexity of running your application in a JS environment other than Bare.
|
|
21
12
|
|
|
22
|
-
|
|
13
|
+
**QVAC SDK** is the main entry point for developing applications with QVAC. It is type-safe and exposes all QVAC capabilities through a unified interface. It runs on Node.js, [Bare runtime](https://bare.pears.com), and [Expo](https://expo.dev).
|
|
23
14
|
|
|
24
|
-
|
|
15
|
+
See [https://docs.qvac.tether.io/sdk/getting-started](https://docs.qvac.tether.io/sdk/getting-started) for the comprehensive QVAC documentation.
|
|
25
16
|
|
|
26
|
-
Supported
|
|
17
|
+
## Supported environments and installation
|
|
27
18
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
npm install @qvac/sdk
|
|
32
|
-
```
|
|
19
|
+
See https://docs.qvac.tether.io/sdk/getting-started/installation
|
|
33
20
|
|
|
34
|
-
|
|
21
|
+
## Quickstart
|
|
35
22
|
|
|
36
|
-
|
|
23
|
+
1. Create the examples workspace:
|
|
37
24
|
|
|
38
25
|
```bash
|
|
39
|
-
|
|
26
|
+
mkdir qvac-examples
|
|
27
|
+
cd qvac-examples
|
|
28
|
+
npm init -y && npm pkg set type=module
|
|
40
29
|
```
|
|
41
30
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
1. Peer dependencies:
|
|
31
|
+
2. Install the SDK:
|
|
45
32
|
|
|
46
33
|
```bash
|
|
47
|
-
npm
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
2. On Android, bump `minSdkVersion` to 29, by adding `ext { minSdkVersion=29 }` to `android/build.gradle` or using `expo-build-properties`.
|
|
51
|
-
|
|
52
|
-
3. Add the QVAC Expo plugin to `app.json`:
|
|
53
|
-
|
|
54
|
-
```js
|
|
55
|
-
export default {
|
|
56
|
-
expo: {
|
|
57
|
-
plugins: ["@qvac/sdk/expo-plugin"],
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
4. Prebuild your project to generate the native files:
|
|
63
|
-
|
|
64
|
-
```bash
|
|
65
|
-
npx expo prebuild
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
5. Build and run it on a **physical device**:
|
|
69
|
-
|
|
70
|
-
```bash
|
|
71
|
-
npx expo run:ios --device
|
|
72
|
-
# or
|
|
73
|
-
npx expo run:android --device
|
|
34
|
+
npm install @qvac/sdk
|
|
74
35
|
```
|
|
75
36
|
|
|
76
|
-
|
|
77
|
-
> Due to limitations with `llamacpp`, QVAC currently does not run on emulators. You **must** use a physical device.
|
|
78
|
-
|
|
79
|
-
## Usage
|
|
37
|
+
3. Create the quickstart script:
|
|
80
38
|
|
|
81
39
|
```js
|
|
82
|
-
import {
|
|
83
|
-
completion,
|
|
84
|
-
LLAMA_3_2_1B_INST_Q4_0,
|
|
85
|
-
loadModel,
|
|
86
|
-
downloadAsset,
|
|
87
|
-
unloadModel,
|
|
88
|
-
VERBOSITY,
|
|
89
|
-
} from "@qvac/sdk";
|
|
40
|
+
import { loadModel, LLAMA_3_2_1B_INST_Q4_0, completion, unloadModel, } from "@qvac/sdk";
|
|
90
41
|
try {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
process.stdout.write(token);
|
|
117
|
-
}
|
|
118
|
-
const stats = await result.stats;
|
|
119
|
-
console.log("\n📊 Performance Stats:", stats);
|
|
120
|
-
// Change `clearStorage: true` to delete cached model files
|
|
121
|
-
await unloadModel({ modelId, clearStorage: false });
|
|
122
|
-
} catch (error) {
|
|
123
|
-
console.error("❌ Error:", error);
|
|
124
|
-
process.exit(1);
|
|
42
|
+
// Load a model into memory
|
|
43
|
+
const modelId = await loadModel({
|
|
44
|
+
modelSrc: LLAMA_3_2_1B_INST_Q4_0,
|
|
45
|
+
modelType: "llm",
|
|
46
|
+
onProgress: (progress) => {
|
|
47
|
+
console.log(progress);
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
// You can use the loaded model multiple times
|
|
51
|
+
const history = [
|
|
52
|
+
{
|
|
53
|
+
role: "user",
|
|
54
|
+
content: "Explain quantum computing in one sentence",
|
|
55
|
+
},
|
|
56
|
+
];
|
|
57
|
+
const result = completion({ modelId, history, stream: true });
|
|
58
|
+
for await (const token of result.tokenStream) {
|
|
59
|
+
process.stdout.write(token);
|
|
60
|
+
}
|
|
61
|
+
// Unload model to free up system resources
|
|
62
|
+
await unloadModel({ modelId });
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
console.error("❌ Error:", error);
|
|
66
|
+
process.exit(1);
|
|
125
67
|
}
|
|
126
68
|
```
|
|
127
69
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
### AI tasks
|
|
70
|
+
4. Run the quickstart script:
|
|
131
71
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
- Translation: between different languages.
|
|
136
|
-
- Text-to-Speech: TTS via ONNX.
|
|
137
|
-
- Multimodal: via [`llama.cpp`] — i.e., process and understand multiple types of media within the same conversation context.
|
|
138
|
-
- RAG: retrieval-augmented generation with progress streaming, cancellation, and workspace management.
|
|
139
|
-
- Delegated inference: perform peer-to-peer edge inference via Holepunch stack.
|
|
140
|
-
|
|
141
|
-
### Utilities
|
|
142
|
-
|
|
143
|
-
- Configuration: customize SDK behavior via config files (`qvac.config.json`, `.js`, or `.ts`).
|
|
144
|
-
- Logging: visibility into what's happening inside your models during loading, inference, and other operations.
|
|
145
|
-
- Download Lifecycle: pause and resume model downloads.
|
|
146
|
-
- Blind Relays: establish peer connections through NAT/firewalls by routing traffic through relay nodes.
|
|
147
|
-
- Sharded models: download a model that is sharded into multiple parts.
|
|
72
|
+
```bash
|
|
73
|
+
node quickstart.js
|
|
74
|
+
```
|
|
148
75
|
|
|
149
76
|
## Examples
|
|
150
77
|
|
|
@@ -164,161 +91,27 @@ node dist/examples/path/to/example.js
|
|
|
164
91
|
bun run examples/path/to/example.ts
|
|
165
92
|
```
|
|
166
93
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
- `llama.cpp` with local files: [`examples/llamacpp-filesystem.ts`](examples/llamacpp-filesystem.ts)
|
|
170
|
-
- `llama.cpp` with Hyperdrive: [`examples/llamacpp-hyperdrive.ts`](examples/llamacpp-hyperdrive.ts)
|
|
171
|
-
- `llama.cpp` with HTTP: [`examples/llamacpp-http.ts`](examples/llamacpp-http.ts)
|
|
172
|
-
- `llama.cpp` with tools/function calls: [`examples/llamacpp-native-tools.ts`](examples/llamacpp-native-tools.ts)
|
|
173
|
-
- `llama.cpp` with multimodal inference: [`examples/llamacpp-multimodal.ts`](examples/llamacpp-multimodal.ts)
|
|
174
|
-
- `llama.cpp` with KV cache: [`examples/kv-cache-example.ts`](examples/kv-cache-example.ts)
|
|
175
|
-
|
|
176
|
-
### Transcription
|
|
177
|
-
|
|
178
|
-
- `whisper.cpp` transcription: [`examples/whispercpp-filesystem.ts`](examples/whispercpp-filesystem.ts)
|
|
179
|
-
- Microphone recording: [`examples/whispercpp-microphone-record.ts`](examples/whispercpp-microphone-record.ts)
|
|
180
|
-
|
|
181
|
-
### Embeddings
|
|
182
|
-
|
|
183
|
-
- Single and batch embeddings: [`examples/embed-hyperdrive.ts`](examples/embed-hyperdrive.ts)
|
|
184
|
-
|
|
185
|
-
**RAG with HyperDB** (cross-platform):
|
|
186
|
-
|
|
187
|
-
- Ingest (full pipeline): [`examples/rag/rag-hyperdb/ingest.ts`](examples/rag/rag-hyperdb/ingest.ts)
|
|
188
|
-
- Segregated pipeline: [`examples/rag/rag-hyperdb/pipeline.ts`](examples/rag/rag-hyperdb/pipeline.ts) _(Segregated flow: chunk → embed → save)_
|
|
189
|
-
- Workspaces: [`examples/rag/rag-hyperdb/workspaces.ts`](examples/rag/rag-hyperdb/workspaces.ts) _(Workspace lifecycle: list, close, delete)_
|
|
190
|
-
- Cancellation: [`examples/rag/rag-hyperdb/cancellation.ts`](examples/rag/rag-hyperdb/cancellation.ts) _(progress + cancel)_
|
|
191
|
-
|
|
192
|
-
**RAG with other backends** (desktop only):
|
|
193
|
-
|
|
194
|
-
- LanceDB: [`examples/rag/rag-lancedb.ts`](examples/rag/rag-lancedb.ts)
|
|
195
|
-
- ChromaDB: [`examples/rag/rag-chromadb.ts`](examples/rag/rag-chromadb.ts) _(requires ChromaDB server)_
|
|
196
|
-
- SQLite-Vector: [`examples/rag/rag-sqlite.ts`](examples/rag/rag-sqlite.ts) _(SQLite-Vector WASM)_
|
|
197
|
-
|
|
198
|
-
### Translation
|
|
199
|
-
|
|
200
|
-
- Marian OPUS translation: [`examples/translation/translation-opus.ts`](examples/translation/translation-opus.ts)
|
|
201
|
-
- Indic language translation: [`examples/translation/translation-indic.ts`](examples/translation/translation-indic.ts)
|
|
202
|
-
- LLM-based translation: [`examples/translation/translation-llm.ts`](examples/translation/translation-llm.ts)
|
|
203
|
-
|
|
204
|
-
### Text-to-Speech
|
|
205
|
-
|
|
206
|
-
- TTS (Chatterbox): [`examples/tts/chatterbox.ts`](examples/tts/chatterbox.ts) _(voice cloning with reference audio)_
|
|
207
|
-
- TTS (Supertonic): [`examples/tts/supertonic.ts`](examples/tts/supertonic.ts) _(general-purpose, no voice cloning)_
|
|
208
|
-
|
|
209
|
-
### Multimodel
|
|
210
|
-
|
|
211
|
-
- Load multiple models simultaneously: [`examples/multi-model-demo.ts`](examples/multi-model-demo.ts)
|
|
212
|
-
|
|
213
|
-
### Delegated inference
|
|
214
|
-
|
|
215
|
-
- Provider: [`examples/delegated-inference/provider.ts`](examples/delegated-inference/provider.ts)
|
|
216
|
-
- Consumer: [`examples/delegated-inference/consumer.ts`](examples/delegated-inference/consumer.ts)
|
|
217
|
-
|
|
218
|
-
> [!TIP]
|
|
219
|
-
> Set `QVAC_HYPERSWARM_SEED` env var to ensure that the provider uses the same keypair (i.e., public key doesn't change on every run).
|
|
220
|
-
|
|
221
|
-
> [!NOTE]
|
|
222
|
-
> Consumer does not handle reconnection yet.
|
|
223
|
-
|
|
224
|
-
### Logging
|
|
225
|
-
|
|
226
|
-
Stream real-time logs from the SDK server and native addons:
|
|
227
|
-
|
|
228
|
-
```ts
|
|
229
|
-
import { loggingStream, SDK_LOG_ID } from "@qvac/sdk";
|
|
94
|
+
## Build
|
|
230
95
|
|
|
231
|
-
|
|
232
|
-
for await (const log of loggingStream({ id: SDK_LOG_ID })) {
|
|
233
|
-
console.log(`[${log.level}] ${log.namespace}: ${log.message}`);
|
|
234
|
-
}
|
|
96
|
+
Use the [Bun](https://bun.sh/) package manager:
|
|
235
97
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
console.log(`[${log.level}] ${log.namespace}: ${log.message}`);
|
|
239
|
-
}
|
|
98
|
+
```bash
|
|
99
|
+
bun i
|
|
240
100
|
```
|
|
241
101
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
### Configuration
|
|
246
|
-
|
|
247
|
-
Customize SDK behavior using a config file. The SDK auto-discovers `qvac.config.{json,js,ts}` in your project root, or you can specify a path via `QVAC_CONFIG_PATH` environment variable.
|
|
248
|
-
|
|
249
|
-
**Supported formats:**
|
|
250
|
-
|
|
251
|
-
- `qvac.config.json` - JSON format
|
|
252
|
-
- `qvac.config.js` - JavaScript with `export default`
|
|
253
|
-
- `qvac.config.ts` - TypeScript with `export default`
|
|
254
|
-
|
|
255
|
-
**Available options:**
|
|
256
|
-
|
|
257
|
-
| Option | Type | Default | Description |
|
|
258
|
-
| ------------------------- | ---------- | ---------------- | --------------------------------------------------- |
|
|
259
|
-
| `cacheDirectory` | `string` | `~/.qvac/models` | Where models and assets are stored |
|
|
260
|
-
| `swarmRelays` | `string[]` | `[]` | Hyperswarm relay public keys for P2P |
|
|
261
|
-
| `loggerLevel` | `string` | `"info"` | Log level: `"error"`, `"warn"`, `"info"`, `"debug"` |
|
|
262
|
-
| `loggerConsoleOutput` | `boolean` | `true` | Enable/disable console output |
|
|
263
|
-
| `httpDownloadConcurrency` | `number` | `3` | Max concurrent HTTP downloads for sharded models |
|
|
264
|
-
| `httpConnectionTimeoutMs` | `number` | `10000` | HTTP connection timeout in milliseconds |
|
|
265
|
-
|
|
266
|
-
- Config usage example: [`examples/default-config-usage.ts`](examples/default-config-usage.ts)
|
|
267
|
-
|
|
268
|
-
### Download Lifecycle
|
|
269
|
-
|
|
270
|
-
- Pause and resume download: [`examples/download-with-cancel.ts`](examples/download-with-cancel.ts)
|
|
271
|
-
|
|
272
|
-
### Blind Relays
|
|
273
|
-
|
|
274
|
-
Blind relays help establish peer connections through NAT/firewalls by routing traffic through relay nodes.
|
|
275
|
-
|
|
276
|
-
- Model downloads via Hyperdrive: [`examples/download-with-blind-relays.ts`](./examples/download-with-blind-relays.ts)
|
|
277
|
-
- Delegated inference: You can reuse the same pattern for delegated inference by adding `swarmRelays` to your config file before starting your provider/consumer.
|
|
278
|
-
|
|
279
|
-
> [!NOTE]
|
|
280
|
-
> The examples use mock relay keys. For real deployments, you **must** use your own relay servers or trusted public relays.
|
|
281
|
-
|
|
282
|
-
### Sharded Models
|
|
283
|
-
|
|
284
|
-
Sharded models are split into multiple files following the pattern: `<name>-00001-of-0000X.<ext>`. The SDK automatically downloads and loads all parts with detailed progress tracking.
|
|
285
|
-
|
|
286
|
-
**Supported formats:**
|
|
287
|
-
|
|
288
|
-
- Archives (`.tar`, `.tar.gz`, `.tgz`): HTTP or local with automatic extraction
|
|
289
|
-
- HTTP sharded URL: pass the download URL of any shard and the SDK will fetch the remaining shards
|
|
290
|
-
- Hyperdrive: use any sharded Hyperdrive model source
|
|
291
|
-
- Local shards: pass the path to any shard file. _(Note: All shards must be in the same directory)_
|
|
292
|
-
|
|
293
|
-
See: [`examples/llamacpp-sharded.ts`](examples/llamacpp-sharded.ts)
|
|
294
|
-
|
|
295
|
-
## Basic flow
|
|
296
|
-
|
|
297
|
-
```mermaid
|
|
298
|
-
sequenceDiagram
|
|
299
|
-
participant User as User
|
|
300
|
-
participant SDK as QVAC SDK
|
|
301
|
-
participant RPC as RPC Client (singleton)
|
|
302
|
-
participant Worker as Bare Worker (singleton)
|
|
303
|
-
|
|
304
|
-
User->>SDK: Call loadModel("llama-3", options)
|
|
305
|
-
SDK->>RPC: Create runtime-specific RPC client
|
|
306
|
-
RPC->>Worker: Spawn worker (if needed) and send loadModel request
|
|
307
|
-
Worker->>Worker: Download and load model into memory
|
|
308
|
-
Worker->>RPC: Return success response
|
|
309
|
-
RPC->>SDK: Model loaded successfully
|
|
310
|
-
SDK->>User: loadModel() resolves with modelId
|
|
102
|
+
```bash
|
|
103
|
+
bun run build # or `watch` for hotreload
|
|
311
104
|
```
|
|
312
105
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
Hot config reload allows you to update model configurations on-the-fly without unloading the model. Pass `modelId` (instead of `modelSrc`) to `loadModel` with the `modelType` and new `modelConfig` to apply changes instantly.
|
|
106
|
+
```bash
|
|
107
|
+
bun run build:pack
|
|
108
|
+
```
|
|
318
109
|
|
|
319
|
-
|
|
110
|
+
This outputs a tarball under `dist/sdk-{version}.tgz` that you can install in your project, e.g.:
|
|
320
111
|
|
|
321
|
-
|
|
112
|
+
```bash
|
|
113
|
+
npm i path/to/sdk-0.3.0.tgz
|
|
114
|
+
```
|
|
322
115
|
|
|
323
116
|
## Contributing
|
|
324
117
|
|
|
@@ -459,32 +252,3 @@ This will:
|
|
|
459
252
|
4. Generate `changelog/<version>/CHANGELOG.md`
|
|
460
253
|
5. Generate `changelog/<version>/breaking.md` for BC changes (with code examples)
|
|
461
254
|
6. Generate `changelog/<version>/api.md` for API changes (with code examples)
|
|
462
|
-
|
|
463
|
-
**Note:** Requires a GitHub token (`GITHUB_TOKEN` or `GH_TOKEN` environment variable) to fetch PR metadata.
|
|
464
|
-
|
|
465
|
-
## Build
|
|
466
|
-
|
|
467
|
-
Use the [Bun](https://bun.sh/) package manager:
|
|
468
|
-
|
|
469
|
-
```bash
|
|
470
|
-
bun i
|
|
471
|
-
```
|
|
472
|
-
|
|
473
|
-
```bash
|
|
474
|
-
bun run build # or `watch` for hotreload
|
|
475
|
-
```
|
|
476
|
-
|
|
477
|
-
```bash
|
|
478
|
-
bun run build:pack
|
|
479
|
-
```
|
|
480
|
-
|
|
481
|
-
This outputs a tarball under `dist/sdk-{version}.tgz` that you can install in your project, e.g.:
|
|
482
|
-
|
|
483
|
-
```bash
|
|
484
|
-
npm i path/to/sdk-0.3.0.tgz
|
|
485
|
-
```
|
|
486
|
-
|
|
487
|
-
## More Resources
|
|
488
|
-
|
|
489
|
-
- [Comprehensive documentation of this SDK](https://qvac.tether.dev/docs/sdk)
|
|
490
|
-
- [Package at NPM](https://www.npmjs.com/package/@qvac/sdk)
|
|
@@ -7,6 +7,7 @@ import { type CancelParams } from "../../schemas/index";
|
|
|
7
7
|
* @param params.modelId - The model ID (required for inference cancellation)
|
|
8
8
|
* @param params.downloadKey - The download key (required for download cancellation)
|
|
9
9
|
* @param params.clearCache - If true, deletes the partial download file (default: false)
|
|
10
|
+
* @param params.delegate - Delegation target for remote download cancellation (optional)
|
|
10
11
|
* @param params.workspace - The RAG workspace to cancel (optional, defaults to "default")
|
|
11
12
|
* @throws {QvacErrorBase} When the response type is invalid or when the cancellation fails
|
|
12
13
|
*
|
|
@@ -23,6 +24,14 @@ import { type CancelParams } from "../../schemas/index";
|
|
|
23
24
|
* await cancel({ operation: "downloadAsset", downloadKey: "download-key", clearCache: true });
|
|
24
25
|
*
|
|
25
26
|
* @example
|
|
27
|
+
* // Cancel delegated remote download
|
|
28
|
+
* await cancel({
|
|
29
|
+
* operation: "downloadAsset",
|
|
30
|
+
* downloadKey: "download-key",
|
|
31
|
+
* delegate: { topic: "topicHex", providerPublicKey: "peerHex" },
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
26
35
|
* // Cancel RAG operation on default workspace
|
|
27
36
|
* await cancel({ operation: "rag" });
|
|
28
37
|
*
|
|
@@ -9,6 +9,7 @@ import { InvalidResponseError, CancelFailedError } from "../../utils/errors-clie
|
|
|
9
9
|
* @param params.modelId - The model ID (required for inference cancellation)
|
|
10
10
|
* @param params.downloadKey - The download key (required for download cancellation)
|
|
11
11
|
* @param params.clearCache - If true, deletes the partial download file (default: false)
|
|
12
|
+
* @param params.delegate - Delegation target for remote download cancellation (optional)
|
|
12
13
|
* @param params.workspace - The RAG workspace to cancel (optional, defaults to "default")
|
|
13
14
|
* @throws {QvacErrorBase} When the response type is invalid or when the cancellation fails
|
|
14
15
|
*
|
|
@@ -25,6 +26,14 @@ import { InvalidResponseError, CancelFailedError } from "../../utils/errors-clie
|
|
|
25
26
|
* await cancel({ operation: "downloadAsset", downloadKey: "download-key", clearCache: true });
|
|
26
27
|
*
|
|
27
28
|
* @example
|
|
29
|
+
* // Cancel delegated remote download
|
|
30
|
+
* await cancel({
|
|
31
|
+
* operation: "downloadAsset",
|
|
32
|
+
* downloadKey: "download-key",
|
|
33
|
+
* delegate: { topic: "topicHex", providerPublicKey: "peerHex" },
|
|
34
|
+
* });
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
28
37
|
* // Cancel RAG operation on default workspace
|
|
29
38
|
* await cancel({ operation: "rag" });
|
|
30
39
|
*
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type HeartbeatResponse } from "../../schemas/index";
|
|
2
|
+
import type { DelegateBase } from "../../schemas/delegate";
|
|
3
|
+
/**
|
|
4
|
+
* Checks if a delegated provider is online by sending a heartbeat round-trip.
|
|
5
|
+
* Can also be used to check if the local SDK worker is responsive.
|
|
6
|
+
*
|
|
7
|
+
* @param params - Delegation target to check
|
|
8
|
+
* @param params.delegate - The provider to check (topic + publicKey + optional timeout)
|
|
9
|
+
* @returns A promise that resolves to a heartbeat response if the provider is reachable.
|
|
10
|
+
* @throws {QvacErrorBase} When the provider is unreachable or the response is invalid.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* // Check if a delegated provider is online
|
|
14
|
+
* try {
|
|
15
|
+
* await heartbeat({
|
|
16
|
+
* delegate: { topic: "topicHex", providerPublicKey: "peerHex", timeout: 3000 },
|
|
17
|
+
* });
|
|
18
|
+
* console.log("Provider is online");
|
|
19
|
+
* } catch {
|
|
20
|
+
* console.log("Provider is offline");
|
|
21
|
+
* }
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* // Check if the local SDK worker is responsive
|
|
25
|
+
* await heartbeat();
|
|
26
|
+
*/
|
|
27
|
+
export declare function heartbeat(params?: {
|
|
28
|
+
delegate?: DelegateBase;
|
|
29
|
+
}): Promise<HeartbeatResponse>;
|
|
30
|
+
//# sourceMappingURL=heartbeat.d.ts.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {} from "../../schemas/index.js";
|
|
2
|
+
import { send } from "../rpc/rpc-client.js";
|
|
3
|
+
import { InvalidResponseError } from "../../utils/errors-client.js";
|
|
4
|
+
/**
|
|
5
|
+
* Checks if a delegated provider is online by sending a heartbeat round-trip.
|
|
6
|
+
* Can also be used to check if the local SDK worker is responsive.
|
|
7
|
+
*
|
|
8
|
+
* @param params - Delegation target to check
|
|
9
|
+
* @param params.delegate - The provider to check (topic + publicKey + optional timeout)
|
|
10
|
+
* @returns A promise that resolves to a heartbeat response if the provider is reachable.
|
|
11
|
+
* @throws {QvacErrorBase} When the provider is unreachable or the response is invalid.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* // Check if a delegated provider is online
|
|
15
|
+
* try {
|
|
16
|
+
* await heartbeat({
|
|
17
|
+
* delegate: { topic: "topicHex", providerPublicKey: "peerHex", timeout: 3000 },
|
|
18
|
+
* });
|
|
19
|
+
* console.log("Provider is online");
|
|
20
|
+
* } catch {
|
|
21
|
+
* console.log("Provider is offline");
|
|
22
|
+
* }
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* // Check if the local SDK worker is responsive
|
|
26
|
+
* await heartbeat();
|
|
27
|
+
*/
|
|
28
|
+
export async function heartbeat(params) {
|
|
29
|
+
const request = {
|
|
30
|
+
type: "heartbeat",
|
|
31
|
+
...(params?.delegate && { delegate: params.delegate }),
|
|
32
|
+
};
|
|
33
|
+
const response = await send(request);
|
|
34
|
+
if (response.type !== "heartbeat") {
|
|
35
|
+
throw new InvalidResponseError("heartbeat");
|
|
36
|
+
}
|
|
37
|
+
return response;
|
|
38
|
+
}
|
|
@@ -4,7 +4,7 @@ export { completion } from "./completion-stream";
|
|
|
4
4
|
export { deleteCache } from "./delete-cache";
|
|
5
5
|
export { unloadModel } from "./unload-model";
|
|
6
6
|
export { loggingStream } from "./logging-stream";
|
|
7
|
-
export {
|
|
7
|
+
export { heartbeat } from "./heartbeat";
|
|
8
8
|
export { transcribe, transcribeStream } from "./transcribe";
|
|
9
9
|
export { embed } from "./embed";
|
|
10
10
|
export { translate } from "./translate";
|
package/dist/client/api/index.js
CHANGED
|
@@ -4,7 +4,7 @@ export { completion } from "./completion-stream.js";
|
|
|
4
4
|
export { deleteCache } from "./delete-cache.js";
|
|
5
5
|
export { unloadModel } from "./unload-model.js";
|
|
6
6
|
export { loggingStream } from "./logging-stream.js";
|
|
7
|
-
export {
|
|
7
|
+
export { heartbeat } from "./heartbeat.js";
|
|
8
8
|
export { transcribe, transcribeStream } from "./transcribe.js";
|
|
9
9
|
export { embed } from "./embed.js";
|
|
10
10
|
export { translate } from "./translate.js";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { completion, deleteCache, loadModel, downloadAsset,
|
|
1
|
+
export { completion, deleteCache, loadModel, downloadAsset, heartbeat, startQVACProvider, stopQVACProvider, unloadModel, transcribe, transcribeStream, embed, translate, cancel, ragChunk, ragIngest, ragSaveEmbeddings, ragSearch, ragDeleteEmbeddings, ragReindex, ragListWorkspaces, ragCloseWorkspace, ragDeleteWorkspace, textToSpeech, getModelInfo, loggingStream, ocr, invokePlugin, invokePluginStream, modelRegistryList, modelRegistrySearch, modelRegistryGetModel, type ModelRegistrySearchParams, } from "./client/api/index";
|
|
2
2
|
export { close } from "./client/index";
|
|
3
3
|
export { type ModelProgressUpdate, type LoadModelOptions, type DownloadAssetOptions, type Tool, type ToolCall, type ToolCallWithCall, type ToolCallError, type ToolCallEvent, type CompletionStats, VERBOSITY, type Attachment, type CompletionParams, type RagSearchResult, type RagSaveEmbeddingsResult, type RagReindexResult, type RagEmbeddedDoc, type RagDoc, type RagWorkspaceInfo, type RagCloseWorkspaceParams, type RagDeleteWorkspaceParams, type RagIngestStage, type RagReindexStage, type RagSaveStage, SDK_CLIENT_ERROR_CODES, SDK_SERVER_ERROR_CODES, type QvacConfig, type ModelInfo, type GetModelInfoParams, type LoadedInstance, type CacheFileInfo, toolSchema, type McpClient, type McpClientInput, type OCRClientParams, type OCRTextBlock, type OCROptions, definePlugin, defineHandler, type QvacPlugin, type CreateModelParams, type PluginModelResult, type ModelRegistryEntry, type ModelRegistryEntryAddon, PLUGIN_LLM, PLUGIN_EMBEDDING, PLUGIN_WHISPER, PLUGIN_NMT, PLUGIN_TTS, PLUGIN_OCR, SDK_DEFAULT_PLUGINS, type BuiltinPlugin, type ProfilerMode, } from "./schemas/index";
|
|
4
4
|
export { type ToolInput, type ToolHandler } from "./utils/tool-helpers";
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Public API exports only
|
|
2
|
-
export { completion, deleteCache, loadModel, downloadAsset,
|
|
2
|
+
export { completion, deleteCache, loadModel, downloadAsset, heartbeat, startQVACProvider, stopQVACProvider, unloadModel, transcribe, transcribeStream, embed, translate, cancel, ragChunk, ragIngest, ragSaveEmbeddings, ragSearch, ragDeleteEmbeddings, ragReindex, ragListWorkspaces, ragCloseWorkspace, ragDeleteWorkspace, textToSpeech, getModelInfo, loggingStream, ocr, invokePlugin, invokePluginStream, modelRegistryList, modelRegistrySearch, modelRegistryGetModel, } from "./client/api/index.js";
|
|
3
3
|
export { close } from "./client/index.js";
|
|
4
4
|
export { VERBOSITY, SDK_CLIENT_ERROR_CODES, SDK_SERVER_ERROR_CODES, toolSchema, definePlugin, defineHandler, PLUGIN_LLM, PLUGIN_EMBEDDING, PLUGIN_WHISPER, PLUGIN_NMT, PLUGIN_TTS, PLUGIN_OCR, SDK_DEFAULT_PLUGINS, } from "./schemas/index.js";
|
|
5
5
|
export {} from "./utils/tool-helpers.js";
|