@moss-dev/moss-web 1.10.0 → 1.11.0

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
@@ -18,7 +18,7 @@ Built on WebAssembly for near-native performance in any modern browser.
18
18
  npm install @moss-dev/moss-web
19
19
  ```
20
20
 
21
- Version 1.10.0 resolves `@moss-dev/moss-wasm@0.18.2`. Text `query()` loads its
21
+ Version 1.11.0 resolves `@moss-dev/moss-wasm@0.19.0`. Text `query()` loads its
22
22
  model through the Moss service using the client's credentials, so the service
23
23
  must be reachable the first time a model is loaded; there is no offline
24
24
  fallback. Before 1.2.0 the only published npm versions were 1.0.0 and 1.0.1,
@@ -329,8 +329,9 @@ Each call takes `apiKey`, `signal`, `timeout`, `idleTimeout`, `maxRetries` and
329
329
  `maxRetries` (2 by default, `0` for none) sends a call again when the connection
330
330
  fails, or when the gateway answers 408, 409, 429 or 5xx before the stream
331
331
  starts, after a `Retry-After` of up to 60 s, else a backoff of 0.5 s doubling
332
- up to 8 s, within `timeout`. `retrieve: false` or `indexes: []` skips the
333
- search, and leaving `indexes` out searches every index. Moss can answer an
332
+ up to 8 s, within `timeout`. Moss searches the indexes a call names in
333
+ `indexes`, else those in an `X-Moss-Indexes` header, else none, and
334
+ `indexes: []` or `retrieve: false` skips the search. Moss can answer an
334
335
  identical request from its reply cache; `cache: false` always asks the model.
335
336
  `stream.requestId` and a response's `requestId`, which `JSON.stringify` leaves
336
337
  out, hold the response's `X-Moss-Request-Id`.
@@ -601,10 +602,11 @@ The page's headers reach the gateway only when the route forwards them by name,
601
602
  since every visitor can set them. Back to the page it passes `Content-Type`,
602
603
  `Retry-After` and `X-Moss-Request-Id`, so an `InferenceError` there carries
603
604
  `retryAfter` and `requestId`. The route refuses an index that is not in its
604
- list, and always sends `X-Moss-Indexes`, because a call without it searches
605
- every index in the project. So `retrieve`, `indexes: []`, `cache` and `apiKey`
606
- in page code do not reach the gateway, and a route that wants them sets those
607
- headers itself, such as `X-Moss-Provider-Key` for your own provider key. The
605
+ list, and always sends `X-Moss-Indexes`, its whole list when the page names
606
+ none, because a call without it searches no index. So `retrieve`,
607
+ `indexes: []`, `cache` and `apiKey` in page code do not reach the gateway, and
608
+ a route that wants them sets those headers itself, such as
609
+ `X-Moss-Provider-Key` for your own provider key. The
608
610
  route also drops any MCP entry the page sends and adds its own server, so the
609
611
  page never holds MCP credentials.
610
612
 
package/dist/client.js CHANGED
@@ -33,6 +33,23 @@ function sameModelArtifactIdentity(left, right) {
33
33
  && left.version === right.version
34
34
  && left.manifestSha256 === right.manifestSha256;
35
35
  }
36
+ /** An `Error` with the `INVALID_ARGUMENT` code, the shape core failures reach the browser in. */
37
+ function invalidArgument(message) {
38
+ return Object.assign(new Error(message), { code: "INVALID_ARGUMENT" });
39
+ }
40
+ /** Throws INVALID_ARGUMENT unless `projectId` and `auth` can authenticate a client. */
41
+ function assertCredentials(projectId, auth) {
42
+ if (typeof projectId !== "string" || projectId === "") {
43
+ throw invalidArgument("projectId must be a non-empty string.");
44
+ }
45
+ const key = typeof auth === "string" && auth !== "";
46
+ const authenticator = typeof auth === "object" &&
47
+ auth !== null &&
48
+ typeof auth.getAuthToken === "function";
49
+ if (!key && !authenticator) {
50
+ throw invalidArgument("projectKey must be a non-empty string, or an authenticator with a getAuthToken function.");
51
+ }
52
+ }
36
53
  /** True for a query with no text to match: empty or only whitespace. */
37
54
  function isBlankQuery(query) {
38
55
  return query.trim().length === 0;
@@ -50,6 +67,7 @@ export class MossClient {
50
67
  });
51
68
  this.autoRefreshLoops = new Map();
52
69
  this.autoRefreshUnsupportedWarned = false;
70
+ assertCredentials(projectId, auth);
53
71
  this.projectId = projectId;
54
72
  if (typeof auth === "string") {
55
73
  this.projectKey = auth;
@@ -66,7 +66,8 @@ export interface ResponseCreateParamsBase {
66
66
  instructions?: string | null;
67
67
  stream?: boolean | null;
68
68
  /**
69
- * Moss indexes to search, every index when left out and none when empty.
69
+ * Moss indexes to search, none when empty. Left out, Moss
70
+ * searches the indexes in an `X-Moss-Indexes` header, else none.
70
71
  * Names travel in a single header, so each must be Latin-1 text with no comma.
71
72
  */
72
73
  indexes?: string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moss-dev/moss-web",
3
- "version": "1.10.0",
3
+ "version": "1.11.0",
4
4
  "type": "module",
5
5
  "description": "Moss browser SDK — in-browser semantic search powered by WASM",
6
6
  "main": "dist/index.js",
@@ -32,7 +32,7 @@
32
32
  "test": "npm run build && node --test"
33
33
  },
34
34
  "dependencies": {
35
- "@moss-dev/moss-wasm": "0.18.2",
35
+ "@moss-dev/moss-wasm": "0.19.0",
36
36
  "onnxruntime-web": "1.30.0"
37
37
  },
38
38
  "devDependencies": {