@moss-js/moss 1.14.0 → 1.15.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 +81 -0
- package/dist/index.esm.js +1 -1
- package/dist/moss.d.ts +26 -11
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -98,6 +98,70 @@ const mossClient = new MossClient("project", "key", {
|
|
|
98
98
|
includes Moss's file-backed UUID as `mossDeviceId`; without a host id, both
|
|
99
99
|
device fields contain that Moss UUID.
|
|
100
100
|
|
|
101
|
+
## Telemetry
|
|
102
|
+
|
|
103
|
+
The SDK reports usage to the Moss cloud at `$MOSS_INDEX_URL/telemetry`
|
|
104
|
+
(`https://service.usemoss.dev/index/telemetry` by default). Telemetry is always
|
|
105
|
+
on, because the device id and the query count drive usage billing. Requests are
|
|
106
|
+
sent in the background. A failed send is dropped and never fails the call that
|
|
107
|
+
caused it.
|
|
108
|
+
|
|
109
|
+
Queries do not send a request each. The SDK buffers their events, with the same
|
|
110
|
+
fields as below, and sends them every 3 seconds while queries run, plus once
|
|
111
|
+
more when the client or session is closed. A send puts up to 500 query events in
|
|
112
|
+
one JSON array per request. The buffer holds up to 10,000 events between sends,
|
|
113
|
+
and events past that are dropped. Other events are sent one per request, when
|
|
114
|
+
the operation happens.
|
|
115
|
+
|
|
116
|
+
`close()` on a client or session resolves after that last send finishes, so
|
|
117
|
+
await it before the process exits. A process that exits without closing can
|
|
118
|
+
lose up to 3 seconds of query events. Each flush waits at most 5 seconds for
|
|
119
|
+
authentication and 3 seconds per request, and drops its events when either fails.
|
|
120
|
+
|
|
121
|
+
### Fields on every event
|
|
122
|
+
|
|
123
|
+
| Field | Value |
|
|
124
|
+
|---|---|
|
|
125
|
+
| `action` | Always `"telemetry"`. |
|
|
126
|
+
| `eventType` | The event type, from the table below. |
|
|
127
|
+
| `projectId` | Your project id. |
|
|
128
|
+
| `clientId`, `sessionId` | The same random id, one per client or session object. |
|
|
129
|
+
| `sdkVersion`, `sdkPackageVersion` | Version of the native binding package. |
|
|
130
|
+
| `nativeCoreVersion` | Version of the Rust core. |
|
|
131
|
+
| `modelCacheSchemaVersion` | Layout version of the on-disk model cache. |
|
|
132
|
+
| `deviceId` | Billable device id: your `identity.deviceId`, or else the Moss device UUID. |
|
|
133
|
+
| `mossDeviceId` | The Moss device UUID stored in `.moss-device-id`. |
|
|
134
|
+
| `userId` | Only when you set one. Never billable. |
|
|
135
|
+
| `indexName` | The index, when the event concerns one index. |
|
|
136
|
+
| `modelId`, `modelArtifactVersion`, `modelManifestSha256` | The embedding model and its exact artifact, when known. |
|
|
137
|
+
|
|
138
|
+
### Event types and their extra fields
|
|
139
|
+
|
|
140
|
+
| Event | Sent when | Extra fields |
|
|
141
|
+
|---|---|---|
|
|
142
|
+
| `index.load` | An index loads | `docCount`, `autoRefresh`, `refreshIntervalSecs` (with auto refresh), `cached` (a cache path was given), `servedStale` (served from the cache while the cloud is unreachable), `modelCacheGeneration` |
|
|
143
|
+
| `index.auto_refresh` | An auto refresh poll finishes | `changed`, `modelCacheGeneration` |
|
|
144
|
+
| `index.unload` | An index unloads or the client closes | `modelCacheGeneration` |
|
|
145
|
+
| `index.query` | A single-index query runs, sent in a batch | `latencyMs`, `modelCacheGeneration` |
|
|
146
|
+
| `index.query_multi` | A multi-index query runs, sent in a batch | The `index.query` fields, plus `indexCount` and `indexNames`. `modelCacheGeneration` when every index shares one, else `modelCacheGenerationsByIndex`. |
|
|
147
|
+
| `index.usage.periodic_flush`, `index.usage.final_flush` | Every 3 seconds while there is usage, and at close | `queryCount`, `docsEmbedded`, `tokensEstimated` |
|
|
148
|
+
| `session.load` | A session loads an index from the cloud | `docCount` |
|
|
149
|
+
| `session.load_from_disk` | A session loads a local snapshot | `docCount`, plus `rebuilt` and `persisted` when a legacy snapshot is rebuilt |
|
|
150
|
+
| `session.add_docs`, `session.delete_docs` | Documents are added or deleted | `docCount` |
|
|
151
|
+
| `session.push_index` | A session pushes its index | `docCount` |
|
|
152
|
+
| `session.auto_refresh_staged` | A newer cloud version is downloaded | `updatedAt` |
|
|
153
|
+
| `session.auto_refresh` | A downloaded version is installed | `changed`, `docCount`, `updatedAt` |
|
|
154
|
+
| `session.unload` | A session is closed | None |
|
|
155
|
+
| `session.query` | A session query runs, sent in a batch | `latencyMs` |
|
|
156
|
+
| `session.usage.periodic_flush`, `session.usage.final_flush` | Every 3 seconds while there is usage, at close, and before a push | `queryCount`, `docsEmbedded`, `tokensEstimated` |
|
|
157
|
+
|
|
158
|
+
`latencyMs` on a query event is the time that query took, in milliseconds.
|
|
159
|
+
`index.query` and `index.query_multi` time the whole call, including the query
|
|
160
|
+
embedding. `session.query` times the search lookup only, without embedding, so
|
|
161
|
+
the two are not directly comparable.
|
|
162
|
+
|
|
163
|
+
No document text, query text, metadata or embedding is ever sent.
|
|
164
|
+
|
|
101
165
|
## Resource cleanup
|
|
102
166
|
|
|
103
167
|
`MossClient` and sessions returned by `client.session(...)` hold native resources that must be released explicitly. Call `close()` on each one when you are done with it, in a `finally` block or equivalent. `close()` is idempotent, so it is safe to call more than once.
|
|
@@ -193,6 +257,23 @@ If the vector is omitted, the query fails closed with an error stating that an
|
|
|
193
257
|
explicit query embedding is required. Moss does not silently fall back to an
|
|
194
258
|
unverified local model or send the query to the cloud.
|
|
195
259
|
|
|
260
|
+
## Offline-tolerant load
|
|
261
|
+
|
|
262
|
+
With a `cachePath` set and a snapshot already on disk, a `loadIndex` whose cloud
|
|
263
|
+
metadata check fails on a transport error (unreachable network, timeout) serves
|
|
264
|
+
the cached snapshot instead of failing, and starts a refresh poller so the index
|
|
265
|
+
catches up when the cloud returns. A real "index not found" (404) still fails,
|
|
266
|
+
so a deleted index does not come back from cache.
|
|
267
|
+
|
|
268
|
+
A load served this way opens the index, but a built-in embedding model cannot be
|
|
269
|
+
opened until the Moss cloud is reachable, so text queries with `alpha` above 0
|
|
270
|
+
fail until then. Keyword-only queries (`alpha: 0`) and queries that pass their
|
|
271
|
+
own embedding keep working.
|
|
272
|
+
|
|
273
|
+
```typescript
|
|
274
|
+
await mossClient.loadIndex("my-docs", { cachePath: "/var/cache/moss" });
|
|
275
|
+
```
|
|
276
|
+
|
|
196
277
|
## Multi-index search
|
|
197
278
|
|
|
198
279
|
Search several loaded indexes in one call and get the global top-k back, with
|
package/dist/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const _0xbe3c1b=_0xb5a9;(function(_0x19c388,_0x18797a){const _0x120fc9=_0xb5a9,_0x1f8870=_0x19c388();while(!![]){try{const _0x5a43c3=-parseInt(_0x120fc9(0x1d1))/0x1*(parseInt(_0x120fc9(0x23c))/0x2)+-parseInt(_0x120fc9(0x226))/0x3*(-parseInt(_0x120fc9(0x24e))/0x4)+-parseInt(_0x120fc9(0x1ca))/0x5*(-parseInt(_0x120fc9(0x1c6))/0x6)+-parseInt(_0x120fc9(0x1de))/0x7+-parseInt(_0x120fc9(0x21e))/0x8*(parseInt(_0x120fc9(0x216))/0x9)+parseInt(_0x120fc9(0x20d))/0xa*(parseInt(_0x120fc9(0x1e4))/0xb)+parseInt(_0x120fc9(0x21b))/0xc*(parseInt(_0x120fc9(0x1d7))/0xd);if(_0x5a43c3===_0x18797a)break;else _0x1f8870['push'](_0x1f8870['shift']());}catch(_0x5e496d){_0x1f8870['push'](_0x1f8870['shift']());}}}(_0x77d9,0x8f92a));import{JobStatus as _0x6363d6}from'@moss-js/moss-core';function _0xb5a9(_0x195c66,_0x313bc1){_0x195c66=_0x195c66-0x189;const _0x77d95a=_0x77d9();let _0xb5a9c0=_0x77d95a[_0x195c66];return _0xb5a9c0;}import*as _0x46fea7 from'@moss-js/moss-core';import*as _0x28db48 from'@moss-js/moss-core';var g=_0x28db48,oe=g[_0xbe3c1b(0x255)],ie=g[_0xbe3c1b(0x1e6)],ae=g[_0xbe3c1b(0x22c)],O=g[_0xbe3c1b(0x214)],ue=typeof process<'u'&&process[_0xbe3c1b(0x201)][_0xbe3c1b(0x224)]||g[_0xbe3c1b(0x1f4)],T=typeof process<'u'?process[_0xbe3c1b(0x201)]:{},f=class{constructor(_0x32895d,_0x4fe1c3){const _0x216f9a=_0xbe3c1b;this[_0x216f9a(0x21d)]=_0x32895d,this[_0x216f9a(0x209)]=_0x4fe1c3,this['authUrl']=T[_0x216f9a(0x199)]??O;}['projectId'];[_0xbe3c1b(0x209)];[_0xbe3c1b(0x243)];async['getAuthToken'](){const _0x403873=_0xbe3c1b;let _0x1c369f=await fetch(this[_0x403873(0x243)],{'method':'POST','headers':{'Content-Type':_0x403873(0x1b0)},'body':JSON[_0x403873(0x251)]({'projectId':this[_0x403873(0x21d)],'projectKey':this[_0x403873(0x209)]}),'signal':AbortSignal[_0x403873(0x25d)](0x7530)});if(_0x1c369f[_0x403873(0x1e8)]===0x191){let _0x3705d2=await _0x1c369f[_0x403873(0x1f2)]();throw new Error('Authentication\x20failed\x20(HTTP\x20401):\x20'+_0x3705d2);}if(!_0x1c369f['ok']){let _0x609c59=await _0x1c369f['text']();throw new Error('HTTP\x20'+_0x1c369f[_0x403873(0x1e8)]+':\x20'+_0x609c59);}let _0x328845=await _0x1c369f[_0x403873(0x1e0)]();return{'token':_0x328845['token'],'expiresIn':_0x328845[_0x403873(0x23d)]};}async[_0xbe3c1b(0x208)](){const _0x55e905=_0xbe3c1b;let {token:_0x25e7db}=await this[_0x55e905(0x1af)]();return _0x55e905(0x1ea)+_0x25e7db;}},I=class{constructor(_0x41fba6){this['inner']=_0x41fba6;}[_0xbe3c1b(0x1c2)];[_0xbe3c1b(0x1ff)]=null;[_0xbe3c1b(0x18a)]=null;async[_0xbe3c1b(0x1af)](){const _0x2bc0c9=_0xbe3c1b;if(this[_0x2bc0c9(0x1ff)]&&this[_0x2bc0c9(0x1ff)][_0x2bc0c9(0x22b)]>Date[_0x2bc0c9(0x1fb)]())return{'token':this[_0x2bc0c9(0x1ff)]['token'],'expiresIn':this['cache'][_0x2bc0c9(0x23d)]};if(this['inflight'])return this[_0x2bc0c9(0x18a)];this['inflight']=this[_0x2bc0c9(0x239)]();try{return await this[_0x2bc0c9(0x18a)];}finally{this['inflight']=null;}}async[_0xbe3c1b(0x208)](){const _0x3be46c=_0xbe3c1b;let {token:_0x38ff29}=await this[_0x3be46c(0x1af)]();return'Bearer\x20'+_0x38ff29;}async['fetchAndCache'](){const _0x44d3ab=_0xbe3c1b;let {token:_0x1c00fd,expiresIn:_0x3bd5ac}=await this[_0x44d3ab(0x1c2)][_0x44d3ab(0x1af)](),_0x28f075=Date[_0x44d3ab(0x1fb)]()+(_0x3bd5ac-0x3c)*0x3e8;return this['cache']={'token':_0x1c00fd,'expiresIn':_0x3bd5ac,'expiresAt':_0x28f075},{'token':_0x1c00fd,'expiresIn':_0x3bd5ac};}};import{randomUUID as _0x57db31}from'node:crypto';import{existsSync as _0x8e456e,mkdirSync as _0x5e9071,readFileSync as _0x3a72ef,writeFileSync as _0x1890a4}from'node:fs';import{join as _0x5f3841}from'node:path';var X=_0xbe3c1b(0x1b9),P=0x100,_=/[\p{Cc}\p{Cf}\p{Cs}\uFFFD]/u;function z(_0x116449){const _0x11636f=_0xbe3c1b;return _0x116449[_0x11636f(0x1cb)]>0x0&&_0x116449['trim']()===_0x116449&&!_['test'](_0x116449)&&new TextEncoder()[_0x11636f(0x1b1)](_0x116449)[_0x11636f(0x1a8)]<=P;}function E(_0x5e4cc2,_0x429cc5){const _0x213034=_0xbe3c1b;if(_0x5e4cc2!==void 0x0){if(typeof _0x5e4cc2!=_0x213034(0x241)||_0x5e4cc2[_0x213034(0x1cb)]===0x0)throw new TypeError(_0x213034(0x1ee)+_0x429cc5+'\x20must\x20be\x20a\x20non-empty\x20string');if(_0x5e4cc2[_0x213034(0x217)]()!==_0x5e4cc2)throw new TypeError(_0x213034(0x1ee)+_0x429cc5+_0x213034(0x198));if(_[_0x213034(0x1ed)](_0x5e4cc2))throw new TypeError('MossClient\x20options.identity.'+_0x429cc5+_0x213034(0x200));if(new TextEncoder()[_0x213034(0x1b1)](_0x5e4cc2)[_0x213034(0x1a8)]>P)throw new TypeError('MossClient\x20options.identity.'+_0x429cc5+'\x20must\x20be\x20at\x20most\x20'+P+_0x213034(0x1cf));return _0x5e4cc2;}}function k(_0x2d6d76){const _0x409961=_0xbe3c1b;if(_0x2d6d76!==void 0x0){if(_0x2d6d76===null||typeof _0x2d6d76!=_0x409961(0x20b)||Array[_0x409961(0x19a)](_0x2d6d76))throw new TypeError('MossClient\x20options.identity\x20must\x20be\x20an\x20object');return Object[_0x409961(0x1a6)]({'deviceId':E(_0x2d6d76[_0x409961(0x246)],'deviceId'),'userId':E(_0x2d6d76[_0x409961(0x193)],'userId')});}}function U(_0x580d28){return _0x580d28?.['deviceId']!==void 0x0||_0x580d28?.['userId']!==void 0x0;}function M(_0x2e5ec3){const _0x4ce095=_0xbe3c1b;if(!_0x2e5ec3?.[_0x4ce095(0x217)]())return;let _0x1183c1=_0x5f3841(_0x2e5ec3,X);try{if(_0x8e456e(_0x1183c1)){let _0x9bd8e9=_0x3a72ef(_0x1183c1,_0x4ce095(0x1b3))[_0x4ce095(0x217)]();return z(_0x9bd8e9)?_0x9bd8e9:void 0x0;}_0x5e9071(_0x2e5ec3,{'recursive':!0x0});let _0x14a57d=_0x57db31();return _0x1890a4(_0x1183c1,_0x14a57d,_0x4ce095(0x1b3)),_0x14a57d;}catch{return;}}var Y=0x1;function y(_0x33f084){const _0x40592a=_0xbe3c1b;let _0x417afb=_0x33f084[_0x40592a(0x19c)];if(typeof _0x417afb!=_0x40592a(0x1da))throw q();let _0x1b772d=_0x417afb['call'](_0x33f084);if(!Number[_0x40592a(0x1ec)](_0x1b772d)||_0x1b772d<Y)throw q();}function q(){const _0x5b85e0=_0xbe3c1b;return new Error(_0x5b85e0(0x18f));}var Ie=0x708*0x3e8;function S(_0x3c50ac){const _0xae1643=_0xbe3c1b;return _0x3c50ac instanceof Error?_0x3c50ac[_0xae1643(0x1f9)]:String(_0x3c50ac);}function Z(_0x49a724){const _0x158a64=_0xbe3c1b;if(_0x49a724===null||typeof _0x49a724!=_0x158a64(0x20b))return _0x158a64(0x1c4)+String(_0x49a724);if(Array[_0x158a64(0x19a)](_0x49a724))return _0x158a64(0x18c);let _0x35bdf0=_0x49a724;return typeof _0x35bdf0['jobId']!='string'||_0x35bdf0[_0x158a64(0x21a)]['length']===0x0?_0x158a64(0x231)+String(_0x35bdf0[_0x158a64(0x21a)])+')':typeof _0x35bdf0[_0x158a64(0x1e8)]!=_0x158a64(0x241)||_0x35bdf0[_0x158a64(0x1e8)][_0x158a64(0x1cb)]===0x0?'received\x20a\x20progress\x20event\x20with\x20a\x20missing\x20or\x20empty\x20status\x20('+String(_0x35bdf0[_0x158a64(0x1e8)])+')':typeof _0x35bdf0['progress']!=_0x158a64(0x1f5)||!Number['isFinite'](_0x35bdf0[_0x158a64(0x244)])?_0x158a64(0x1d5)+String(_0x35bdf0[_0x158a64(0x244)])+')':_0x35bdf0[_0x158a64(0x1db)]!==void 0x0&&_0x35bdf0[_0x158a64(0x1db)]!==null&&typeof _0x35bdf0['currentPhase']!='string'?'received\x20a\x20progress\x20event\x20with\x20a\x20non-string\x20currentPhase\x20('+String(_0x35bdf0[_0x158a64(0x1db)])+')':null;}var x=class{[_0xbe3c1b(0x20a)];[_0xbe3c1b(0x261)];[_0xbe3c1b(0x233)];[_0xbe3c1b(0x1a0)];[_0xbe3c1b(0x25e)];['projectId'];[_0xbe3c1b(0x203)];constructor(_0x26df4f,_0x109d15,_0x3f3eaf){const _0x20f6b8=_0xbe3c1b;this[_0x20f6b8(0x25e)]=k(_0x3f3eaf?.['identity']),this[_0x20f6b8(0x1a0)]=M(_0x3f3eaf?.[_0x20f6b8(0x1e7)]),this[_0x20f6b8(0x21d)]=_0x26df4f;let _0x357421=typeof _0x109d15==_0x20f6b8(0x241)?new f(_0x26df4f,_0x109d15):_0x109d15;this[_0x20f6b8(0x20a)]=new I(_0x357421);let _0x50300b=_0x46fea7,_0x56c784=_0x50300b[_0x20f6b8(0x253)]??_0x50300b[_0x20f6b8(0x1d9)]?.['ManageClient'],_0x261034=_0x50300b[_0x20f6b8(0x22a)]??_0x50300b[_0x20f6b8(0x1d9)]?.[_0x20f6b8(0x22a)];if(!_0x56c784||!_0x261034)throw new Error(_0x20f6b8(0x1a4));if(typeof _0x109d15==_0x20f6b8(0x241))this[_0x20f6b8(0x261)]=new _0x56c784(_0x26df4f,_0x109d15),this[_0x20f6b8(0x233)]=new _0x261034(_0x26df4f,_0x109d15);else{let _0x4d2186=_0x50300b[_0x20f6b8(0x1ac)]??_0x50300b[_0x20f6b8(0x1d9)]?.[_0x20f6b8(0x1ac)],_0x2d36b6=_0x50300b[_0x20f6b8(0x234)]??_0x50300b[_0x20f6b8(0x1d9)]?.[_0x20f6b8(0x234)];if(!_0x4d2186||!_0x2d36b6)throw new Error(_0x20f6b8(0x195));let _0xb92769=this[_0x20f6b8(0x20a)],_0x390412=(_0x204576,_0x369387)=>{const _0x5e2b12=_0x20f6b8;try{_0x2d36b6(_0x204576,_0x369387);}catch(_0x23e556){console[_0x5e2b12(0x23b)](_0x5e2b12(0x1ab)+_0x204576+_0x5e2b12(0x25c)+S(_0x23e556));}},_0x5d98ce=(_0x2f5124,_0x1cfd90)=>{try{_0x4d2186(_0x2f5124,_0x1cfd90);}catch(_0x2e8bc2){_0x390412(_0x2f5124,'moss-core\x20rejected\x20the\x20auth\x20token:\x20'+S(_0x2e8bc2));}},_0x55ddf7=!0x1,_0x4a4e3b=(_0x4fa03c,_0x3c5432)=>{const _0x54ea5f=_0x20f6b8;if(_0x4fa03c||!Number[_0x54ea5f(0x1ec)](_0x3c5432)||_0x3c5432<0x0){_0x55ddf7||(_0x55ddf7=!0x0,console[_0x54ea5f(0x23b)]('[moss]\x20Ignoring\x20an\x20auth\x20request\x20with\x20no\x20usable\x20request\x20id;\x20custom\x20authentication\x20may\x20be\x20unavailable\x20for\x20this\x20client.\x20Cause:\x20'+(_0x4fa03c?_0x4fa03c[_0x54ea5f(0x1f9)]:_0x54ea5f(0x1c4)+String(_0x3c5432))));return;}_0xb92769[_0x54ea5f(0x208)]()['then'](_0x185409=>{const _0x1de975=_0x54ea5f;let _0x3588e5=_0x185409[_0x1de975(0x259)](_0x1de975(0x1ea))?_0x185409[_0x1de975(0x1b7)](0x7):_0x185409;_0x5d98ce(_0x3c5432,_0x3588e5);},_0x4088a8=>_0x390412(_0x3c5432,S(_0x4088a8)));};this[_0x20f6b8(0x203)]=_0x4a4e3b;let _0x3fe020=_0x56c784,_0x44d05c=_0x261034;if(!_0x3fe020[_0x20f6b8(0x20c)]||!_0x44d05c[_0x20f6b8(0x20c)])throw new Error('moss-core\x20runtime\x20ManageClient/IndexManager\x20is\x20missing\x20withAuthenticator\x20factory.\x20Ensure\x20you\x20are\x20using\x20a\x20moss-core\x20build\x20that\x20supports\x20custom\x20authenticators.');this['manageClient']=_0x3fe020['withAuthenticator'](_0x26df4f,_0x4a4e3b),this[_0x20f6b8(0x233)]=_0x44d05c['withAuthenticator'](_0x26df4f,_0x4a4e3b);}this['applyIdentity'](this[_0x20f6b8(0x233)]);}async[_0xbe3c1b(0x21f)](){const _0x3f4109=_0xbe3c1b;let _0x338748=this['indexManager'][_0x3f4109(0x21f)];if(typeof _0x338748!=_0x3f4109(0x1da))throw new Error(_0x3f4109(0x1fc));await _0x338748[_0x3f4109(0x20e)](this[_0x3f4109(0x233)]);}async[_0xbe3c1b(0x1af)](){const _0x383990=_0xbe3c1b;return this[_0x383990(0x20a)]['getAuthToken']();}[_0xbe3c1b(0x225)](_0x146108){if(!_0x146108)return;let _0x37e750=!0x1;return(_0x57f1d7,_0x1c6e29)=>{const _0x175045=_0xb5a9;let _0x50c60e=_0x57f1d7?_0x57f1d7[_0x175045(0x1f9)]:Z(_0x1c6e29);if(_0x50c60e!==null){_0x37e750||(_0x37e750=!0x0,console[_0x175045(0x23b)](_0x175045(0x191)+_0x50c60e));return;}_0x146108(_0x1c6e29);};}[_0xbe3c1b(0x1e3)](_0x350765){const _0x413deb=_0xbe3c1b;let _0x3b4f2e=_0x350765['trim']()[_0x413deb(0x238)]()[_0x413deb(0x235)](/\s+/g,'_'),_0x40a07b=_0x3b4f2e[_0x413deb(0x235)](/_/g,'');if(_0x3b4f2e==='pending_upload'||_0x40a07b===_0x413deb(0x189))return _0x6363d6[_0x413deb(0x1f7)];if(_0x3b4f2e===_0x413deb(0x1b4))return _0x6363d6[_0x413deb(0x227)];if(_0x3b4f2e==='building')return _0x6363d6[_0x413deb(0x1be)];if(_0x3b4f2e===_0x413deb(0x190))return _0x6363d6[_0x413deb(0x23e)];if(_0x3b4f2e===_0x413deb(0x260))return _0x6363d6[_0x413deb(0x1e2)];throw new Error('Unsupported\x20job\x20status\x20\x27'+_0x350765+_0x413deb(0x1b8));}async[_0xbe3c1b(0x230)](_0x4e6470,_0x84b530,_0x1ee26c,_0x5dcb05){const _0x5a5dc1=_0xbe3c1b;if(!_0x84b530[_0x5a5dc1(0x1cb)])throw new Error('createIndex\x20requires\x20at\x20least\x20one\x20document');return await this['manageClient']['createIndex'](_0x4e6470,_0x84b530,_0x1ee26c,this[_0x5a5dc1(0x225)](_0x5dcb05?.[_0x5a5dc1(0x23f)]));}async['toByteArray'](_0x16d970){const _0x5d1044=_0xbe3c1b;if(_0x16d970 instanceof Uint8Array)return Array[_0x5d1044(0x221)](_0x16d970);if(_0x16d970 instanceof ArrayBuffer)return Array['from'](new Uint8Array(_0x16d970));if(typeof _0x16d970[_0x5d1044(0x232)]=='function'){let _0x3250a8=await _0x16d970[_0x5d1044(0x232)]();return Array[_0x5d1044(0x221)](new Uint8Array(_0x3250a8));}throw new Error(_0x5d1044(0x23a));}async[_0xbe3c1b(0x257)](_0x448223,_0x37207f,_0x513b2a){const _0x6f5245=_0xbe3c1b;if(_0x37207f[_0x6f5245(0x1cb)]===0x0)throw new Error(_0x6f5245(0x1f1));let _0x1e5688=_0x513b2a?.['modelId']??_0x6f5245(0x204),_0x36501c=await Promise[_0x6f5245(0x1c3)](_0x37207f[_0x6f5245(0x1c8)](async _0x10efaf=>({'name':_0x10efaf[_0x6f5245(0x192)],'contentType':_0x10efaf[_0x6f5245(0x1fa)],'path':_0x10efaf[_0x6f5245(0x24d)]??void 0x0,'data':_0x10efaf['data']!=null?await this['toByteArray'](_0x10efaf[_0x6f5245(0x196)]):void 0x0})));return await this[_0x6f5245(0x261)][_0x6f5245(0x257)](_0x448223,_0x36501c,_0x1e5688,this['wrapProgress'](_0x513b2a?.[_0x6f5245(0x23f)]),_0x513b2a?.[_0x6f5245(0x1d4)]??null);}async[_0xbe3c1b(0x1c7)](_0x433bdd,_0x42fb76,_0x3e89fa){const _0x52268b=_0xbe3c1b;if(Array['isArray'](_0x42fb76)&&_0x42fb76['length']===0x0)throw new Error('addDocs\x20requires\x20at\x20least\x20one\x20document');return await this[_0x52268b(0x261)]['addDocs'](_0x433bdd,_0x42fb76,_0x3e89fa??null,this[_0x52268b(0x225)](_0x3e89fa?.['onProgress']));}async[_0xbe3c1b(0x24f)](_0x1d27cc,_0x3d7d94,_0x6169c){const _0x36983b=_0xbe3c1b;if(Array[_0x36983b(0x19a)](_0x3d7d94)&&_0x3d7d94[_0x36983b(0x1cb)]===0x0)throw new Error(_0x36983b(0x1f6));return await this[_0x36983b(0x261)][_0x36983b(0x24f)](_0x1d27cc,_0x3d7d94,this['wrapProgress'](_0x6169c?.['onProgress']));}async[_0xbe3c1b(0x24a)](_0x5a83f8){const _0x5c3ee3=_0xbe3c1b;let _0x54b127=await this['manageClient']['getJobStatus'](_0x5a83f8);return{..._0x54b127,'status':this[_0x5c3ee3(0x1e3)](_0x54b127['status']),'currentPhase':_0x54b127[_0x5c3ee3(0x1db)]??null,'error':_0x54b127[_0x5c3ee3(0x19e)]??null};}async[_0xbe3c1b(0x1d6)](_0x3080c7){return this['manageClient']['getIndex'](_0x3080c7);}async[_0xbe3c1b(0x197)](){const _0x43be6b=_0xbe3c1b;return this[_0x43be6b(0x261)][_0x43be6b(0x197)]();}async['deleteIndex'](_0x94cbcb){const _0x4f517d=_0xbe3c1b;return this[_0x4f517d(0x261)]['deleteIndex'](_0x94cbcb);}async['getDocs'](_0x3cef08,_0x5c23e7){const _0x248010=_0xbe3c1b;return this['manageClient'][_0x248010(0x25a)](_0x3cef08,_0x5c23e7??null);}async['loadIndex'](_0x103ca7,_0x592cd5){const _0x42ac96=_0xbe3c1b;this[_0x42ac96(0x24c)](_0x592cd5?.['cachePath']);let _0x1c3c36=await this['indexManager'][_0x42ac96(0x18e)](_0x103ca7,_0x592cd5??null);return _0x1c3c36['model']['id']!=='custom'&&await this['indexManager'][_0x42ac96(0x207)](_0x103ca7),_0x1c3c36[_0x42ac96(0x192)];}async['loadIndexes'](_0xae8592,_0x34462f){const _0x32f2f3=_0xbe3c1b;let _0xd9368e=this[_0x32f2f3(0x237)]();return this['ensureCachePathDeviceId'](_0x34462f?.[_0x32f2f3(0x1e7)]),_0xd9368e[_0x32f2f3(0x1fd)](_0xae8592,_0x34462f??null);}async[_0xbe3c1b(0x256)](_0x2e2432){const _0x261e6f=_0xbe3c1b;return this['indexManager'][_0x261e6f(0x256)](_0x2e2432);}async['unloadIndexes'](_0x3a4ae1){const _0x4a1aea=_0xbe3c1b;return this[_0x4a1aea(0x237)]()[_0x4a1aea(0x1ba)](_0x3a4ae1);}[_0xbe3c1b(0x237)](){const _0x581eec=_0xbe3c1b;let _0xaec773=this['indexManager'];if(typeof _0xaec773[_0x581eec(0x222)]!=_0x581eec(0x1da)||typeof _0xaec773[_0x581eec(0x19f)]!=_0x581eec(0x1da)||typeof _0xaec773[_0x581eec(0x1fd)]!=_0x581eec(0x1da)||typeof _0xaec773[_0x581eec(0x1ba)]!=_0x581eec(0x1da))throw new Error(_0x581eec(0x1a3));return{'queryMultiIndex':_0xaec773['queryMultiIndex']['bind'](_0xaec773),'queryMultiIndexText':_0xaec773[_0x581eec(0x19f)]['bind'](_0xaec773),'loadIndexes':_0xaec773[_0x581eec(0x1fd)][_0x581eec(0x1ce)](_0xaec773),'unloadIndexes':_0xaec773[_0x581eec(0x1ba)]['bind'](_0xaec773)};}['ensureCachePathDeviceId'](_0x5c3b1a){const _0x423656=_0xbe3c1b;_0x5c3b1a&&this[_0x423656(0x1a0)]===void 0x0&&M(_0x5c3b1a);}[_0xbe3c1b(0x229)]=_0x50d8ea=>{const _0x2e4955=_0xbe3c1b;!U(this[_0x2e4955(0x25e)])&&this['cachePathDeviceId']===void 0x0||_0x50d8ea[_0x2e4955(0x1cc)](this[_0x2e4955(0x25e)]?.['deviceId']??null,this['configuredIdentity']?.[_0x2e4955(0x193)]??null,this[_0x2e4955(0x1a0)]??null);};[_0xbe3c1b(0x249)]=_0xfb39f9=>{const _0x38ba5e=_0xbe3c1b;let _0x443b58=this[_0x38ba5e(0x233)][_0x38ba5e(0x1ad)]?.();if(!_0x443b58){this[_0x38ba5e(0x229)](_0xfb39f9);return;}_0xfb39f9[_0x38ba5e(0x1cc)](_0x443b58[_0x38ba5e(0x246)]??null,this[_0x38ba5e(0x25e)]?.[_0x38ba5e(0x193)]??null,_0x443b58['mossDeviceId']??null);};['hasCustomAuthenticator'](){return this['authNotifyFn']!==void 0x0;}async[_0xbe3c1b(0x245)](_0x147a38,_0x16f73c,_0x21c68e){const _0x3ed09d=_0xbe3c1b;if(!this[_0x3ed09d(0x203)])throw new Error('createAuthenticatedSessionInner\x20requires\x20a\x20custom\x20IAuthenticator\x20client');let _0xa4f6bd=_0x46fea7,_0x1d2b83=_0xa4f6bd[_0x3ed09d(0x22f)]??_0xa4f6bd[_0x3ed09d(0x1d9)]?.[_0x3ed09d(0x22f)];if(!_0x1d2b83||typeof _0x1d2b83[_0x3ed09d(0x20c)]!=_0x3ed09d(0x1da))throw new Error(_0x3ed09d(0x25f));return _0x21c68e&&y(_0x1d2b83),_0x1d2b83[_0x3ed09d(0x20c)](_0x147a38,_0x16f73c,this[_0x3ed09d(0x21d)],this[_0x3ed09d(0x203)],null,null,_0x21c68e?.[_0x3ed09d(0x218)]??null,_0x21c68e?.[_0x3ed09d(0x1f0)]??null);}async['query'](_0x11d416,_0xd515c5,_0x15d35c){const _0x16c55e=_0xbe3c1b;if(!await this[_0x16c55e(0x233)][_0x16c55e(0x206)](_0x11d416))throw new Error('Index\x20\x22'+_0x11d416+'\x22\x20is\x20not\x20loaded.\x20Call\x20loadIndex(\x22'+_0x11d416+_0x16c55e(0x258));let _0x256eaf=_0x15d35c?.[_0x16c55e(0x242)]??0x5,_0x46c16c=_0x15d35c?.['alpha']??0.8;return _0x15d35c?.[_0x16c55e(0x1cd)]?this['indexManager'][_0x16c55e(0x236)](_0x11d416,_0xd515c5,_0x15d35c['embedding'],_0x256eaf,_0x46c16c,_0x15d35c?.[_0x16c55e(0x1ef)]):this['indexManager'][_0x16c55e(0x1bc)](_0x11d416,_0xd515c5,_0x256eaf,_0x46c16c,_0x15d35c?.['filter']);}async[_0xbe3c1b(0x222)](_0x50fff0,_0x93b751,_0x32a376){const _0x41985a=_0xbe3c1b;if(_0x50fff0[_0x41985a(0x1cb)]===0x0)throw new Error('queryMultiIndex\x20requires\x20at\x20least\x20one\x20index\x20name');let _0x3f7296=this['requireMultiIndexCore'](),_0x33731d=_0x32a376?.['topK']??0xa,_0x178fa0=_0x32a376?.[_0x41985a(0x21c)]??0.8;if(_0x32a376?.[_0x41985a(0x1cd)])return _0x3f7296[_0x41985a(0x222)](_0x50fff0,_0x93b751,_0x32a376['embedding'],_0x33731d,_0x178fa0,_0x32a376?.[_0x41985a(0x1ef)]);try{return await _0x3f7296[_0x41985a(0x19f)](_0x50fff0,_0x93b751,_0x33731d,_0x178fa0,_0x32a376?.[_0x41985a(0x1ef)]);}catch(_0x522e0c){throw _0x522e0c instanceof Error&&_0x522e0c[_0x41985a(0x1f9)]['includes']('no\x20exact\x20artifact\x20identity')?new Error(_0x522e0c[_0x41985a(0x1f9)]+_0x41985a(0x1d2),{'cause':_0x522e0c}):_0x522e0c instanceof Error&&_0x522e0c[_0x41985a(0x1f9)][_0x41985a(0x205)]('requires\x20explicit\x20query\x20embeddings')?new Error(_0x41985a(0x262),{'cause':_0x522e0c}):_0x522e0c;}}};import{SessionIndex as _0x14da15}from'@moss-js/moss-core';var h=class r{#e;#r;#s;#i=!0x1;#a;constructor(_0x17e339,_0x273fdb,_0x1b3e00){this.#s=_0x17e339,this.#r=_0x273fdb,this.#e=_0x1b3e00;}static async[_0xbe3c1b(0x248)](_0x4da06c,_0x536224,_0x1dca81,_0x966f58,_0x56d210,_0x1cbb77,_0x116076){const _0x5c76e4=_0xbe3c1b;let _0x1b4b09=_0x14da15;_0x116076&&y(_0x1b4b09);let _0x3cfafd=await _0x1b4b09['create'](_0x4da06c,_0x536224,_0x1dca81,_0x966f58,_0x56d210??null,_0x116076?.['version']??null,_0x116076?.[_0x5c76e4(0x1f0)]??null);return r['_fromInner'](_0x4da06c,_0x536224,_0x3cfafd,_0x1cbb77);}static[_0xbe3c1b(0x19d)](_0xdd3f88,_0x31d15f,_0xd86c48,_0x4a9dee){return _0x4a9dee?.(_0xd86c48),new r(_0xdd3f88,_0x31d15f,_0xd86c48);}get[_0xbe3c1b(0x192)](){return this.#s;}get[_0xbe3c1b(0x25b)](){const _0xb48905=_0xbe3c1b;return this.#n(),this.#e[_0xb48905(0x25b)];}get[_0xbe3c1b(0x1a1)](){return this.#r;}async[_0xbe3c1b(0x1c7)](_0x18e85d,_0x526e47){const _0x1fde92=_0xbe3c1b;this.#n();let _0x450c5c=_0x526e47?{'upsert':_0x526e47['upsert']??!0x0}:void 0x0;if(this.#r===_0x1fde92(0x1dd)){let _0x44b98e=r.#t(_0x18e85d),_0x4c3814=_0x18e85d[_0x1fde92(0x1c8)](_0x22899=>{const _0x5bd3d0=_0x1fde92;let _0x4442ad={..._0x22899};return delete _0x4442ad[_0x5bd3d0(0x1cd)],_0x4442ad;}),_0x33b531=await this.#e[_0x1fde92(0x194)](_0x4c3814,_0x44b98e,_0x450c5c);return{'added':_0x33b531[_0x1fde92(0x20f)],'updated':_0x33b531[_0x1fde92(0x254)]};}let _0x162904=await this.#e[_0x1fde92(0x1f8)](_0x18e85d,_0x450c5c);return{'added':_0x162904[_0x1fde92(0x20f)],'updated':_0x162904['updated']};}async[_0xbe3c1b(0x24f)](_0x53a98e){return this.#n(),await this.#e['deleteDocuments'](_0x53a98e);}async[_0xbe3c1b(0x25a)](_0x95172c){const _0x1467ee=_0xbe3c1b;return this.#n(),await this.#e[_0x1467ee(0x240)](_0x95172c??null);}async[_0xbe3c1b(0x236)](_0x54c130,_0x276ea8){const _0x3997d5=_0xbe3c1b;this.#n();let _0x516dbc=_0x276ea8?.[_0x3997d5(0x242)]??0x5,_0x541927=_0x276ea8?.[_0x3997d5(0x21c)]??0.8,_0x34a64b=_0x276ea8?.['filter']??null,_0x555935=_0x276ea8?.[_0x3997d5(0x1cd)];if(_0x555935==null){if(this.#r===_0x3997d5(0x1dd))throw new Error('This\x20session\x20uses\x20custom\x20embeddings.\x20Provide\x20a\x20query\x20embedding\x20via\x20QueryOptions.embedding.');return await this.#e[_0x3997d5(0x1bc)](_0x54c130,_0x516dbc,_0x541927,_0x34a64b);}return await this.#e[_0x3997d5(0x236)](_0x54c130,_0x516dbc,Array[_0x3997d5(0x221)](_0x555935),_0x541927,_0x34a64b);}async[_0xbe3c1b(0x18e)](_0x415c2d,_0x478435){const _0x149665=_0xbe3c1b;return this.#n(),this.#e[_0x149665(0x18e)](_0x415c2d,_0x478435??null);}async[_0xbe3c1b(0x1bd)](){const _0x3ab247=_0xbe3c1b;return this.#n(),this.#e[_0x3ab247(0x1bd)]();}async[_0xbe3c1b(0x228)](_0x4ba834){const _0x8a3cb0=_0xbe3c1b;this.#n(),await this.#e[_0x8a3cb0(0x228)](_0x4ba834);}async[_0xbe3c1b(0x19b)](_0x310d35,_0xfd4bad){const _0x4d8170=_0xbe3c1b;this.#n();let _0x173ec1=_0xfd4bad?.[_0x4d8170(0x1c1)]??!0x0;return await this.#e[_0x4d8170(0x19b)](_0x310d35,{'rebuildLegacy':_0x173ec1});}async[_0xbe3c1b(0x1a5)](_0x45ea6f){const _0x482f91=_0xbe3c1b;return this.#n(),await this.#e[_0x482f91(0x1a5)](_0x45ea6f);}#n(){const _0x42a935=_0xbe3c1b;if(this.#i)throw new Error(_0x42a935(0x1a7)+this.#s+'\x27\x20is\x20closed');}[_0xbe3c1b(0x21f)](){return this.#a??=this.#o(),this.#a;}async #o(){const _0x21f142=_0xbe3c1b;this.#i=!0x0;let _0x55482d=this.#e[_0x21f142(0x21f)];if(typeof _0x55482d!=_0x21f142(0x1da))throw new Error(_0x21f142(0x202));await _0x55482d[_0x21f142(0x20e)](this.#e);}async[Symbol[_0xbe3c1b(0x1f3)]](){const _0x8ead39=_0xbe3c1b;return this[_0x8ead39(0x21f)]();}async[_0xbe3c1b(0x1e5)](){const _0xf7b6d4=_0xbe3c1b;this.#n(),this.#r!==_0xf7b6d4(0x1dd)&&await this.#e[_0xf7b6d4(0x1a9)]();}static#t(_0x5c5a3b){const _0x315d96=_0xbe3c1b;let _0x383091=_0x5c5a3b['filter'](_0x339aa7=>!_0x339aa7['embedding']||_0x339aa7['embedding'][_0x315d96(0x1cb)]===0x0)['map'](_0x15e7fb=>_0x15e7fb['id']);if(_0x383091[_0x315d96(0x1cb)]>0x0)throw new Error(_0x315d96(0x1d8)+_0x383091[_0x315d96(0x1a2)](',\x20')+_0x315d96(0x1b6));return _0x5c5a3b[_0x315d96(0x1c8)](_0x573514=>Array[_0x315d96(0x221)](_0x573514[_0x315d96(0x1cd)]??[]));}},te=_0xbe3c1b(0x18b),ne=_0xbe3c1b(0x1d3),b=class extends Error{['status'];[_0xbe3c1b(0x211)];constructor(_0x31d117,_0x56377c){const _0x19303b=_0xbe3c1b;let _0x205eac=_0x56377c?':\x20'+_0x56377c:'';super(_0x19303b(0x22d)+_0x31d117+_0x205eac),this[_0x19303b(0x192)]=_0x19303b(0x1c5),this[_0x19303b(0x1e8)]=_0x31d117,this[_0x19303b(0x211)]=_0x56377c;}};function re(){const _0x9a5281=_0xbe3c1b;return''+(typeof process<'u'&&process[_0x9a5281(0x201)][_0x9a5281(0x223)]||te)['replace'](/\/+$/,'')+ne;}function se(_0x4fe443){const _0x1cc498=_0xbe3c1b;return _0x4fe443?Object[_0x1cc498(0x1aa)](Object[_0x1cc498(0x18d)](_0x4fe443)[_0x1cc498(0x1ef)](([,_0x41a34f])=>_0x41a34f!==void 0x0)):{};}async function j(_0x1e4cb3,_0x247a2f,_0x113ec9,_0x5a52d0){const _0x12e334=_0xbe3c1b;let _0x4b477e={...se(_0x5a52d0),'action':_0x113ec9,'projectId':_0x1e4cb3},_0x3fea5f=await fetch(re(),{'method':_0x12e334(0x1bf),'headers':{'Content-Type':_0x12e334(0x1b0),'X-Project-Key':_0x247a2f},'body':JSON[_0x12e334(0x251)](_0x4b477e),'signal':AbortSignal[_0x12e334(0x25d)](0x927c0)}),_0x24cbca=await _0x3fea5f['text']();if(!_0x3fea5f['ok'])throw new b(_0x3fea5f[_0x12e334(0x1e8)],_0x24cbca);return _0x24cbca?JSON['parse'](_0x24cbca):{};}var F='moss-minilm',A=class{#e;#r;#s;#i=!0x1;#a;#n=new Set();constructor(_0x128902,_0x55b291,_0x393c24){const _0x2ef627=_0xbe3c1b;this.#e=new x(_0x128902,_0x55b291,_0x393c24),this.#r=_0x128902,this.#s=typeof _0x55b291==_0x2ef627(0x241)?_0x55b291:null;}async[_0xbe3c1b(0x1af)](){const _0x1c29cc=_0xbe3c1b;return this.#t(),this.#e[_0x1c29cc(0x1af)]();}async['createIndex'](_0x2ef3c7,_0xfbf0c2,_0x3f1856){const _0xdd6446=_0xbe3c1b;this.#t();let _0xce121a;return _0x3f1856?.[_0xdd6446(0x1a1)]!==void 0x0?_0xce121a=_0x3f1856[_0xdd6446(0x1a1)]:_0xce121a=_0xfbf0c2[_0xdd6446(0x212)](_0x45d501=>Array[_0xdd6446(0x19a)](_0x45d501[_0xdd6446(0x1cd)])&&_0x45d501[_0xdd6446(0x1cd)]['length']>0x0)?'custom':F,this.#e[_0xdd6446(0x230)](_0x2ef3c7,_0xfbf0c2,_0xce121a,_0x3f1856);}async[_0xbe3c1b(0x257)](_0x5d0605,_0x4839c2,_0x36b0a0){const _0x150bdd=_0xbe3c1b;return this.#t(),this.#e[_0x150bdd(0x257)](_0x5d0605,_0x4839c2,_0x36b0a0);}async[_0xbe3c1b(0x1d6)](_0xd378ca){const _0x4d8993=_0xbe3c1b;return this.#t(),this.#e[_0x4d8993(0x1d6)](_0xd378ca);}async[_0xbe3c1b(0x197)](){const _0x220c57=_0xbe3c1b;return this.#t(),this.#e[_0x220c57(0x197)]();}async[_0xbe3c1b(0x252)](_0x27184e){const _0x5907b2=_0xbe3c1b;return this.#t(),this.#e[_0x5907b2(0x252)](_0x27184e);}async['addDocs'](_0x57af18,_0x38c597,_0x570e43){const _0x3ab1e7=_0xbe3c1b;return this.#t(),this.#e[_0x3ab1e7(0x1c7)](_0x57af18,_0x38c597,_0x570e43);}async[_0xbe3c1b(0x24f)](_0x2ed711,_0x8c0a1e,_0x30f047){const _0x565132=_0xbe3c1b;return this.#t(),this.#e[_0x565132(0x24f)](_0x2ed711,_0x8c0a1e,_0x30f047);}async[_0xbe3c1b(0x24a)](_0x329864){return this.#t(),this.#e['getJobStatus'](_0x329864);}async[_0xbe3c1b(0x213)](_0x4df2de,_0x4d5f01,_0x4fd5b2){const _0x48f705=_0xbe3c1b;return this.#t(),this.#o(_0x48f705(0x213),{'rootUrl':_0x4df2de,'indexName':_0x4d5f01,'maxPages':_0x4fd5b2?.[_0x48f705(0x247)],'maxDocuments':_0x4fd5b2?.[_0x48f705(0x1b2)],'maxDepth':_0x4fd5b2?.['maxDepth'],'includePaths':_0x4fd5b2?.[_0x48f705(0x1c9)],'excludePaths':_0x4fd5b2?.[_0x48f705(0x220)],'respectRobots':_0x4fd5b2?.[_0x48f705(0x1eb)],'parseDocuments':_0x4fd5b2?.[_0x48f705(0x215)],'refreshCadence':_0x4fd5b2?.[_0x48f705(0x24b)],'modelId':_0x4fd5b2?.['modelId']});}async[_0xbe3c1b(0x1ae)](_0x48b784){const _0x1cfa3d=_0xbe3c1b;this.#t();let _0x3cf666=(await this.#o(_0x1cfa3d(0x1ae),_0x48b784!==void 0x0?{'indexName':_0x48b784}:void 0x0))[_0x1cfa3d(0x1d0)]??[];return _0x48b784===void 0x0?_0x3cf666:_0x3cf666[_0x1cfa3d(0x1ef)](_0x3fedb3=>_0x3fedb3[_0x1cfa3d(0x219)]===_0x48b784);}async['getWebSource'](_0x5cdf3d){const _0x523452=_0xbe3c1b;return this.#t(),this.#o(_0x523452(0x1e9),{'sourceId':_0x5cdf3d});}async[_0xbe3c1b(0x1df)](_0x179c4c,_0x46752d){const _0x4b784f=_0xbe3c1b;return this.#t(),this.#o(_0x4b784f(0x1df),{'sourceId':_0x179c4c,'refreshCadence':_0x46752d[_0x4b784f(0x24b)],'rootUrl':_0x46752d['rootUrl'],'includePaths':_0x46752d[_0x4b784f(0x1c9)],'excludePaths':_0x46752d[_0x4b784f(0x220)],'maxDepth':_0x46752d[_0x4b784f(0x22e)],'maxPages':_0x46752d[_0x4b784f(0x247)],'resync':_0x46752d[_0x4b784f(0x1b5)]});}async[_0xbe3c1b(0x1bb)](_0x17c61d){const _0x5376db=_0xbe3c1b;return this.#t(),this.#o(_0x5376db(0x1bb),{'sourceId':_0x17c61d});}async[_0xbe3c1b(0x1dc)](_0x2a3410){const _0x340a87=_0xbe3c1b;return this.#t(),this.#o(_0x340a87(0x1dc),{'sourceId':_0x2a3410});}async #o(_0x218ca9,_0x1fd352){const _0x581d53=_0xbe3c1b;if(this.#s===null)throw new Error(_0x581d53(0x250));return j(this.#r,this.#s,_0x218ca9,_0x1fd352);}async['getDocs'](_0xe0968f,_0x4dc852){const _0x29deca=_0xbe3c1b;return this.#t(),this.#e[_0x29deca(0x25a)](_0xe0968f,_0x4dc852);}async[_0xbe3c1b(0x18e)](_0x2210ff,_0x90753e){return this.#t(),this.#e['loadIndex'](_0x2210ff,_0x90753e);}async[_0xbe3c1b(0x1fd)](_0x99c949,_0x143859){const _0xe6eee3=_0xbe3c1b;return this.#t(),this.#e[_0xe6eee3(0x1fd)](_0x99c949,_0x143859);}async['unloadIndex'](_0x45c777){const _0x181c2e=_0xbe3c1b;return this.#t(),this.#e[_0x181c2e(0x256)](_0x45c777);}async[_0xbe3c1b(0x1ba)](_0xcdb25a){return this.#t(),this.#e['unloadIndexes'](_0xcdb25a);}async[_0xbe3c1b(0x236)](_0x2d4b89,_0x555576,_0x5d757f){const _0x1415cb=_0xbe3c1b;return this.#t(),this.#e[_0x1415cb(0x236)](_0x2d4b89,_0x555576,_0x5d757f);}async['queryMultiIndex'](_0x4ff9e9,_0x1a9cc5,_0x563506){const _0x1e3501=_0xbe3c1b;return this.#t(),this.#e[_0x1e3501(0x222)](_0x4ff9e9,_0x1a9cc5,_0x563506);}async['session'](_0x2da034,_0x4fb6a5=F,_0x3d591d){const _0x574687=_0xbe3c1b;this.#t();let _0x2b8ad8=this.#e[_0x574687(0x249)],_0x4d26d1;if(this.#s!==null)_0x4d26d1=await h[_0x574687(0x248)](_0x2da034,_0x4fb6a5,this.#r,this.#s,void 0x0,_0x2b8ad8,_0x3d591d);else{let _0x289311=await this.#e[_0x574687(0x245)](_0x2da034,_0x4fb6a5,_0x3d591d);_0x4d26d1=h[_0x574687(0x19d)](_0x2da034,_0x4fb6a5,_0x289311,_0x2b8ad8);}await _0x4d26d1[_0x574687(0x1e5)]();for(let _0x2a58a6 of this.#n)_0x2a58a6[_0x574687(0x210)]()||this.#n[_0x574687(0x1fe)](_0x2a58a6);return this.#n[_0x574687(0x1c0)](new WeakRef(_0x4d26d1)),_0x4d26d1;}#t(){const _0x2806c4=_0xbe3c1b;if(this.#i)throw new Error(_0x2806c4(0x1e1));}['close'](){return this.#a??=this.#u(),this.#a;}async #u(){const _0x53fb29=_0xbe3c1b;this.#i=!0x0;let _0x5abdaa=[...this.#n][_0x53fb29(0x1c8)](_0x2a2d03=>_0x2a2d03[_0x53fb29(0x210)]())[_0x53fb29(0x1ef)](_0x4221cd=>_0x4221cd!==void 0x0);this.#n['clear'](),await Promise['all'](_0x5abdaa[_0x53fb29(0x1c8)](_0x1b341=>_0x1b341[_0x53fb29(0x21f)]())),await this.#e[_0x53fb29(0x21f)]();}async[Symbol['asyncDispose']](){const _0x2e0481=_0xbe3c1b;return this[_0x2e0481(0x21f)]();}};function _0x77d9(){const _0x49ab17=['Failed','normalizeJobStatus','3793427eWNywA','_warmModel','SDK_VERSION_NUMBER','cachePath','status','getWebSource','Bearer\x20','respectRobots','isSafeInteger','test','MossClient\x20options.identity.','filter','manifestSha256','createIndexFromFiles\x20requires\x20at\x20least\x20one\x20file','text','asyncDispose','CLOUD_API_INDEX_URL','number','deleteDocs\x20requires\x20at\x20least\x20one\x20document\x20ID','PendingUpload','addDocumentsText','message','contentType','now','@moss-js/moss-core\x20>=\x200.20.0\x20is\x20required\x20for\x20MossClient.close()','loadIndexes','delete','cache','\x20contains\x20an\x20unsupported\x20character','env','@moss-js/moss-core\x20>=\x200.20.0\x20is\x20required\x20for\x20SessionIndex.close()','authNotifyFn','moss-minilm','includes','hasIndex','loadQueryModel','getAuthHeader','projectKey','authenticator','object','withAuthenticator','30eEETLK','call','added','deref','body','some','createWebSource','CLOUD_API_AUTH_URL','parseDocuments','23832BcyvmZ','trim','version','indexName','jobId','36rIubtc','alpha','projectId','1856AUNMmY','close','excludePaths','from','queryMultiIndex','MOSS_CLOUD_API_BASE_URL','MOSS_INDEX_URL','wrapProgress','860343iozovX','Uploading','saveToDisk','applyIdentity','IndexManager','expiresAt','CLOUD_API_IDENTITY_URL','HTTP\x20error!\x20status:\x20','maxDepth','SessionIndex','createIndex','received\x20a\x20progress\x20event\x20with\x20a\x20missing\x20or\x20empty\x20jobId\x20(','arrayBuffer','indexManager','rejectAuthRequest','replace','query','requireMultiIndexCore','toLowerCase','fetchAndCache','Unsupported\x20data\x20type\x20for\x20file\x20upload','warn','2YybPlo','expiresIn','Completed','onProgress','getDocuments','string','topK','authUrl','progress','createAuthenticatedSessionInner','deviceId','maxPages','_create','applySessionIdentity','getJobStatus','refreshCadence','ensureCachePathDeviceId','path','8aHeEnT','deleteDocs','Web\x20source\x20methods\x20require\x20a\x20project\x20key.\x20Construct\x20MossClient\x20with\x20(projectId,\x20projectKey).','stringify','deleteIndex','ManageClient','updated','MODEL_DOWNLOAD_URL','unloadIndex','createIndexFromFiles','\x22)\x20or\x20loadIndexes([...])\x20before\x20querying;\x20queries\x20run\x20locally\x20and\x20there\x20is\x20no\x20cloud\x20query\x20fallback.','startsWith','getDocs','docCount','\x20could\x20not\x20be\x20settled:\x20','timeout','configuredIdentity','moss-core\x20runtime\x20SessionIndex\x20is\x20missing\x20the\x20withAuthenticator\x20factory.\x20Upgrade\x20@moss-js/moss-core\x20to\x20a\x20build\x20that\x20supports\x20custom\x20authenticators\x20for\x20sessions.','failed','manageClient','One\x20or\x20more\x20indexes\x20use\x20custom\x20embeddings.\x20Provide\x20a\x20query\x20vector\x20via\x20options.embedding,\x20or\x20use\x20alpha\x200\x20for\x20keyword-only\x20search.','pendingupload','inflight','https://service.usemoss.dev','received\x20an\x20array\x20where\x20a\x20JobProgress\x20object\x20was\x20expected','entries','loadIndex','The\x20installed\x20@moss-js/moss-core\x20runtime\x20does\x20not\x20support\x20exact\x20model\x20artifact\x20identities.\x20Upgrade\x20moss-core\x20before\x20creating\x20this\x20session.','completed','[moss]\x20Dropping\x20a\x20malformed\x20job\x20progress\x20event;\x20progress\x20reporting\x20may\x20be\x20incomplete\x20for\x20this\x20operation.\x20Cause:\x20','name','userId','addDocuments','moss-core\x20runtime\x20is\x20missing\x20resolveAuthRequest/rejectAuthRequest\x20exports.\x20Ensure\x20you\x20are\x20using\x20a\x20moss-core\x20build\x20that\x20supports\x20custom\x20authenticators.','data','listIndexes','\x20must\x20not\x20have\x20leading\x20or\x20trailing\x20whitespace','MOSS_AUTH_URL','isArray','loadFromDisk','modelArtifactContractVersion','_fromInner','error','queryMultiIndexText','cachePathDeviceId','modelId','join','The\x20installed\x20@moss-js/moss-core\x20does\x20not\x20support\x20multi-index\x20operations\x20(queryMultiIndex,\x20loadIndexes,\x20unloadIndexes).\x20Upgrade\x20@moss-js/moss-core.','moss-core\x20runtime\x20is\x20missing\x20ManageClient/IndexManager\x20exports','inspectSnapshot','freeze','SessionIndex\x20\x27','byteLength','loadModel','fromEntries','[moss]\x20Auth\x20request\x20','resolveAuthRequest','deviceIdentity','listWebSources','getAuthToken','application/json','encode','maxDocuments','utf8','uploading','resync','.\x20All\x20documents\x20must\x20have\x20.embedding\x20set\x20when\x20using\x20modelId=\x27custom\x27.','slice','\x27\x20returned\x20by\x20moss-core','.moss-device-id','unloadIndexes','resyncWebSource','queryText','pushIndex','Building','POST','add','rebuildLegacy','inner','all','received\x20','ManageApiError','26826muqPxs','addDocs','map','includePaths','55LAxQKl','length','setIdentity','embedding','bind','\x20UTF-8\x20bytes','sources','1134929GWbtvB','\x20Provide\x20a\x20query\x20vector\x20via\x20options.embedding,\x20or\x20use\x20alpha\x200\x20for\x20keyword-only\x20search.','/v1/manage','parseOptions','received\x20a\x20progress\x20event\x20with\x20a\x20non-finite\x20progress\x20value\x20(','getIndex','4925284ZFuioG','Documents\x20missing\x20.embedding\x20for\x20custom\x20model:\x20','default','function','currentPhase','deleteWebSource','custom','3196053adwZtG','updateWebSource','json','MossClient\x20is\x20closed'];_0x77d9=function(){return _0x49ab17;};return _0x77d9();}export{b as ManageApiError,A as MossClient,h as SessionIndex};
|
|
1
|
+
function _0x5865(){const _0xd31e47=['moss-core\x20runtime\x20SessionIndex\x20is\x20missing\x20the\x20withAuthenticator\x20factory.\x20Upgrade\x20@moss-js/moss-core\x20to\x20a\x20build\x20that\x20supports\x20custom\x20authenticators\x20for\x20sessions.','embedding','HTTP\x20error!\x20status:\x20','manifestSha256','listWebSources','json','configuredIdentity','Unsupported\x20job\x20status\x20\x27','path','cachePath','5889oECLKR','applySessionIdentity','toByteArray','authUrl','56MlwvPJ','delete','maxPages','respectRobots','moss-minilm','queryText','createIndexFromFiles\x20requires\x20at\x20least\x20one\x20file','test','resolveAuthRequest','normalizeJobStatus','PendingUpload','createIndexFromFiles','withAuthenticator','\x20could\x20not\x20be\x20settled:\x20','fetchAndCache','refreshCadence','\x20must\x20not\x20have\x20leading\x20or\x20trailing\x20whitespace','createIndex','excludePaths','applyIdentity','body','alpha','all','projectKey','deviceIdentity','call','currentPhase','MOSS_CLOUD_API_BASE_URL','_fromInner','getAuthHeader','expiresAt','no\x20exact\x20artifact\x20identity','pendingupload','https://service.usemoss.dev','addDocs\x20requires\x20at\x20least\x20one\x20document','application/json','then','modelId','byteLength','unloadIndex','authNotifyFn','authenticator','status','MossClient\x20is\x20closed','env','Unsupported\x20data\x20type\x20for\x20file\x20upload','progress','asyncDispose','Web\x20source\x20methods\x20require\x20a\x20project\x20key.\x20Construct\x20MossClient\x20with\x20(projectId,\x20projectKey).','sources','unloadIndexes','error','\x20UTF-8\x20bytes','requireMultiIndexCore','inflight','default','MOSS_AUTH_URL','@moss-js/moss-core\x20>=\x200.20.0\x20is\x20required\x20for\x20MossClient.close()','queryMultiIndexText','utf8','data','function','length','deleteDocs','resync','Failed','The\x20installed\x20@moss-js/moss-core\x20runtime\x20does\x20not\x20support\x20exact\x20model\x20artifact\x20identities.\x20Upgrade\x20moss-core\x20before\x20creating\x20this\x20session.','timeout','stringify','map','parse','minScore','mossDeviceId','getWebSource','\x20must\x20be\x20at\x20most\x20','bind','IndexManager','inner','[moss]\x20Dropping\x20a\x20malformed\x20job\x20progress\x20event;\x20progress\x20reporting\x20may\x20be\x20incomplete\x20for\x20this\x20operation.\x20Cause:\x20','ManageApiError','getDocs','Uploading','startsWith','deviceId','86PZaosg','now','arrayBuffer','cache','expiresIn','text','pending_upload','indexManager','393750gHCouw','moss-core\x20runtime\x20ManageClient/IndexManager\x20is\x20missing\x20withAuthenticator\x20factory.\x20Ensure\x20you\x20are\x20using\x20a\x20moss-core\x20build\x20that\x20supports\x20custom\x20authenticators.','addDocs','1577240cghewG','\x22)\x20or\x20loadIndexes([...])\x20before\x20querying;\x20queries\x20run\x20locally\x20and\x20there\x20is\x20no\x20cloud\x20query\x20fallback.','from','loadModel','identity','token','MossClient\x20options.identity.','pushIndex','replace','updateWebSource','query','ManageClient','maxDocuments','Authentication\x20failed\x20(HTTP\x20401):\x20','queryMultiIndex','SessionIndex','Bearer\x20','createIndex\x20requires\x20at\x20least\x20one\x20document','[moss]\x20Ignoring\x20an\x20auth\x20request\x20with\x20no\x20usable\x20request\x20id;\x20custom\x20authentication\x20may\x20be\x20unavailable\x20for\x20this\x20client.\x20Cause:\x20','HTTP\x20','maxDepth','isArray','manageClient','POST','received\x20','\x20Provide\x20a\x20query\x20vector\x20via\x20options.embedding,\x20or\x20use\x20alpha\x200\x20for\x20keyword-only\x20search.','createAuthenticatedSessionInner','loadIndex','_warmModel','loadFromDisk','loadIndexes','CLOUD_API_INDEX_URL','SDK_VERSION_NUMBER','contentType','hasCustomAuthenticator','modelArtifactContractVersion','Index\x20\x22','failed','MossClient\x20options.identity\x20must\x20be\x20an\x20object','toLowerCase','projectId','object','_create','trim','version','deleteDocuments','parseOptions','SessionIndex\x20\x27','moss-core\x20runtime\x20is\x20missing\x20ManageClient/IndexManager\x20exports','indexName','added','includePaths','1684746QCAjQK','This\x20session\x20uses\x20custom\x20embeddings.\x20Provide\x20a\x20query\x20embedding\x20via\x20QueryOptions.embedding.','message','topK','building','createAuthenticatedSessionInner\x20requires\x20a\x20custom\x20IAuthenticator\x20client','getAuthToken','queryMultiIndex\x20requires\x20at\x20least\x20one\x20index\x20name','[moss]\x20Auth\x20request\x20','name','custom','listIndexes','warn','addDocumentsText','jobId','includes','The\x20installed\x20@moss-js/moss-core\x20does\x20not\x20support\x20multi-index\x20operations\x20(queryMultiIndex,\x20loadIndexes,\x20unloadIndexes).\x20Upgrade\x20@moss-js/moss-core.','requires\x20explicit\x20query\x20embeddings','inspectSnapshot','moss-core\x20runtime\x20is\x20missing\x20resolveAuthRequest/rejectAuthRequest\x20exports.\x20Ensure\x20you\x20are\x20using\x20a\x20moss-core\x20build\x20that\x20supports\x20custom\x20authenticators.','updated','ensureCachePathDeviceId','deleteDocs\x20requires\x20at\x20least\x20one\x20document\x20ID','wrapProgress','Building','join','setIdentity','Documents\x20missing\x20.embedding\x20for\x20custom\x20model:\x20','uploading','2395638GCaZNE','onProgress','candidateDepth','deref','cachePathDeviceId','close','getIndex','fromEntries','One\x20or\x20more\x20indexes\x20use\x20custom\x20embeddings.\x20Provide\x20a\x20query\x20vector\x20via\x20options.embedding,\x20or\x20use\x20alpha\x200\x20for\x20keyword-only\x20search.','deleteIndex','getJobStatus','string','slice','number','docCount','filter','998187zeMKQN','completed','\x22\x20is\x20not\x20loaded.\x20Call\x20loadIndex(\x22','1615108mirvvS','Completed','isSafeInteger','createWebSource','.\x20All\x20documents\x20must\x20have\x20.embedding\x20set\x20when\x20using\x20modelId=\x27custom\x27.','isFinite','\x27\x20returned\x20by\x20moss-core','\x20must\x20be\x20a\x20non-empty\x20string','saveToDisk','/v1/manage','addDocuments','rejectAuthRequest'];_0x5865=function(){return _0xd31e47;};return _0x5865();}const _0x46a83d=_0xddff;(function(_0x5860ff,_0x3cceb5){const _0x3ef3b4=_0xddff,_0x51f83d=_0x5860ff();while(!![]){try{const _0x22f410=-parseInt(_0x3ef3b4(0x16f))/0x1+-parseInt(_0x3ef3b4(0x1e0))/0x2*(-parseInt(_0x3ef3b4(0x188))/0x3)+-parseInt(_0x3ef3b4(0x172))/0x4+-parseInt(_0x3ef3b4(0x1eb))/0x5+parseInt(_0x3ef3b4(0x1e8))/0x6+parseInt(_0x3ef3b4(0x142))/0x7+parseInt(_0x3ef3b4(0x18c))/0x8*(parseInt(_0x3ef3b4(0x15f))/0x9);if(_0x22f410===_0x3cceb5)break;else _0x51f83d['push'](_0x51f83d['shift']());}catch(_0x2c4ccb){_0x51f83d['push'](_0x51f83d['shift']());}}}(_0x5865,0x82ffe));import{JobStatus as _0x5a2181}from'@moss-js/moss-core';import*as _0x1f1a6f from'@moss-js/moss-core';import*as _0x171d58 from'@moss-js/moss-core';var g=_0x171d58,ae=g['MODEL_DOWNLOAD_URL'],ue=g[_0x46a83d(0x20b)],de=g['CLOUD_API_IDENTITY_URL'],T=g['CLOUD_API_AUTH_URL'],ce=typeof process<'u'&&process[_0x46a83d(0x1b8)]['MOSS_INDEX_URL']||g[_0x46a83d(0x20a)],E=typeof process<'u'?process['env']:{},f=class{constructor(_0x3efcc4,_0x3f0494){const _0x1434a1=_0x46a83d;this['projectId']=_0x3efcc4,this[_0x1434a1(0x1a3)]=_0x3f0494,this[_0x1434a1(0x18b)]=E[_0x1434a1(0x1c4)]??T;}[_0x46a83d(0x213)];[_0x46a83d(0x1a3)];['authUrl'];async[_0x46a83d(0x148)](){const _0x44b57b=_0x46a83d;let _0x18e3e7=await fetch(this[_0x44b57b(0x18b)],{'method':_0x44b57b(0x202),'headers':{'Content-Type':_0x44b57b(0x1af)},'body':JSON[_0x44b57b(0x1d0)]({'projectId':this[_0x44b57b(0x213)],'projectKey':this[_0x44b57b(0x1a3)]}),'signal':AbortSignal['timeout'](0x7530)});if(_0x18e3e7[_0x44b57b(0x1b6)]===0x191){let _0x3a8a36=await _0x18e3e7[_0x44b57b(0x1e5)]();throw new Error(_0x44b57b(0x1f8)+_0x3a8a36);}if(!_0x18e3e7['ok']){let _0x39097c=await _0x18e3e7[_0x44b57b(0x1e5)]();throw new Error(_0x44b57b(0x1fe)+_0x18e3e7[_0x44b57b(0x1b6)]+':\x20'+_0x39097c);}let _0x50dbc1=await _0x18e3e7[_0x44b57b(0x183)]();return{'token':_0x50dbc1[_0x44b57b(0x1f0)],'expiresIn':_0x50dbc1[_0x44b57b(0x1e4)]};}async[_0x46a83d(0x1a9)](){const _0x576801=_0x46a83d;let {token:_0x1b3176}=await this[_0x576801(0x148)]();return'Bearer\x20'+_0x1b3176;}},I=class{constructor(_0x5b376f){const _0x140337=_0x46a83d;this[_0x140337(0x1d9)]=_0x5b376f;}[_0x46a83d(0x1d9)];[_0x46a83d(0x1e3)]=null;[_0x46a83d(0x1c2)]=null;async[_0x46a83d(0x148)](){const _0x36ba65=_0x46a83d;if(this[_0x36ba65(0x1e3)]&&this[_0x36ba65(0x1e3)][_0x36ba65(0x1aa)]>Date[_0x36ba65(0x1e1)]())return{'token':this[_0x36ba65(0x1e3)][_0x36ba65(0x1f0)],'expiresIn':this[_0x36ba65(0x1e3)][_0x36ba65(0x1e4)]};if(this[_0x36ba65(0x1c2)])return this[_0x36ba65(0x1c2)];this['inflight']=this[_0x36ba65(0x19a)]();try{return await this[_0x36ba65(0x1c2)];}finally{this['inflight']=null;}}async[_0x46a83d(0x1a9)](){let {token:_0x388eb3}=await this['getAuthToken']();return'Bearer\x20'+_0x388eb3;}async[_0x46a83d(0x19a)](){const _0x21fc57=_0x46a83d;let {token:_0x3d4fbf,expiresIn:_0x3e2379}=await this['inner']['getAuthToken'](),_0xb882e1=Date[_0x21fc57(0x1e1)]()+(_0x3e2379-0x3c)*0x3e8;return this[_0x21fc57(0x1e3)]={'token':_0x3d4fbf,'expiresIn':_0x3e2379,'expiresAt':_0xb882e1},{'token':_0x3d4fbf,'expiresIn':_0x3e2379};}};import{randomUUID as _0x3b74d0}from'node:crypto';import{existsSync as _0x4d2da1,mkdirSync as _0x466ae4,readFileSync as _0x431bad,writeFileSync as _0x21360b}from'node:fs';import{join as _0x13aeed}from'node:path';var z='.moss-device-id',S=0x100,k=/[\p{Cc}\p{Cf}\p{Cs}\uFFFD]/u;function Y(_0x23d30a){const _0x121e7f=_0x46a83d;return _0x23d30a['length']>0x0&&_0x23d30a[_0x121e7f(0x216)]()===_0x23d30a&&!k[_0x121e7f(0x193)](_0x23d30a)&&new TextEncoder()['encode'](_0x23d30a)[_0x121e7f(0x1b2)]<=S;}function _(_0x30ba72,_0x2e8f88){const _0x43a7e8=_0x46a83d;if(_0x30ba72!==void 0x0){if(typeof _0x30ba72!=_0x43a7e8(0x16a)||_0x30ba72['length']===0x0)throw new TypeError(_0x43a7e8(0x1f1)+_0x2e8f88+_0x43a7e8(0x179));if(_0x30ba72['trim']()!==_0x30ba72)throw new TypeError(_0x43a7e8(0x1f1)+_0x2e8f88+_0x43a7e8(0x19c));if(k[_0x43a7e8(0x193)](_0x30ba72))throw new TypeError(_0x43a7e8(0x1f1)+_0x2e8f88+'\x20contains\x20an\x20unsupported\x20character');if(new TextEncoder()['encode'](_0x30ba72)[_0x43a7e8(0x1b2)]>S)throw new TypeError(_0x43a7e8(0x1f1)+_0x2e8f88+_0x43a7e8(0x1d6)+S+_0x43a7e8(0x1c0));return _0x30ba72;}}function U(_0x41a35f){const _0x79ef9b=_0x46a83d;if(_0x41a35f!==void 0x0){if(_0x41a35f===null||typeof _0x41a35f!=_0x79ef9b(0x214)||Array[_0x79ef9b(0x200)](_0x41a35f))throw new TypeError(_0x79ef9b(0x211));return Object['freeze']({'deviceId':_(_0x41a35f['deviceId'],_0x79ef9b(0x1df)),'userId':_(_0x41a35f['userId'],'userId')});}}function q(_0x16b90e){const _0x45f15b=_0x46a83d;return _0x16b90e?.[_0x45f15b(0x1df)]!==void 0x0||_0x16b90e?.['userId']!==void 0x0;}function M(_0x158771){const _0x4a81d7=_0x46a83d;if(!_0x158771?.['trim']())return;let _0xd037a6=_0x13aeed(_0x158771,z);try{if(_0x4d2da1(_0xd037a6)){let _0x58fe3b=_0x431bad(_0xd037a6,_0x4a81d7(0x1c7))[_0x4a81d7(0x216)]();return Y(_0x58fe3b)?_0x58fe3b:void 0x0;}_0x466ae4(_0x158771,{'recursive':!0x0});let _0x11b932=_0x3b74d0();return _0x21360b(_0xd037a6,_0x11b932,_0x4a81d7(0x1c7)),_0x11b932;}catch{return;}}var Z=0x1;function y(_0x2572bd){const _0x4762fb=_0x46a83d;let _0x41402d=_0x2572bd[_0x4762fb(0x20e)];if(typeof _0x41402d!=_0x4762fb(0x1c9))throw L();let _0x2aa4a9=_0x41402d[_0x4762fb(0x1a5)](_0x2572bd);if(!Number[_0x4762fb(0x174)](_0x2aa4a9)||_0x2aa4a9<Z)throw L();}function L(){const _0xa2981=_0x46a83d;return new Error(_0xa2981(0x1ce));}var xe=0x708*0x3e8;function x(_0x38b551){const _0x34afb3=_0x46a83d;if(!(_0x38b551?.['minScore']===void 0x0&&_0x38b551?.[_0x34afb3(0x161)]===void 0x0))return{'minScore':_0x38b551[_0x34afb3(0x1d3)],'candidateDepth':_0x38b551[_0x34afb3(0x161)]};}function A(_0x28596b){const _0x2e69b7=_0x46a83d;return _0x28596b instanceof Error?_0x28596b[_0x2e69b7(0x144)]:String(_0x28596b);}function _0xddff(_0x3b6774,_0x309031){_0x3b6774=_0x3b6774-0x141;const _0x586501=_0x5865();let _0xddff50=_0x586501[_0x3b6774];return _0xddff50;}function ee(_0x1f0cfd){const _0x2b2511=_0x46a83d;if(_0x1f0cfd===null||typeof _0x1f0cfd!=_0x2b2511(0x214))return _0x2b2511(0x203)+String(_0x1f0cfd);if(Array[_0x2b2511(0x200)](_0x1f0cfd))return'received\x20an\x20array\x20where\x20a\x20JobProgress\x20object\x20was\x20expected';let _0x11ff41=_0x1f0cfd;return typeof _0x11ff41['jobId']!=_0x2b2511(0x16a)||_0x11ff41['jobId'][_0x2b2511(0x1ca)]===0x0?'received\x20a\x20progress\x20event\x20with\x20a\x20missing\x20or\x20empty\x20jobId\x20('+String(_0x11ff41[_0x2b2511(0x150)])+')':typeof _0x11ff41[_0x2b2511(0x1b6)]!=_0x2b2511(0x16a)||_0x11ff41['status'][_0x2b2511(0x1ca)]===0x0?'received\x20a\x20progress\x20event\x20with\x20a\x20missing\x20or\x20empty\x20status\x20('+String(_0x11ff41[_0x2b2511(0x1b6)])+')':typeof _0x11ff41[_0x2b2511(0x1ba)]!=_0x2b2511(0x16c)||!Number[_0x2b2511(0x177)](_0x11ff41['progress'])?'received\x20a\x20progress\x20event\x20with\x20a\x20non-finite\x20progress\x20value\x20('+String(_0x11ff41[_0x2b2511(0x1ba)])+')':_0x11ff41['currentPhase']!==void 0x0&&_0x11ff41[_0x2b2511(0x1a6)]!==null&&typeof _0x11ff41[_0x2b2511(0x1a6)]!='string'?'received\x20a\x20progress\x20event\x20with\x20a\x20non-string\x20currentPhase\x20('+String(_0x11ff41[_0x2b2511(0x1a6)])+')':null;}var b=class{['authenticator'];[_0x46a83d(0x201)];[_0x46a83d(0x1e7)];[_0x46a83d(0x163)];[_0x46a83d(0x184)];['projectId'];[_0x46a83d(0x1b4)];constructor(_0xc4f53d,_0x146818,_0x7c846f){const _0x2ded6e=_0x46a83d;this['configuredIdentity']=U(_0x7c846f?.[_0x2ded6e(0x1ef)]),this[_0x2ded6e(0x163)]=M(_0x7c846f?.[_0x2ded6e(0x187)]),this[_0x2ded6e(0x213)]=_0xc4f53d;let _0x4b6942=typeof _0x146818==_0x2ded6e(0x16a)?new f(_0xc4f53d,_0x146818):_0x146818;this['authenticator']=new I(_0x4b6942);let _0x211416=_0x1f1a6f,_0x4900e3=_0x211416[_0x2ded6e(0x1f6)]??_0x211416['default']?.[_0x2ded6e(0x1f6)],_0x3946dd=_0x211416[_0x2ded6e(0x1d8)]??_0x211416[_0x2ded6e(0x1c3)]?.[_0x2ded6e(0x1d8)];if(!_0x4900e3||!_0x3946dd)throw new Error(_0x2ded6e(0x21b));if(typeof _0x146818=='string')this[_0x2ded6e(0x201)]=new _0x4900e3(_0xc4f53d,_0x146818),this[_0x2ded6e(0x1e7)]=new _0x3946dd(_0xc4f53d,_0x146818);else{let _0x3105de=_0x211416[_0x2ded6e(0x194)]??_0x211416[_0x2ded6e(0x1c3)]?.['resolveAuthRequest'],_0x5c8737=_0x211416[_0x2ded6e(0x17d)]??_0x211416['default']?.[_0x2ded6e(0x17d)];if(!_0x3105de||!_0x5c8737)throw new Error(_0x2ded6e(0x155));let _0x1e7dcc=this[_0x2ded6e(0x1b5)],_0x513eba=(_0x15652b,_0x245096)=>{const _0x40e859=_0x2ded6e;try{_0x5c8737(_0x15652b,_0x245096);}catch(_0x2661a0){console[_0x40e859(0x14e)](_0x40e859(0x14a)+_0x15652b+_0x40e859(0x199)+A(_0x2661a0));}},_0x59c2e3=(_0x324b04,_0x383566)=>{try{_0x3105de(_0x324b04,_0x383566);}catch(_0x4e1680){_0x513eba(_0x324b04,'moss-core\x20rejected\x20the\x20auth\x20token:\x20'+A(_0x4e1680));}},_0x157fc4=!0x1,_0x4f0511=(_0x4e79b1,_0x209bca)=>{const _0x4c4e05=_0x2ded6e;if(_0x4e79b1||!Number[_0x4c4e05(0x174)](_0x209bca)||_0x209bca<0x0){_0x157fc4||(_0x157fc4=!0x0,console[_0x4c4e05(0x14e)](_0x4c4e05(0x1fd)+(_0x4e79b1?_0x4e79b1[_0x4c4e05(0x144)]:_0x4c4e05(0x203)+String(_0x209bca))));return;}_0x1e7dcc[_0x4c4e05(0x1a9)]()[_0x4c4e05(0x1b0)](_0x4144fc=>{const _0x48e550=_0x4c4e05;let _0x5b4233=_0x4144fc[_0x48e550(0x1de)](_0x48e550(0x1fb))?_0x4144fc[_0x48e550(0x16b)](0x7):_0x4144fc;_0x59c2e3(_0x209bca,_0x5b4233);},_0x59f7b7=>_0x513eba(_0x209bca,A(_0x59f7b7)));};this[_0x2ded6e(0x1b4)]=_0x4f0511;let _0xa8ceab=_0x4900e3,_0x284f4f=_0x3946dd;if(!_0xa8ceab['withAuthenticator']||!_0x284f4f[_0x2ded6e(0x198)])throw new Error(_0x2ded6e(0x1e9));this[_0x2ded6e(0x201)]=_0xa8ceab[_0x2ded6e(0x198)](_0xc4f53d,_0x4f0511),this['indexManager']=_0x284f4f[_0x2ded6e(0x198)](_0xc4f53d,_0x4f0511);}this[_0x2ded6e(0x19f)](this[_0x2ded6e(0x1e7)]);}async[_0x46a83d(0x164)](){const _0x26a3d4=_0x46a83d;let _0x4a3bca=this[_0x26a3d4(0x1e7)]['close'];if(typeof _0x4a3bca!=_0x26a3d4(0x1c9))throw new Error(_0x26a3d4(0x1c5));await _0x4a3bca[_0x26a3d4(0x1a5)](this['indexManager']);}async[_0x46a83d(0x148)](){const _0x666c9a=_0x46a83d;return this[_0x666c9a(0x1b5)][_0x666c9a(0x148)]();}[_0x46a83d(0x159)](_0x4c6cdc){if(!_0x4c6cdc)return;let _0x1c2c34=!0x1;return(_0x5ea448,_0x403fc7)=>{const _0x33cf13=_0xddff;let _0x54841d=_0x5ea448?_0x5ea448[_0x33cf13(0x144)]:ee(_0x403fc7);if(_0x54841d!==null){_0x1c2c34||(_0x1c2c34=!0x0,console[_0x33cf13(0x14e)](_0x33cf13(0x1da)+_0x54841d));return;}_0x4c6cdc(_0x403fc7);};}[_0x46a83d(0x195)](_0x334470){const _0x155355=_0x46a83d;let _0x250f41=_0x334470[_0x155355(0x216)]()[_0x155355(0x212)]()['replace'](/\s+/g,'_'),_0x1a4222=_0x250f41[_0x155355(0x1f3)](/_/g,'');if(_0x250f41===_0x155355(0x1e6)||_0x1a4222===_0x155355(0x1ac))return _0x5a2181[_0x155355(0x196)];if(_0x250f41===_0x155355(0x15e))return _0x5a2181[_0x155355(0x1dd)];if(_0x250f41===_0x155355(0x146))return _0x5a2181[_0x155355(0x15a)];if(_0x250f41===_0x155355(0x170))return _0x5a2181[_0x155355(0x173)];if(_0x250f41===_0x155355(0x210))return _0x5a2181[_0x155355(0x1cd)];throw new Error(_0x155355(0x185)+_0x334470+_0x155355(0x178));}async['createIndex'](_0x5525a4,_0x2d4e21,_0x2c8344,_0x2aa729){const _0x312735=_0x46a83d;if(!_0x2d4e21[_0x312735(0x1ca)])throw new Error(_0x312735(0x1fc));return await this[_0x312735(0x201)][_0x312735(0x19d)](_0x5525a4,_0x2d4e21,_0x2c8344,this[_0x312735(0x159)](_0x2aa729?.[_0x312735(0x160)]));}async[_0x46a83d(0x18a)](_0x809009){const _0x20ede=_0x46a83d;if(_0x809009 instanceof Uint8Array)return Array['from'](_0x809009);if(_0x809009 instanceof ArrayBuffer)return Array[_0x20ede(0x1ed)](new Uint8Array(_0x809009));if(typeof _0x809009['arrayBuffer']==_0x20ede(0x1c9)){let _0x2f8424=await _0x809009[_0x20ede(0x1e2)]();return Array[_0x20ede(0x1ed)](new Uint8Array(_0x2f8424));}throw new Error(_0x20ede(0x1b9));}async[_0x46a83d(0x197)](_0x28bf73,_0x39acca,_0x429092){const _0x150454=_0x46a83d;if(_0x39acca[_0x150454(0x1ca)]===0x0)throw new Error(_0x150454(0x192));let _0x21e199=_0x429092?.[_0x150454(0x1b1)]??_0x150454(0x190),_0xd9adbe=await Promise[_0x150454(0x1a2)](_0x39acca[_0x150454(0x1d1)](async _0x50a7ec=>({'name':_0x50a7ec[_0x150454(0x14b)],'contentType':_0x50a7ec[_0x150454(0x20c)],'path':_0x50a7ec[_0x150454(0x186)]??void 0x0,'data':_0x50a7ec[_0x150454(0x1c8)]!=null?await this[_0x150454(0x18a)](_0x50a7ec[_0x150454(0x1c8)]):void 0x0})));return await this[_0x150454(0x201)][_0x150454(0x197)](_0x28bf73,_0xd9adbe,_0x21e199,this[_0x150454(0x159)](_0x429092?.[_0x150454(0x160)]),_0x429092?.[_0x150454(0x219)]??null);}async[_0x46a83d(0x1ea)](_0x447b2b,_0x362285,_0x4c3681){const _0xd8bc4f=_0x46a83d;if(Array[_0xd8bc4f(0x200)](_0x362285)&&_0x362285['length']===0x0)throw new Error(_0xd8bc4f(0x1ae));return await this['manageClient'][_0xd8bc4f(0x1ea)](_0x447b2b,_0x362285,_0x4c3681??null,this['wrapProgress'](_0x4c3681?.[_0xd8bc4f(0x160)]));}async[_0x46a83d(0x1cb)](_0x2c4133,_0x24cddb,_0x52bf73){const _0x4c8223=_0x46a83d;if(Array['isArray'](_0x24cddb)&&_0x24cddb[_0x4c8223(0x1ca)]===0x0)throw new Error(_0x4c8223(0x158));return await this[_0x4c8223(0x201)][_0x4c8223(0x1cb)](_0x2c4133,_0x24cddb,this[_0x4c8223(0x159)](_0x52bf73?.[_0x4c8223(0x160)]));}async[_0x46a83d(0x169)](_0x54147f){const _0x1bed93=_0x46a83d;let _0xe6b5fa=await this[_0x1bed93(0x201)][_0x1bed93(0x169)](_0x54147f);return{..._0xe6b5fa,'status':this['normalizeJobStatus'](_0xe6b5fa[_0x1bed93(0x1b6)]),'currentPhase':_0xe6b5fa[_0x1bed93(0x1a6)]??null,'error':_0xe6b5fa[_0x1bed93(0x1bf)]??null};}async['getIndex'](_0x23ba4c){const _0x3bf8fe=_0x46a83d;return this[_0x3bf8fe(0x201)][_0x3bf8fe(0x165)](_0x23ba4c);}async['listIndexes'](){const _0x1fbd1e=_0x46a83d;return this[_0x1fbd1e(0x201)][_0x1fbd1e(0x14d)]();}async[_0x46a83d(0x168)](_0x45f973){const _0x235f98=_0x46a83d;return this[_0x235f98(0x201)][_0x235f98(0x168)](_0x45f973);}async[_0x46a83d(0x1dc)](_0x30c64a,_0x200233){const _0x1ef1a4=_0x46a83d;return this[_0x1ef1a4(0x201)]['getDocs'](_0x30c64a,_0x200233??null);}async['loadIndex'](_0x2904f3,_0x1c232a){const _0x30642f=_0x46a83d;return this[_0x30642f(0x157)](_0x1c232a?.[_0x30642f(0x187)]),(await this[_0x30642f(0x1e7)][_0x30642f(0x206)](_0x2904f3,_0x1c232a??null))[_0x30642f(0x14b)];}async['loadIndexes'](_0x5862b1,_0x363f59){const _0x4fc802=_0x46a83d;let _0xc88f04=this[_0x4fc802(0x1c1)]();return this[_0x4fc802(0x157)](_0x363f59?.[_0x4fc802(0x187)]),_0xc88f04[_0x4fc802(0x209)](_0x5862b1,_0x363f59??null);}async[_0x46a83d(0x1b3)](_0x2bd1e6){const _0x50af75=_0x46a83d;return this['indexManager'][_0x50af75(0x1b3)](_0x2bd1e6);}async['unloadIndexes'](_0x9f1cfe){const _0xd6c23=_0x46a83d;return this[_0xd6c23(0x1c1)]()[_0xd6c23(0x1be)](_0x9f1cfe);}[_0x46a83d(0x1c1)](){const _0x48e9fe=_0x46a83d;let _0x2d3692=this['indexManager'];if(typeof _0x2d3692['queryMultiIndex']!='function'||typeof _0x2d3692['queryMultiIndexText']!=_0x48e9fe(0x1c9)||typeof _0x2d3692[_0x48e9fe(0x209)]!=_0x48e9fe(0x1c9)||typeof _0x2d3692['unloadIndexes']!=_0x48e9fe(0x1c9))throw new Error(_0x48e9fe(0x152));return{'queryMultiIndex':_0x2d3692[_0x48e9fe(0x1f9)][_0x48e9fe(0x1d7)](_0x2d3692),'queryMultiIndexText':_0x2d3692['queryMultiIndexText'][_0x48e9fe(0x1d7)](_0x2d3692),'loadIndexes':_0x2d3692['loadIndexes'][_0x48e9fe(0x1d7)](_0x2d3692),'unloadIndexes':_0x2d3692['unloadIndexes']['bind'](_0x2d3692)};}['ensureCachePathDeviceId'](_0x27ac17){const _0x5e1bb0=_0x46a83d;_0x27ac17&&this[_0x5e1bb0(0x163)]===void 0x0&&M(_0x27ac17);}[_0x46a83d(0x19f)]=_0x565d4f=>{const _0x2ba277=_0x46a83d;!q(this['configuredIdentity'])&&this[_0x2ba277(0x163)]===void 0x0||_0x565d4f[_0x2ba277(0x15c)](this[_0x2ba277(0x184)]?.[_0x2ba277(0x1df)]??null,this['configuredIdentity']?.['userId']??null,this[_0x2ba277(0x163)]??null);};[_0x46a83d(0x189)]=_0x31bbba=>{const _0x74fa4a=_0x46a83d;let _0x264ac3=this['indexManager'][_0x74fa4a(0x1a4)]?.();if(!_0x264ac3){this['applyIdentity'](_0x31bbba);return;}_0x31bbba[_0x74fa4a(0x15c)](_0x264ac3[_0x74fa4a(0x1df)]??null,this[_0x74fa4a(0x184)]?.['userId']??null,_0x264ac3[_0x74fa4a(0x1d4)]??null);};[_0x46a83d(0x20d)](){return this['authNotifyFn']!==void 0x0;}async[_0x46a83d(0x205)](_0x57e657,_0x2ca807,_0xe56b50){const _0xa432b4=_0x46a83d;if(!this[_0xa432b4(0x1b4)])throw new Error(_0xa432b4(0x147));let _0x5dc09b=_0x1f1a6f,_0x15a459=_0x5dc09b[_0xa432b4(0x1fa)]??_0x5dc09b[_0xa432b4(0x1c3)]?.[_0xa432b4(0x1fa)];if(!_0x15a459||typeof _0x15a459[_0xa432b4(0x198)]!=_0xa432b4(0x1c9))throw new Error(_0xa432b4(0x17e));return _0xe56b50&&y(_0x15a459),_0x15a459[_0xa432b4(0x198)](_0x57e657,_0x2ca807,this[_0xa432b4(0x213)],this['authNotifyFn'],null,null,_0xe56b50?.[_0xa432b4(0x217)]??null,_0xe56b50?.[_0xa432b4(0x181)]??null);}async[_0x46a83d(0x1f5)](_0x34c29e,_0x30e043,_0x11b5a8){const _0x599233=_0x46a83d;if(!await this[_0x599233(0x1e7)]['hasIndex'](_0x34c29e))throw new Error(_0x599233(0x20f)+_0x34c29e+_0x599233(0x171)+_0x34c29e+_0x599233(0x1ec));let _0x12406f=_0x11b5a8?.[_0x599233(0x145)]??0x5,_0x3d6ca7=_0x11b5a8?.[_0x599233(0x1a1)]??0.8;return _0x11b5a8?.[_0x599233(0x17f)]?this[_0x599233(0x1e7)][_0x599233(0x1f5)](_0x34c29e,_0x30e043,_0x11b5a8['embedding'],_0x12406f,_0x3d6ca7,_0x11b5a8?.[_0x599233(0x16e)],x(_0x11b5a8)):this['indexManager']['queryText'](_0x34c29e,_0x30e043,_0x12406f,_0x3d6ca7,_0x11b5a8?.[_0x599233(0x16e)],x(_0x11b5a8));}async[_0x46a83d(0x1f9)](_0x59e202,_0x356645,_0x5cd60b){const _0xf5a7be=_0x46a83d;if(_0x59e202[_0xf5a7be(0x1ca)]===0x0)throw new Error(_0xf5a7be(0x149));let _0x3f1e23=this[_0xf5a7be(0x1c1)](),_0x56a85d=_0x5cd60b?.['topK']??0xa,_0x2c17ec=_0x5cd60b?.[_0xf5a7be(0x1a1)]??0.8;if(_0x5cd60b?.['embedding'])return _0x3f1e23[_0xf5a7be(0x1f9)](_0x59e202,_0x356645,_0x5cd60b[_0xf5a7be(0x17f)],_0x56a85d,_0x2c17ec,_0x5cd60b?.[_0xf5a7be(0x16e)],x(_0x5cd60b));try{return await _0x3f1e23[_0xf5a7be(0x1c6)](_0x59e202,_0x356645,_0x56a85d,_0x2c17ec,_0x5cd60b?.['filter'],x(_0x5cd60b));}catch(_0x314c60){throw _0x314c60 instanceof Error&&_0x314c60['message'][_0xf5a7be(0x151)](_0xf5a7be(0x1ab))?new Error(_0x314c60[_0xf5a7be(0x144)]+_0xf5a7be(0x204),{'cause':_0x314c60}):_0x314c60 instanceof Error&&_0x314c60[_0xf5a7be(0x144)][_0xf5a7be(0x151)](_0xf5a7be(0x153))?new Error(_0xf5a7be(0x167),{'cause':_0x314c60}):_0x314c60;}}};import{SessionIndex as _0x299e9a}from'@moss-js/moss-core';var h=class r{#e;#r;#s;#i=!0x1;#a;constructor(_0xfd2256,_0x2af824,_0x27bbc3){this.#s=_0xfd2256,this.#r=_0x2af824,this.#e=_0x27bbc3;}static async['_create'](_0x2139f2,_0x4aaf78,_0x15ccd3,_0x4150bf,_0x235906,_0x8e8fc,_0x22af73){const _0x254cc8=_0x46a83d;let _0x313c28=_0x299e9a;_0x22af73&&y(_0x313c28);let _0x10a7bb=await _0x313c28['create'](_0x2139f2,_0x4aaf78,_0x15ccd3,_0x4150bf,_0x235906??null,_0x22af73?.[_0x254cc8(0x217)]??null,_0x22af73?.[_0x254cc8(0x181)]??null);return r[_0x254cc8(0x1a8)](_0x2139f2,_0x4aaf78,_0x10a7bb,_0x8e8fc);}static[_0x46a83d(0x1a8)](_0x3be776,_0x44a783,_0x291790,_0x148c3e){return _0x148c3e?.(_0x291790),new r(_0x3be776,_0x44a783,_0x291790);}get['name'](){return this.#s;}get[_0x46a83d(0x16d)](){const _0x1c39b0=_0x46a83d;return this.#n(),this.#e[_0x1c39b0(0x16d)];}get[_0x46a83d(0x1b1)](){return this.#r;}async['addDocs'](_0x326fe4,_0x3c15c9){const _0x21cb4a=_0x46a83d;this.#n();let _0x1fb7e5=_0x3c15c9?{'upsert':_0x3c15c9['upsert']??!0x0}:void 0x0;if(this.#r==='custom'){let _0x13c36e=r.#t(_0x326fe4),_0x573f91=_0x326fe4['map'](_0x10c08f=>{const _0x2776fd=_0xddff;let _0x25ae62={..._0x10c08f};return delete _0x25ae62[_0x2776fd(0x17f)],_0x25ae62;}),_0x5462bf=await this.#e[_0x21cb4a(0x17c)](_0x573f91,_0x13c36e,_0x1fb7e5);return{'added':_0x5462bf[_0x21cb4a(0x21d)],'updated':_0x5462bf[_0x21cb4a(0x156)]};}let _0x36a41d=await this.#e[_0x21cb4a(0x14f)](_0x326fe4,_0x1fb7e5);return{'added':_0x36a41d[_0x21cb4a(0x21d)],'updated':_0x36a41d['updated']};}async['deleteDocs'](_0x5d72a6){const _0x2d5539=_0x46a83d;return this.#n(),await this.#e[_0x2d5539(0x218)](_0x5d72a6);}async[_0x46a83d(0x1dc)](_0x7a303c){return this.#n(),await this.#e['getDocuments'](_0x7a303c??null);}async['query'](_0x45989c,_0x420ea1){const _0x5f2fc9=_0x46a83d;this.#n();let _0x34ed1f=_0x420ea1?.[_0x5f2fc9(0x145)]??0x5,_0x55f937=_0x420ea1?.[_0x5f2fc9(0x1a1)]??0.8,_0x67bbb7=_0x420ea1?.[_0x5f2fc9(0x16e)]??null,_0x4a3e3a=_0x420ea1?.[_0x5f2fc9(0x17f)];if(_0x4a3e3a==null){if(this.#r===_0x5f2fc9(0x14c))throw new Error(_0x5f2fc9(0x143));return await this.#e[_0x5f2fc9(0x191)](_0x45989c,_0x34ed1f,_0x55f937,_0x67bbb7);}return await this.#e[_0x5f2fc9(0x1f5)](_0x45989c,_0x34ed1f,Array[_0x5f2fc9(0x1ed)](_0x4a3e3a),_0x55f937,_0x67bbb7);}async[_0x46a83d(0x206)](_0x41b2c2,_0x3258a7){const _0x4d16a9=_0x46a83d;return this.#n(),this.#e[_0x4d16a9(0x206)](_0x41b2c2,_0x3258a7??null);}async[_0x46a83d(0x1f2)](){const _0x745f16=_0x46a83d;return this.#n(),this.#e[_0x745f16(0x1f2)]();}async[_0x46a83d(0x17a)](_0x2c5ddf){const _0x2666a9=_0x46a83d;this.#n(),await this.#e[_0x2666a9(0x17a)](_0x2c5ddf);}async[_0x46a83d(0x208)](_0x3e2c76,_0x2fbbcf){const _0xa54195=_0x46a83d;this.#n();let _0x2ad015=_0x2fbbcf?.['rebuildLegacy']??!0x0;return await this.#e[_0xa54195(0x208)](_0x3e2c76,{'rebuildLegacy':_0x2ad015});}async[_0x46a83d(0x154)](_0x424a8f){const _0x255492=_0x46a83d;return this.#n(),await this.#e[_0x255492(0x154)](_0x424a8f);}#n(){const _0x39f651=_0x46a83d;if(this.#i)throw new Error(_0x39f651(0x21a)+this.#s+'\x27\x20is\x20closed');}[_0x46a83d(0x164)](){return this.#a??=this.#o(),this.#a;}async #o(){const _0x4822ad=_0x46a83d;this.#i=!0x0;let _0x3f1d05=this.#e[_0x4822ad(0x164)];if(typeof _0x3f1d05!=_0x4822ad(0x1c9))throw new Error('@moss-js/moss-core\x20>=\x200.20.0\x20is\x20required\x20for\x20SessionIndex.close()');await _0x3f1d05['call'](this.#e);}async[Symbol[_0x46a83d(0x1bb)]](){const _0x34f63d=_0x46a83d;return this[_0x34f63d(0x164)]();}async[_0x46a83d(0x207)](){const _0x40364e=_0x46a83d;this.#n(),this.#r!==_0x40364e(0x14c)&&await this.#e[_0x40364e(0x1ee)]();}static#t(_0x562664){const _0x4dc0c2=_0x46a83d;let _0x55c213=_0x562664[_0x4dc0c2(0x16e)](_0xc35080=>!_0xc35080['embedding']||_0xc35080[_0x4dc0c2(0x17f)][_0x4dc0c2(0x1ca)]===0x0)[_0x4dc0c2(0x1d1)](_0x582d4b=>_0x582d4b['id']);if(_0x55c213[_0x4dc0c2(0x1ca)]>0x0)throw new Error(_0x4dc0c2(0x15d)+_0x55c213[_0x4dc0c2(0x15b)](',\x20')+_0x4dc0c2(0x176));return _0x562664[_0x4dc0c2(0x1d1)](_0x587fee=>Array['from'](_0x587fee[_0x4dc0c2(0x17f)]??[]));}};import{validateIndexName as _0x13890c}from'@moss-js/moss-core';var ne=_0x46a83d(0x1ad),re=_0x46a83d(0x17b),w=class extends Error{[_0x46a83d(0x1b6)];[_0x46a83d(0x1a0)];constructor(_0x324ea7,_0x502cba){const _0x516f7f=_0x46a83d;let _0x260b5=_0x502cba?':\x20'+_0x502cba:'';super(_0x516f7f(0x180)+_0x324ea7+_0x260b5),this['name']=_0x516f7f(0x1db),this[_0x516f7f(0x1b6)]=_0x324ea7,this[_0x516f7f(0x1a0)]=_0x502cba;}};function se(){const _0x19e1a2=_0x46a83d;return''+(typeof process<'u'&&process['env'][_0x19e1a2(0x1a7)]||ne)[_0x19e1a2(0x1f3)](/\/+$/,'')+re;}function oe(_0x3617a1){const _0x4115c2=_0x46a83d;return _0x3617a1?Object[_0x4115c2(0x166)](Object['entries'](_0x3617a1)[_0x4115c2(0x16e)](([,_0x5baf99])=>_0x5baf99!==void 0x0)):{};}async function F(_0x2a06cd,_0x344c19,_0x282889,_0x56e674){const _0x2eb82c=_0x46a83d;let _0x3a0c4a={...oe(_0x56e674),'action':_0x282889,'projectId':_0x2a06cd},_0x519d2f=await fetch(se(),{'method':_0x2eb82c(0x202),'headers':{'Content-Type':'application/json','X-Project-Key':_0x344c19},'body':JSON[_0x2eb82c(0x1d0)](_0x3a0c4a),'signal':AbortSignal[_0x2eb82c(0x1cf)](0x927c0)}),_0x4b4cf5=await _0x519d2f[_0x2eb82c(0x1e5)]();if(!_0x519d2f['ok'])throw new w(_0x519d2f[_0x2eb82c(0x1b6)],_0x4b4cf5);return _0x4b4cf5?JSON[_0x2eb82c(0x1d2)](_0x4b4cf5):{};}var W=_0x46a83d(0x190),D=class{#e;#r;#s;#i=!0x1;#a;#n=new Set();constructor(_0x2a3c28,_0xd00f39,_0x3a710){const _0x4fd41d=_0x46a83d;this.#e=new b(_0x2a3c28,_0xd00f39,_0x3a710),this.#r=_0x2a3c28,this.#s=typeof _0xd00f39==_0x4fd41d(0x16a)?_0xd00f39:null;}async['getAuthToken'](){const _0x18d89a=_0x46a83d;return this.#t(),this.#e[_0x18d89a(0x148)]();}async[_0x46a83d(0x19d)](_0x19aae9,_0x5bd27f,_0x350e87){const _0x42f074=_0x46a83d;this.#t();let _0x587134;return _0x350e87?.[_0x42f074(0x1b1)]!==void 0x0?_0x587134=_0x350e87[_0x42f074(0x1b1)]:_0x587134=_0x5bd27f['some'](_0x3f8aa7=>Array['isArray'](_0x3f8aa7[_0x42f074(0x17f)])&&_0x3f8aa7[_0x42f074(0x17f)][_0x42f074(0x1ca)]>0x0)?_0x42f074(0x14c):W,this.#e['createIndex'](_0x19aae9,_0x5bd27f,_0x587134,_0x350e87);}async[_0x46a83d(0x197)](_0x4079d9,_0x1f689c,_0x4bd39f){const _0x4ea5f4=_0x46a83d;return this.#t(),this.#e[_0x4ea5f4(0x197)](_0x4079d9,_0x1f689c,_0x4bd39f);}async[_0x46a83d(0x165)](_0x1d4f18){const _0x132bed=_0x46a83d;return this.#t(),this.#e[_0x132bed(0x165)](_0x1d4f18);}async['listIndexes'](){const _0x221b9d=_0x46a83d;return this.#t(),this.#e[_0x221b9d(0x14d)]();}async['deleteIndex'](_0x275d56){const _0x4c121e=_0x46a83d;return this.#t(),this.#e[_0x4c121e(0x168)](_0x275d56);}async[_0x46a83d(0x1ea)](_0x1e06b9,_0x1d0ef7,_0x1c2ac4){const _0x16ac2d=_0x46a83d;return this.#t(),this.#e[_0x16ac2d(0x1ea)](_0x1e06b9,_0x1d0ef7,_0x1c2ac4);}async[_0x46a83d(0x1cb)](_0xa24c13,_0x40bf7b,_0x4bdc26){return this.#t(),this.#e['deleteDocs'](_0xa24c13,_0x40bf7b,_0x4bdc26);}async['getJobStatus'](_0x4074bb){const _0x175c02=_0x46a83d;return this.#t(),this.#e[_0x175c02(0x169)](_0x4074bb);}async['createWebSource'](_0x5bddc9,_0x1af71f,_0x18a2db){const _0x3b32d1=_0x46a83d;return this.#t(),_0x13890c(_0x1af71f),this.#o(_0x3b32d1(0x175),{'rootUrl':_0x5bddc9,'indexName':_0x1af71f,'maxPages':_0x18a2db?.[_0x3b32d1(0x18e)],'maxDocuments':_0x18a2db?.[_0x3b32d1(0x1f7)],'maxDepth':_0x18a2db?.[_0x3b32d1(0x1ff)],'includePaths':_0x18a2db?.[_0x3b32d1(0x141)],'excludePaths':_0x18a2db?.[_0x3b32d1(0x19e)],'respectRobots':_0x18a2db?.[_0x3b32d1(0x18f)],'parseDocuments':_0x18a2db?.['parseDocuments'],'refreshCadence':_0x18a2db?.[_0x3b32d1(0x19b)],'modelId':_0x18a2db?.[_0x3b32d1(0x1b1)]});}async['listWebSources'](_0x3d12a8){const _0xd5d590=_0x46a83d;this.#t();let _0x24e645=(await this.#o(_0xd5d590(0x182),_0x3d12a8!==void 0x0?{'indexName':_0x3d12a8}:void 0x0))[_0xd5d590(0x1bd)]??[];return _0x3d12a8===void 0x0?_0x24e645:_0x24e645[_0xd5d590(0x16e)](_0x231aa5=>_0x231aa5[_0xd5d590(0x21c)]===_0x3d12a8);}async[_0x46a83d(0x1d5)](_0x8f33ef){const _0x3bd6b3=_0x46a83d;return this.#t(),this.#o(_0x3bd6b3(0x1d5),{'sourceId':_0x8f33ef});}async[_0x46a83d(0x1f4)](_0x224463,_0x56d1b3){const _0x527b47=_0x46a83d;return this.#t(),this.#o(_0x527b47(0x1f4),{'sourceId':_0x224463,'refreshCadence':_0x56d1b3[_0x527b47(0x19b)],'rootUrl':_0x56d1b3['rootUrl'],'includePaths':_0x56d1b3['includePaths'],'excludePaths':_0x56d1b3[_0x527b47(0x19e)],'maxDepth':_0x56d1b3['maxDepth'],'maxPages':_0x56d1b3[_0x527b47(0x18e)],'resync':_0x56d1b3[_0x527b47(0x1cc)]});}async['resyncWebSource'](_0x55704){return this.#t(),this.#o('resyncWebSource',{'sourceId':_0x55704});}async['deleteWebSource'](_0x5d0322){return this.#t(),this.#o('deleteWebSource',{'sourceId':_0x5d0322});}async #o(_0x726aa7,_0x470e77){const _0x5dfa0c=_0x46a83d;if(this.#s===null)throw new Error(_0x5dfa0c(0x1bc));return F(this.#r,this.#s,_0x726aa7,_0x470e77);}async[_0x46a83d(0x1dc)](_0x1b80a2,_0x463868){const _0x7f31f7=_0x46a83d;return this.#t(),this.#e[_0x7f31f7(0x1dc)](_0x1b80a2,_0x463868);}async['loadIndex'](_0x31ca1c,_0x2b0d87){const _0x37298d=_0x46a83d;return this.#t(),this.#e[_0x37298d(0x206)](_0x31ca1c,_0x2b0d87);}async[_0x46a83d(0x209)](_0x3c174e,_0x1d7fbb){return this.#t(),this.#e['loadIndexes'](_0x3c174e,_0x1d7fbb);}async[_0x46a83d(0x1b3)](_0x3d6a17){const _0xcfd40=_0x46a83d;return this.#t(),this.#e[_0xcfd40(0x1b3)](_0x3d6a17);}async[_0x46a83d(0x1be)](_0x5d7b0d){return this.#t(),this.#e['unloadIndexes'](_0x5d7b0d);}async[_0x46a83d(0x1f5)](_0x496673,_0x33787a,_0x75a08f){return this.#t(),this.#e['query'](_0x496673,_0x33787a,_0x75a08f);}async[_0x46a83d(0x1f9)](_0x2d9d88,_0x29be49,_0x150e42){const _0x4cc838=_0x46a83d;return this.#t(),this.#e[_0x4cc838(0x1f9)](_0x2d9d88,_0x29be49,_0x150e42);}async['session'](_0x39dff9,_0x64c489=W,_0x8f92c7){const _0x21828c=_0x46a83d;this.#t();let _0x37c616=this.#e[_0x21828c(0x189)],_0xe6f658;if(this.#s!==null)_0xe6f658=await h[_0x21828c(0x215)](_0x39dff9,_0x64c489,this.#r,this.#s,void 0x0,_0x37c616,_0x8f92c7);else{let _0x5180c2=await this.#e[_0x21828c(0x205)](_0x39dff9,_0x64c489,_0x8f92c7);_0xe6f658=h[_0x21828c(0x1a8)](_0x39dff9,_0x64c489,_0x5180c2,_0x37c616);}await _0xe6f658['_warmModel']();for(let _0x467fe5 of this.#n)_0x467fe5['deref']()||this.#n[_0x21828c(0x18d)](_0x467fe5);return this.#n['add'](new WeakRef(_0xe6f658)),_0xe6f658;}#t(){const _0x57f93b=_0x46a83d;if(this.#i)throw new Error(_0x57f93b(0x1b7));}[_0x46a83d(0x164)](){return this.#a??=this.#u(),this.#a;}async #u(){const _0x348359=_0x46a83d;this.#i=!0x0;let _0x5f3da7=[...this.#n][_0x348359(0x1d1)](_0x51bad0=>_0x51bad0[_0x348359(0x162)]())['filter'](_0x44f62a=>_0x44f62a!==void 0x0);this.#n['clear'](),await Promise['all'](_0x5f3da7['map'](_0x57272b=>_0x57272b['close']())),await this.#e[_0x348359(0x164)]();}async[Symbol[_0x46a83d(0x1bb)]](){const _0x30010d=_0x46a83d;return this[_0x30010d(0x164)]();}};export{w as ManageApiError,D as MossClient,h as SessionIndex};
|
package/dist/moss.d.ts
CHANGED
|
@@ -146,6 +146,7 @@ export declare interface LoadIndexOptions {
|
|
|
146
146
|
autoRefresh?: boolean;
|
|
147
147
|
/**
|
|
148
148
|
* Polling interval in seconds. Only used when autoRefresh is true.
|
|
149
|
+
* 0 uses the default, and the minimum is 1 second.
|
|
149
150
|
* @default 600 (10 minutes)
|
|
150
151
|
*/
|
|
151
152
|
pollingIntervalInSeconds?: number;
|
|
@@ -524,9 +525,15 @@ export declare class MossClient {
|
|
|
524
525
|
* Moss can generate query embeddings locally. For an older identity-less
|
|
525
526
|
* index, provide a caller-generated vector through `options.embedding`.
|
|
526
527
|
*
|
|
528
|
+
* A blank `query` (empty or only whitespace) with no `options.embedding`
|
|
529
|
+
* returns no results at every `alpha`, without running the embedding model.
|
|
530
|
+
* With an embedding, a blank `query` ranks by the embedding alone. An
|
|
531
|
+
* embedding holding NaN or infinity, or one whose length differs from the
|
|
532
|
+
* index dimension, rejects at every `alpha`.
|
|
533
|
+
*
|
|
527
534
|
* @param indexName - Name of the target index to search.
|
|
528
535
|
* @param query - The search query text.
|
|
529
|
-
* @param options - Optional query configuration including topK (default: 5)
|
|
536
|
+
* @param options - Optional query configuration including topK (default: 5; 0 returns no results), embedding overrides, minScore, and candidateDepth.
|
|
530
537
|
* @returns Promise that resolves to SearchResult with matching documents.
|
|
531
538
|
* @throws {Error} If the index is not loaded.
|
|
532
539
|
*
|
|
@@ -546,16 +553,18 @@ export declare class MossClient {
|
|
|
546
553
|
*
|
|
547
554
|
* All names must already be loaded (`loadIndex` / `loadIndexes`) and share
|
|
548
555
|
* the same embedding model; there is no cloud fallback. `options.alpha`
|
|
549
|
-
* works exactly as in `query` (default 0.8): `1.0` is embedding-only
|
|
550
|
-
*
|
|
551
|
-
*
|
|
552
|
-
*
|
|
553
|
-
*
|
|
554
|
-
*
|
|
556
|
+
* works exactly as in `query` (default 0.8): `1.0` is embedding-only, `0.0`
|
|
557
|
+
* is keyword-only, and values in between fuse both signals. Every mix returns
|
|
558
|
+
* results in hybrid order with the same relevance `score` as single-index
|
|
559
|
+
* `query`, and `options.minScore` filters on that score. Keyword scoring
|
|
560
|
+
* runs each index's own BM25 and merges hits before fusion. `options.topK`
|
|
561
|
+
* (default 10) caps the merged result, not each index, and 0 returns no
|
|
562
|
+
* results. `options.filter` applies uniformly to every index. A blank
|
|
563
|
+
* `query` with no `options.embedding` returns no results and embeds nothing.
|
|
555
564
|
*
|
|
556
565
|
* @param indexNames - Names of the loaded indexes to search.
|
|
557
566
|
* @param query - The search query text.
|
|
558
|
-
* @param options - Optional topK, alpha, embedding, and
|
|
567
|
+
* @param options - Optional topK, alpha, embedding, filter, minScore, and candidateDepth.
|
|
559
568
|
* @returns SearchResult whose docs carry `indexName`.
|
|
560
569
|
* @throws {Error} If no names are given, a name is not loaded, or models differ.
|
|
561
570
|
*
|
|
@@ -659,9 +668,9 @@ export declare type MossModel = "moss-minilm" | "moss-mediumlm" | "custom";
|
|
|
659
668
|
*/
|
|
660
669
|
export declare interface MutationOptions {
|
|
661
670
|
/**
|
|
662
|
-
* Whether
|
|
663
|
-
*
|
|
664
|
-
*
|
|
671
|
+
* Whether a document replaces a stored one with the same ID.
|
|
672
|
+
* `SessionIndex.addDocs` applies it locally and treats an omitted value as `true`.
|
|
673
|
+
* `MossClient.addDocs` sends it only when set, and the cloud service decides how to apply it.
|
|
665
674
|
*/
|
|
666
675
|
upsert?: boolean;
|
|
667
676
|
/**
|
|
@@ -820,6 +829,12 @@ export declare class SessionIndex {
|
|
|
820
829
|
* For `modelId="custom"`, an explicit `options.embedding` is required.
|
|
821
830
|
* For built-in models the query is embedded locally by the Rust core
|
|
822
831
|
* on a native worker thread if `options.embedding` is omitted.
|
|
832
|
+
*
|
|
833
|
+
* A blank `query` (empty or only whitespace) with no `options.embedding`
|
|
834
|
+
* returns no results at every `alpha`, without running the embedding model.
|
|
835
|
+
* With an embedding, a blank `query` ranks by the embedding alone.
|
|
836
|
+
* A custom-model session still needs `options.embedding`.
|
|
837
|
+
* `options.topK` defaults to 5, and 0 returns no results.
|
|
823
838
|
*/
|
|
824
839
|
query(query: string, options?: QueryOptions): Promise<SearchResult>;
|
|
825
840
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moss-js/moss",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.0",
|
|
4
4
|
"main": "dist/index.esm.js",
|
|
5
5
|
"module": "dist/index.esm.js",
|
|
6
6
|
"types": "dist/moss.d.ts",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"author": "InferEdge Inc.",
|
|
46
46
|
"license": "SEE LICENSE IN LICENSE",
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@moss-js/moss-core": "0.
|
|
48
|
+
"@moss-js/moss-core": "0.30.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@eslint/js": "^9.39.4",
|