@ariacompute/engine-ts 1.6.0 → 1.6.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/README.md CHANGED
@@ -22,5 +22,5 @@ into `~/.ariacompute/models/{model}` and then loads it. A valid cached bundle is
22
22
  reused without re-downloading.
23
23
 
24
24
  ```ts
25
- const eng = await Engine.open("gemma-4-e2b-it_q4", { token: "DASHBOARD_TOKEN" });
25
+ const eng = await Engine.open("gemma-4-e2b-it_q4", { token: "API_TOKEN" });
26
26
  ```
package/dist/index.d.ts CHANGED
@@ -47,6 +47,12 @@ export declare function isLocalRef(modelRef: string): boolean;
47
47
  export declare class Engine {
48
48
  private lib;
49
49
  private handle;
50
+ private fnInit;
51
+ private fnDestroy;
52
+ private fnComplete;
53
+ private fnEmbed;
54
+ private fnTranscribe;
55
+ private fnLastError;
50
56
  /** Construct from a local bundle directory. */
51
57
  constructor(bundle: string, opts?: OpenOptions);
52
58
  /** Auto-detect: a value containing a separator or already on disk is a local
package/dist/index.js CHANGED
@@ -130,7 +130,7 @@ const encoder = new TextEncoder();
130
130
  * Skips the download when a valid bundle is already cached. */
131
131
  async function downloadModel(model, token, site = DEFAULT_SITE) {
132
132
  if (!token)
133
- throw new Error("dashboard token is required to download a model");
133
+ throw new Error("api token is required to download a model");
134
134
  const { slug, quant } = parseBundleName(model);
135
135
  const cache = cacheDir(model);
136
136
  if (fs.existsSync(cache) && isValidBundle(cache))
@@ -173,15 +173,15 @@ class Engine {
173
173
  /** Construct from a local bundle directory. */
174
174
  constructor(bundle, opts = {}) {
175
175
  this.lib = loadLib(opts.ffiLib);
176
- this.lib.func("aria_model_init", "void*", ["str"]);
177
- this.lib.func("aria_model_destroy", "void", ["void*"]);
178
- this.lib.func("aria_complete", "int", ["void*", "str", "str", "str", "str", "size_t"]);
179
- this.lib.func("aria_embed", "int", ["void*", "str", "str", "size_t"]);
180
- this.lib.func("aria_transcribe", "int", ["void*", "void*", "size_t", "str", "str", "size_t"]);
181
- this.lib.func("aria_last_error", "str", []);
182
- this.handle = this.lib.aria_model_init(bundle);
176
+ this.fnInit = this.lib.func("aria_model_init", "void*", ["str"]);
177
+ this.fnDestroy = this.lib.func("aria_model_destroy", "void", ["void*"]);
178
+ this.fnComplete = this.lib.func("aria_complete", "int", ["void*", "str", "str", "str", "str", "size_t"]);
179
+ this.fnEmbed = this.lib.func("aria_embed", "int", ["void*", "str", "str", "size_t"]);
180
+ this.fnTranscribe = this.lib.func("aria_transcribe", "int", ["void*", "void*", "size_t", "str", "str", "size_t"]);
181
+ this.fnLastError = this.lib.func("aria_last_error", "str", []);
182
+ this.handle = this.fnInit(bundle);
183
183
  if (!this.handle) {
184
- const err = this.lib.aria_last_error();
184
+ const err = this.fnLastError();
185
185
  throw new Error(err || "init failed");
186
186
  }
187
187
  }
@@ -192,7 +192,7 @@ class Engine {
192
192
  if (isLocalRef(modelRef))
193
193
  return new Engine(modelRef, opts);
194
194
  if (!opts.token) {
195
- throw new Error(`model name '${modelRef}' requires a dashboard token to download`);
195
+ throw new Error(`model name '${modelRef}' requires an api token to download`);
196
196
  }
197
197
  const bundle = await downloadModel(modelRef, opts.token, opts.site ?? DEFAULT_SITE);
198
198
  return new Engine(bundle, opts);
@@ -200,9 +200,9 @@ class Engine {
200
200
  complete(messages, opts = {}) {
201
201
  const payload = JSON.stringify({ messages, opts });
202
202
  const buf = Buffer.alloc(1 << 16);
203
- const rc = this.lib.aria_complete(this.handle, payload, "", "", buf, buf.length);
203
+ const rc = this.fnComplete(this.handle, payload, "", "", buf, buf.length);
204
204
  if (rc !== 0) {
205
- const err = this.lib.aria_last_error();
205
+ const err = this.fnLastError();
206
206
  return { success: false, response: "", error: err || "complete failed" };
207
207
  }
208
208
  try {
@@ -215,25 +215,25 @@ class Engine {
215
215
  }
216
216
  embed(text) {
217
217
  const buf = Buffer.alloc(1 << 20);
218
- const rc = this.lib.aria_embed(this.handle, text, buf, buf.length);
218
+ const rc = this.fnEmbed(this.handle, text, buf, buf.length);
219
219
  if (rc !== 0) {
220
- const err = this.lib.aria_last_error();
220
+ const err = this.fnLastError();
221
221
  throw new Error(err || "embed failed");
222
222
  }
223
223
  return JSON.parse(buf.toString("utf8").replace(/\0+$/, ""));
224
224
  }
225
225
  transcribe(pcm) {
226
226
  const buf = Buffer.alloc(1 << 16);
227
- const rc = this.lib.aria_transcribe(this.handle, pcm, pcm.length, "", buf, buf.length);
227
+ const rc = this.fnTranscribe(this.handle, pcm, pcm.length, "", buf, buf.length);
228
228
  if (rc !== 0) {
229
- const err = this.lib.aria_last_error();
229
+ const err = this.fnLastError();
230
230
  throw new Error(err || "transcribe failed");
231
231
  }
232
232
  return buf.toString("utf8").replace(/\0+$/, "");
233
233
  }
234
234
  close() {
235
235
  if (this.handle)
236
- this.lib.aria_model_destroy(this.handle);
236
+ this.fnDestroy(this.handle);
237
237
  this.handle = null;
238
238
  }
239
239
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ariacompute/engine-ts",
3
- "version": "1.6.0",
3
+ "version": "1.6.2",
4
4
  "description": "TypeScript/Node SDK for Aria Engine",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",