@moss-js/moss 1.14.0 → 1.16.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
@@ -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
+ const _0xb7ded2=_0xf7dd;(function(_0x346014,_0x35f986){const _0x4faaaf=_0xf7dd,_0x151dd3=_0x346014();while(!![]){try{const _0x2627a1=-parseInt(_0x4faaaf(0x16f))/0x1+-parseInt(_0x4faaaf(0x1d8))/0x2*(-parseInt(_0x4faaaf(0x17b))/0x3)+-parseInt(_0x4faaaf(0x18b))/0x4+parseInt(_0x4faaaf(0x1ae))/0x5+-parseInt(_0x4faaaf(0x18c))/0x6+parseInt(_0x4faaaf(0x196))/0x7+parseInt(_0x4faaaf(0x214))/0x8*(parseInt(_0x4faaaf(0x1f4))/0x9);if(_0x2627a1===_0x35f986)break;else _0x151dd3['push'](_0x151dd3['shift']());}catch(_0x2e7c15){_0x151dd3['push'](_0x151dd3['shift']());}}}(_0x4484,0x51fc6));import{JobStatus as _0x5f4ea8}from'@moss-js/moss-core';import*as _0x5e12ee from'@moss-js/moss-core';import*as _0x36bb09 from'@moss-js/moss-core';var g=_0x36bb09,le=g[_0xb7ded2(0x1f1)],me=g[_0xb7ded2(0x1ee)],he=g[_0xb7ded2(0x1af)],T=g[_0xb7ded2(0x205)],ge=typeof process<'u'&&process[_0xb7ded2(0x22c)][_0xb7ded2(0x193)]||g[_0xb7ded2(0x195)],_=typeof process<'u'?process['env']:{},I=class{constructor(_0x27b9ea,_0x375c47){const _0x4b7f61=_0xb7ded2;this[_0x4b7f61(0x217)]=_0x27b9ea,this[_0x4b7f61(0x23d)]=_0x375c47,this[_0x4b7f61(0x1d7)]=_['MOSS_AUTH_URL']??T;}[_0xb7ded2(0x217)];[_0xb7ded2(0x23d)];[_0xb7ded2(0x1d7)];async['getAuthToken'](){const _0x479cd1=_0xb7ded2;let _0x412600=await fetch(this[_0x479cd1(0x1d7)],{'method':_0x479cd1(0x1d0),'headers':{'Content-Type':_0x479cd1(0x17c)},'body':JSON[_0x479cd1(0x1cc)]({'projectId':this[_0x479cd1(0x217)],'projectKey':this['projectKey']}),'signal':AbortSignal[_0x479cd1(0x1e7)](0x7530)});if(_0x412600[_0x479cd1(0x17e)]===0x191){let _0x5a4d53=await _0x412600[_0x479cd1(0x22a)]();throw new Error(_0x479cd1(0x16e)+_0x5a4d53);}if(!_0x412600['ok']){let _0x2818ba=await _0x412600[_0x479cd1(0x22a)]();throw new Error(_0x479cd1(0x1f9)+_0x412600['status']+':\x20'+_0x2818ba);}let _0x3bfd17=await _0x412600[_0x479cd1(0x206)]();return{'token':_0x3bfd17[_0x479cd1(0x1fa)],'expiresIn':_0x3bfd17[_0x479cd1(0x21e)]};}async['getAuthHeader'](){const _0x3adba4=_0xb7ded2;let {token:_0x577aff}=await this[_0x3adba4(0x185)]();return _0x3adba4(0x1cd)+_0x577aff;}},y=class{constructor(_0x44a248){const _0x393ecf=_0xb7ded2;this[_0x393ecf(0x1a7)]=_0x44a248;}[_0xb7ded2(0x1a7)];['cache']=null;[_0xb7ded2(0x203)]=null;async[_0xb7ded2(0x185)](){const _0xb880ea=_0xb7ded2;if(this[_0xb880ea(0x23c)]&&this[_0xb880ea(0x23c)]['expiresAt']>Date['now']())return{'token':this[_0xb880ea(0x23c)][_0xb880ea(0x1fa)],'expiresIn':this[_0xb880ea(0x23c)]['expiresIn']};if(this[_0xb880ea(0x203)])return this['inflight'];this[_0xb880ea(0x203)]=this['fetchAndCache']();try{return await this[_0xb880ea(0x203)];}finally{this['inflight']=null;}}async['getAuthHeader'](){const _0x3bca43=_0xb7ded2;let {token:_0x11e978}=await this[_0x3bca43(0x185)]();return'Bearer\x20'+_0x11e978;}async[_0xb7ded2(0x23b)](){const _0x367346=_0xb7ded2;let {token:_0x49746e,expiresIn:_0x17c8b6}=await this[_0x367346(0x1a7)][_0x367346(0x185)](),_0x569c2f=Date['now']()+(_0x17c8b6-0x3c)*0x3e8;return this[_0x367346(0x23c)]={'token':_0x49746e,'expiresIn':_0x17c8b6,'expiresAt':_0x569c2f},{'token':_0x49746e,'expiresIn':_0x17c8b6};}};import{randomUUID as _0x48aa9b}from'node:crypto';import{existsSync as _0x315ff5,mkdirSync as _0x767e04,readFileSync as _0x165c89,writeFileSync as _0x20d990}from'node:fs';import{join as _0xa59d9a}from'node:path';function _0x4484(){const _0x595f31=['getDocs','projectId','getAuthHeader','deleteIndex','deviceIdentity','bind','failed','manageClient','expiresIn','queryMultiIndexText','delete','_create','sources','encode','PendingUpload','isSafeInteger','listWebSources','rejectAuthRequest','data','query','text','all','env','received\x20','indexName','includePaths','cachePath','Unsupported\x20data\x20type\x20for\x20file\x20upload','resync','rootUrl','deleteDocs\x20requires\x20at\x20least\x20one\x20document\x20ID','call','parseDocuments','hasIndex','received\x20a\x20progress\x20event\x20with\x20a\x20non-string\x20currentPhase\x20(','unloadIndexes','updated','fetchAndCache','cache','projectKey','\x22)\x20or\x20loadIndexes([...])\x20before\x20querying;\x20queries\x20run\x20locally\x20and\x20there\x20is\x20no\x20cloud\x20query\x20fallback.','custom','warn','join','getJobStatus','test','received\x20a\x20progress\x20event\x20with\x20a\x20non-finite\x20progress\x20value\x20(','@moss-js/moss-core\x20>=\x200.20.0\x20is\x20required\x20for\x20MossClient.close()','SessionIndex','alpha','identity','applySessionIdentity','string','loadModel','message','byteLength','Authentication\x20failed\x20(HTTP\x20401):\x20','497266ZTVQED','jobId','NOT_FOUND','close','keys','default','applyIdentity','startsWith','deleteDocs','requireMultiIndexCore','received\x20an\x20array\x20where\x20a\x20JobProgress\x20object\x20was\x20expected','/v1/manage','261juHXPo','application/json','create','status','function','INVALID_ARGUMENT','modelArtifactContractVersion','userId','deleteWebSource','SessionIndex\x20\x27','getAuthToken','body','path','object','This\x20session\x20uses\x20custom\x20embeddings.\x20Provide\x20a\x20query\x20embedding\x20via\x20QueryOptions.embedding.','createIndex','2162012uNVucH','1720308VcVIoI','Web\x20source\x20methods\x20require\x20a\x20project\x20key.\x20Construct\x20MossClient\x20with\x20(projectId,\x20projectKey).','loadIndex','mossDeviceId','_fromInner','MOSS_CLOUD_API_BASE_URL','trim','MOSS_INDEX_URL','createIndexFromFiles\x20requires\x20at\x20least\x20one\x20file','CLOUD_API_INDEX_URL','2434901acjFFO','code','queryMultiIndex','MossClient\x20is\x20closed','pushIndex','onProgress','session','slice','Unsupported\x20job\x20status\x20\x27','addDocumentsText','ManageClient','saveToDisk','completed','parse','createIndex\x20requires\x20at\x20least\x20one\x20document','loadIndexes','Building','inner','createIndexFromFiles','Documents\x20missing\x20.embedding\x20for\x20custom\x20model:\x20','resolveAuthRequest','moss-core\x20runtime\x20SessionIndex\x20is\x20missing\x20the\x20withAuthenticator\x20factory.\x20Upgrade\x20@moss-js/moss-core\x20to\x20a\x20build\x20that\x20supports\x20custom\x20authenticators\x20for\x20sessions.','hasCustomAuthenticator','loadFromDisk','155705KvPUiE','CLOUD_API_IDENTITY_URL','authNotifyFn','minScore','.\x20All\x20documents\x20must\x20have\x20.embedding\x20set\x20when\x20using\x20modelId=\x27custom\x27.','withAuthenticator','Failed','entries','arrayBuffer','createAuthenticatedSessionInner','modelId','rebuildLegacy','received\x20a\x20progress\x20event\x20with\x20a\x20missing\x20or\x20empty\x20jobId\x20(','refreshCadence','queryText','[moss]\x20Dropping\x20a\x20malformed\x20job\x20progress\x20event;\x20progress\x20reporting\x20may\x20be\x20incomplete\x20for\x20this\x20operation.\x20Cause:\x20','setIdentity','asyncDispose','\x22\x20is\x20not\x20loaded.\x20Call\x20loadIndex(\x22','added','https://service.usemoss.dev','Uploading','moss-core\x20runtime\x20is\x20missing\x20resolveAuthRequest/rejectAuthRequest\x20exports.\x20Ensure\x20you\x20are\x20using\x20a\x20moss-core\x20build\x20that\x20supports\x20custom\x20authenticators.','The\x20installed\x20@moss-js/moss-core\x20does\x20not\x20support\x20multi-index\x20operations\x20(queryMultiIndex,\x20loadIndexes,\x20unloadIndexes).\x20Upgrade\x20@moss-js/moss-core.','map','indexManager','manifestSha256','toByteArray','@moss-js/moss-core\x20>=\x200.20.0\x20is\x20required\x20for\x20SessionIndex.close()','inspectSnapshot','stringify','Bearer\x20','embedding','fromEntries','POST','\x20contains\x20an\x20unsupported\x20character','isFinite','pendingupload','upsert','MossClient\x20options.identity\x20must\x20be\x20an\x20object','configuredIdentity','authUrl','1006wtrjDo','The\x20installed\x20@moss-js/moss-core\x20runtime\x20does\x20not\x20support\x20exact\x20model\x20artifact\x20identities.\x20Upgrade\x20moss-core\x20before\x20creating\x20this\x20session.','topK','IndexManager','MossClient\x20options.identity.','deviceId','wrapProgress','deleteDocuments','getIndex','moss-minilm','utf8','resyncWebSource','updateWebSource','isArray','currentPhase','timeout','cachePathDeviceId','_warmModel','docCount','getWebSource','\x27\x20is\x20closed','name','SDK_VERSION_NUMBER','queryMultiIndex\x20requires\x20at\x20least\x20one\x20index\x20name','createWebSource','MODEL_DOWNLOAD_URL','unloadIndex','parseOptions','11138004pfnJCR','deref','moss-core\x20rejected\x20the\x20auth\x20token:\x20','.moss-device-id','normalizeJobStatus','HTTP\x20','token','length','maxDocuments','replace','ensureCachePathDeviceId','Completed','listIndexes','moss-core\x20runtime\x20ManageClient/IndexManager\x20is\x20missing\x20withAuthenticator\x20factory.\x20Ensure\x20you\x20are\x20using\x20a\x20moss-core\x20build\x20that\x20supports\x20custom\x20authenticators.','\x27\x20returned\x20by\x20moss-core','inflight','number','CLOUD_API_AUTH_URL','json','authenticator','\x20must\x20be\x20at\x20most\x20','progress','filter','Index\x20\x22','version','maxPages','addDocs','error','from','building','add','\x20must\x20be\x20a\x20non-empty\x20string','8mUzxVC','pending_upload'];_0x4484=function(){return _0x595f31;};return _0x4484();}var Y=_0xb7ded2(0x1f7),S=0x100,k=/[\p{Cc}\p{Cf}\p{Cs}\uFFFD]/u;function Z(_0x14b5e1){const _0x23a8ba=_0xb7ded2;return _0x14b5e1['length']>0x0&&_0x14b5e1['trim']()===_0x14b5e1&&!k[_0x23a8ba(0x243)](_0x14b5e1)&&new TextEncoder()[_0x23a8ba(0x223)](_0x14b5e1)[_0x23a8ba(0x16d)]<=S;}function U(_0x5d4881,_0x1425e9){const _0x14c66a=_0xb7ded2;if(_0x5d4881!==void 0x0){if(typeof _0x5d4881!=_0x14c66a(0x16a)||_0x5d4881['length']===0x0)throw new TypeError('MossClient\x20options.identity.'+_0x1425e9+_0x14c66a(0x213));if(_0x5d4881[_0x14c66a(0x192)]()!==_0x5d4881)throw new TypeError('MossClient\x20options.identity.'+_0x1425e9+'\x20must\x20not\x20have\x20leading\x20or\x20trailing\x20whitespace');if(k[_0x14c66a(0x243)](_0x5d4881))throw new TypeError(_0x14c66a(0x1dc)+_0x1425e9+_0x14c66a(0x1d1));if(new TextEncoder()[_0x14c66a(0x223)](_0x5d4881)['byteLength']>S)throw new TypeError(_0x14c66a(0x1dc)+_0x1425e9+_0x14c66a(0x208)+S+'\x20UTF-8\x20bytes');return _0x5d4881;}}function _0xf7dd(_0x12546a,_0x14d2e6){_0x12546a=_0x12546a-0x169;const _0x448496=_0x4484();let _0xf7dd7a=_0x448496[_0x12546a];return _0xf7dd7a;}function L(_0x57af50){const _0xbafc50=_0xb7ded2;if(_0x57af50!==void 0x0){if(_0x57af50===null||typeof _0x57af50!=_0xbafc50(0x188)||Array[_0xbafc50(0x1e5)](_0x57af50))throw new TypeError(_0xbafc50(0x1d5));return Object['freeze']({'deviceId':U(_0x57af50[_0xbafc50(0x1dd)],'deviceId'),'userId':U(_0x57af50[_0xbafc50(0x182)],_0xbafc50(0x182))});}}function N(_0x4c9bbf){const _0x49f1f9=_0xb7ded2;return _0x4c9bbf?.[_0x49f1f9(0x1dd)]!==void 0x0||_0x4c9bbf?.[_0x49f1f9(0x182)]!==void 0x0;}function A(_0x95a4f1){const _0x3ac3d6=_0xb7ded2;if(!_0x95a4f1?.[_0x3ac3d6(0x192)]())return;let _0x3bc32b=_0xa59d9a(_0x95a4f1,Y);try{if(_0x315ff5(_0x3bc32b)){let _0x59138a=_0x165c89(_0x3bc32b,'utf8')[_0x3ac3d6(0x192)]();return Z(_0x59138a)?_0x59138a:void 0x0;}_0x767e04(_0x95a4f1,{'recursive':!0x0});let _0x5090cf=_0x48aa9b();return _0x20d990(_0x3bc32b,_0x5090cf,_0x3ac3d6(0x1e2)),_0x5090cf;}catch{return;}}var ee=0x1;function x(_0x1ef910){const _0x3dad15=_0xb7ded2;let _0x4c5fa3=_0x1ef910[_0x3dad15(0x181)];if(typeof _0x4c5fa3!='function')throw q();let _0x18a771=_0x4c5fa3[_0x3dad15(0x235)](_0x1ef910);if(!Number['isSafeInteger'](_0x18a771)||_0x18a771<ee)throw q();}function q(){const _0x2c0621=_0xb7ded2;return new Error(_0x2c0621(0x1d9));}var Pe=0x708*0x3e8,te={'INVALID_ARGUMENT':!0x0,'NOT_FOUND':!0x0,'UNAUTHORIZED':!0x0,'NETWORK':!0x0,'DESERIALIZATION':!0x0,'MODEL_UNAVAILABLE':!0x0,'INTERNAL':!0x0},ne=new Set(Object[_0xb7ded2(0x173)](te));function re(_0x2fd24e){const _0x7eb29f=_0xb7ded2;if(!(_0x2fd24e instanceof Error))return!0x1;let _0x4b4c19=_0x2fd24e[_0x7eb29f(0x197)];return typeof _0x4b4c19==_0x7eb29f(0x16a)&&ne['has'](_0x4b4c19);}function p(_0x509e4a,_0x8090e4){return Object['assign'](new Error(_0x8090e4),{'code':_0x509e4a});}function b(_0x4cf6ea){const _0x513e0a=_0xb7ded2;if(!(_0x4cf6ea?.[_0x513e0a(0x1b1)]===void 0x0&&_0x4cf6ea?.['candidateDepth']===void 0x0))return{'minScore':_0x4cf6ea['minScore'],'candidateDepth':_0x4cf6ea['candidateDepth']};}function D(_0x5b7cee){const _0x2f7207=_0xb7ded2;return _0x5b7cee instanceof Error?_0x5b7cee[_0x2f7207(0x16c)]:String(_0x5b7cee);}function se(_0x3b76e3){const _0x39d232=_0xb7ded2;if(_0x3b76e3===null||typeof _0x3b76e3!='object')return _0x39d232(0x22d)+String(_0x3b76e3);if(Array[_0x39d232(0x1e5)](_0x3b76e3))return _0x39d232(0x179);let _0x201909=_0x3b76e3;return typeof _0x201909[_0x39d232(0x170)]!=_0x39d232(0x16a)||_0x201909['jobId'][_0x39d232(0x1fb)]===0x0?_0x39d232(0x1ba)+String(_0x201909['jobId'])+')':typeof _0x201909[_0x39d232(0x17e)]!=_0x39d232(0x16a)||_0x201909[_0x39d232(0x17e)][_0x39d232(0x1fb)]===0x0?'received\x20a\x20progress\x20event\x20with\x20a\x20missing\x20or\x20empty\x20status\x20('+String(_0x201909['status'])+')':typeof _0x201909[_0x39d232(0x209)]!=_0x39d232(0x204)||!Number[_0x39d232(0x1d2)](_0x201909[_0x39d232(0x209)])?_0x39d232(0x244)+String(_0x201909[_0x39d232(0x209)])+')':_0x201909['currentPhase']!==void 0x0&&_0x201909['currentPhase']!==null&&typeof _0x201909[_0x39d232(0x1e6)]!=_0x39d232(0x16a)?_0x39d232(0x238)+String(_0x201909[_0x39d232(0x1e6)])+')':null;}var w=class{[_0xb7ded2(0x207)];[_0xb7ded2(0x21d)];['indexManager'];[_0xb7ded2(0x1e8)];[_0xb7ded2(0x1d6)];['projectId'];['authNotifyFn'];constructor(_0x478761,_0x47ea50,_0xdfae84){const _0xad4402=_0xb7ded2;this[_0xad4402(0x1d6)]=L(_0xdfae84?.[_0xad4402(0x248)]),this[_0xad4402(0x1e8)]=A(_0xdfae84?.[_0xad4402(0x230)]),this[_0xad4402(0x217)]=_0x478761;let _0x1a89df=typeof _0x47ea50==_0xad4402(0x16a)?new I(_0x478761,_0x47ea50):_0x47ea50;this[_0xad4402(0x207)]=new y(_0x1a89df);let _0x1bb598=_0x5e12ee,_0x1e0230=_0x1bb598[_0xad4402(0x1a0)]??_0x1bb598[_0xad4402(0x174)]?.['ManageClient'],_0xe3591=_0x1bb598[_0xad4402(0x1db)]??_0x1bb598[_0xad4402(0x174)]?.[_0xad4402(0x1db)];if(!_0x1e0230||!_0xe3591)throw new Error('moss-core\x20runtime\x20is\x20missing\x20ManageClient/IndexManager\x20exports');if(typeof _0x47ea50==_0xad4402(0x16a))this[_0xad4402(0x21d)]=new _0x1e0230(_0x478761,_0x47ea50),this[_0xad4402(0x1c7)]=new _0xe3591(_0x478761,_0x47ea50);else{let _0x122945=_0x1bb598[_0xad4402(0x1aa)]??_0x1bb598[_0xad4402(0x174)]?.[_0xad4402(0x1aa)],_0xe8ea7c=_0x1bb598[_0xad4402(0x227)]??_0x1bb598[_0xad4402(0x174)]?.['rejectAuthRequest'];if(!_0x122945||!_0xe8ea7c)throw new Error(_0xad4402(0x1c4));let _0x1ba626=this[_0xad4402(0x207)],_0x3ac26a=(_0x5e50d9,_0x3f0271)=>{const _0x24071a=_0xad4402;try{_0xe8ea7c(_0x5e50d9,_0x3f0271);}catch(_0x460c6a){console[_0x24071a(0x240)]('[moss]\x20Auth\x20request\x20'+_0x5e50d9+'\x20could\x20not\x20be\x20settled:\x20'+D(_0x460c6a));}},_0x2240e9=(_0x520f73,_0x513db5)=>{const _0x4c68d8=_0xad4402;try{_0x122945(_0x520f73,_0x513db5);}catch(_0x149373){_0x3ac26a(_0x520f73,_0x4c68d8(0x1f6)+D(_0x149373));}},_0x551385=!0x1,_0x16cb97=(_0x15a07c,_0x384c5e)=>{const _0x4ce78a=_0xad4402;if(_0x15a07c||!Number[_0x4ce78a(0x225)](_0x384c5e)||_0x384c5e<0x0){_0x551385||(_0x551385=!0x0,console[_0x4ce78a(0x240)]('[moss]\x20Ignoring\x20an\x20auth\x20request\x20with\x20no\x20usable\x20request\x20id;\x20custom\x20authentication\x20may\x20be\x20unavailable\x20for\x20this\x20client.\x20Cause:\x20'+(_0x15a07c?_0x15a07c[_0x4ce78a(0x16c)]:_0x4ce78a(0x22d)+String(_0x384c5e))));return;}_0x1ba626[_0x4ce78a(0x218)]()['then'](_0x2ab775=>{const _0x366ba9=_0x4ce78a;let _0x18915e=_0x2ab775[_0x366ba9(0x176)](_0x366ba9(0x1cd))?_0x2ab775[_0x366ba9(0x19d)](0x7):_0x2ab775;_0x2240e9(_0x384c5e,_0x18915e);},_0x215739=>_0x3ac26a(_0x384c5e,D(_0x215739)));};this[_0xad4402(0x1b0)]=_0x16cb97;let _0x560194=_0x1e0230,_0x5f1eaf=_0xe3591;if(!_0x560194[_0xad4402(0x1b3)]||!_0x5f1eaf[_0xad4402(0x1b3)])throw new Error(_0xad4402(0x201));this['manageClient']=_0x560194['withAuthenticator'](_0x478761,_0x16cb97),this['indexManager']=_0x5f1eaf['withAuthenticator'](_0x478761,_0x16cb97);}this[_0xad4402(0x175)](this[_0xad4402(0x1c7)]);}async[_0xb7ded2(0x172)](){const _0x84b445=_0xb7ded2;let _0x2784b7=this[_0x84b445(0x1c7)][_0x84b445(0x172)];if(typeof _0x2784b7!=_0x84b445(0x17f))throw new Error(_0x84b445(0x245));await _0x2784b7[_0x84b445(0x235)](this[_0x84b445(0x1c7)]);}async['getAuthToken'](){const _0xa5ce15=_0xb7ded2;return this[_0xa5ce15(0x207)][_0xa5ce15(0x185)]();}[_0xb7ded2(0x1de)](_0x241389){if(!_0x241389)return;let _0x290b22=!0x1;return(_0x4234f8,_0x586727)=>{const _0x42e3f2=_0xf7dd;let _0x137c84=_0x4234f8?_0x4234f8['message']:se(_0x586727);if(_0x137c84!==null){_0x290b22||(_0x290b22=!0x0,console['warn'](_0x42e3f2(0x1bd)+_0x137c84));return;}_0x241389(_0x586727);};}[_0xb7ded2(0x1f8)](_0x3fa72e){const _0x578fac=_0xb7ded2;let _0x577c17=_0x3fa72e['trim']()['toLowerCase']()[_0x578fac(0x1fd)](/\s+/g,'_'),_0xe62ac=_0x577c17[_0x578fac(0x1fd)](/_/g,'');if(_0x577c17===_0x578fac(0x215)||_0xe62ac===_0x578fac(0x1d3))return _0x5f4ea8[_0x578fac(0x224)];if(_0x577c17==='uploading')return _0x5f4ea8[_0x578fac(0x1c3)];if(_0x577c17===_0x578fac(0x211))return _0x5f4ea8[_0x578fac(0x1a6)];if(_0x577c17===_0x578fac(0x1a2))return _0x5f4ea8[_0x578fac(0x1ff)];if(_0x577c17===_0x578fac(0x21c))return _0x5f4ea8[_0x578fac(0x1b4)];throw new Error(_0x578fac(0x19e)+_0x3fa72e+_0x578fac(0x202));}async[_0xb7ded2(0x18a)](_0x182604,_0x54548d,_0x39a569,_0x521013){const _0x4b11e1=_0xb7ded2;if(!_0x54548d[_0x4b11e1(0x1fb)])throw new Error(_0x4b11e1(0x1a4));return await this[_0x4b11e1(0x21d)][_0x4b11e1(0x18a)](_0x182604,_0x54548d,_0x39a569,this[_0x4b11e1(0x1de)](_0x521013?.[_0x4b11e1(0x19b)]));}async[_0xb7ded2(0x1c9)](_0x5ed9fe){const _0x43b10d=_0xb7ded2;if(_0x5ed9fe instanceof Uint8Array)return Array[_0x43b10d(0x210)](_0x5ed9fe);if(_0x5ed9fe instanceof ArrayBuffer)return Array['from'](new Uint8Array(_0x5ed9fe));if(typeof _0x5ed9fe[_0x43b10d(0x1b6)]==_0x43b10d(0x17f)){let _0x249063=await _0x5ed9fe['arrayBuffer']();return Array[_0x43b10d(0x210)](new Uint8Array(_0x249063));}throw new Error(_0x43b10d(0x231));}async[_0xb7ded2(0x1a8)](_0x467af6,_0x8711df,_0x1eefa4){const _0x3f33c8=_0xb7ded2;if(_0x8711df['length']===0x0)throw new Error(_0x3f33c8(0x194));let _0x53f0b9=_0x1eefa4?.['modelId']??'moss-minilm',_0x8772ba=await Promise[_0x3f33c8(0x22b)](_0x8711df[_0x3f33c8(0x1c6)](async _0x1a1a04=>({'name':_0x1a1a04[_0x3f33c8(0x1ed)],'contentType':_0x1a1a04['contentType'],'path':_0x1a1a04[_0x3f33c8(0x187)]??void 0x0,'data':_0x1a1a04[_0x3f33c8(0x228)]!=null?await this['toByteArray'](_0x1a1a04[_0x3f33c8(0x228)]):void 0x0})));return await this['manageClient'][_0x3f33c8(0x1a8)](_0x467af6,_0x8772ba,_0x53f0b9,this['wrapProgress'](_0x1eefa4?.[_0x3f33c8(0x19b)]),_0x1eefa4?.[_0x3f33c8(0x1f3)]??null);}async[_0xb7ded2(0x20e)](_0x249710,_0x10afe7,_0x2501ab){const _0x385774=_0xb7ded2;if(Array[_0x385774(0x1e5)](_0x10afe7)&&_0x10afe7[_0x385774(0x1fb)]===0x0)throw new Error('addDocs\x20requires\x20at\x20least\x20one\x20document');return await this[_0x385774(0x21d)]['addDocs'](_0x249710,_0x10afe7,_0x2501ab??null,this[_0x385774(0x1de)](_0x2501ab?.['onProgress']));}async[_0xb7ded2(0x177)](_0x39a44d,_0x2de74a,_0x11a855){const _0x146a78=_0xb7ded2;if(Array[_0x146a78(0x1e5)](_0x2de74a)&&_0x2de74a[_0x146a78(0x1fb)]===0x0)throw new Error(_0x146a78(0x234));return await this['manageClient'][_0x146a78(0x177)](_0x39a44d,_0x2de74a,this['wrapProgress'](_0x11a855?.['onProgress']));}async[_0xb7ded2(0x242)](_0x11fa02){const _0x52198d=_0xb7ded2;let _0x43c57c=await this['manageClient'][_0x52198d(0x242)](_0x11fa02);return{..._0x43c57c,'status':this['normalizeJobStatus'](_0x43c57c[_0x52198d(0x17e)]),'currentPhase':_0x43c57c['currentPhase']??null,'error':_0x43c57c[_0x52198d(0x20f)]??null};}async[_0xb7ded2(0x1e0)](_0x4fa82a){const _0x3a7711=_0xb7ded2;return this[_0x3a7711(0x21d)][_0x3a7711(0x1e0)](_0x4fa82a);}async[_0xb7ded2(0x200)](){const _0x279af8=_0xb7ded2;return this[_0x279af8(0x21d)]['listIndexes']();}async[_0xb7ded2(0x219)](_0x5b1e4a){const _0x1f969e=_0xb7ded2;return this[_0x1f969e(0x21d)][_0x1f969e(0x219)](_0x5b1e4a);}async[_0xb7ded2(0x216)](_0x4f3386,_0x516c46){const _0x10bb7a=_0xb7ded2;return this[_0x10bb7a(0x21d)]['getDocs'](_0x4f3386,_0x516c46??null);}async[_0xb7ded2(0x18e)](_0x366420,_0x3d885a){const _0x24f2d7=_0xb7ded2;return this['ensureCachePathDeviceId'](_0x3d885a?.[_0x24f2d7(0x230)]),(await this[_0x24f2d7(0x1c7)][_0x24f2d7(0x18e)](_0x366420,_0x3d885a??null))['name'];}async[_0xb7ded2(0x1a5)](_0x402de0,_0x241abc){const _0x2310be=_0xb7ded2;let _0x43b2ad=this[_0x2310be(0x178)]();return this['ensureCachePathDeviceId'](_0x241abc?.['cachePath']),_0x43b2ad[_0x2310be(0x1a5)](_0x402de0,_0x241abc??null);}async[_0xb7ded2(0x1f2)](_0x144493){const _0x76beb0=_0xb7ded2;return this[_0x76beb0(0x1c7)][_0x76beb0(0x1f2)](_0x144493);}async[_0xb7ded2(0x239)](_0x26483c){return this['requireMultiIndexCore']()['unloadIndexes'](_0x26483c);}[_0xb7ded2(0x178)](){const _0x69cd8c=_0xb7ded2;let _0x54219d=this[_0x69cd8c(0x1c7)];if(typeof _0x54219d[_0x69cd8c(0x198)]!=_0x69cd8c(0x17f)||typeof _0x54219d[_0x69cd8c(0x21f)]!='function'||typeof _0x54219d[_0x69cd8c(0x1a5)]!=_0x69cd8c(0x17f)||typeof _0x54219d['unloadIndexes']!='function')throw new Error(_0x69cd8c(0x1c5));return{'queryMultiIndex':_0x54219d[_0x69cd8c(0x198)][_0x69cd8c(0x21b)](_0x54219d),'queryMultiIndexText':_0x54219d[_0x69cd8c(0x21f)]['bind'](_0x54219d),'loadIndexes':_0x54219d[_0x69cd8c(0x1a5)][_0x69cd8c(0x21b)](_0x54219d),'unloadIndexes':_0x54219d['unloadIndexes'][_0x69cd8c(0x21b)](_0x54219d)};}[_0xb7ded2(0x1fe)](_0x2299dc){_0x2299dc&&this['cachePathDeviceId']===void 0x0&&A(_0x2299dc);}[_0xb7ded2(0x175)]=_0x3abb0d=>{const _0x193778=_0xb7ded2;!N(this['configuredIdentity'])&&this[_0x193778(0x1e8)]===void 0x0||_0x3abb0d['setIdentity'](this[_0x193778(0x1d6)]?.[_0x193778(0x1dd)]??null,this[_0x193778(0x1d6)]?.['userId']??null,this[_0x193778(0x1e8)]??null);};[_0xb7ded2(0x169)]=_0x5ae14e=>{const _0x779b33=_0xb7ded2;let _0x54b315=this['indexManager'][_0x779b33(0x21a)]?.();if(!_0x54b315){this[_0x779b33(0x175)](_0x5ae14e);return;}_0x5ae14e[_0x779b33(0x1be)](_0x54b315[_0x779b33(0x1dd)]??null,this[_0x779b33(0x1d6)]?.[_0x779b33(0x182)]??null,_0x54b315[_0x779b33(0x18f)]??null);};[_0xb7ded2(0x1ac)](){const _0x58f231=_0xb7ded2;return this[_0x58f231(0x1b0)]!==void 0x0;}async[_0xb7ded2(0x1b7)](_0x3136ef,_0x42f9a8,_0x1f7f49){const _0x4131e5=_0xb7ded2;if(!this[_0x4131e5(0x1b0)])throw new Error('createAuthenticatedSessionInner\x20requires\x20a\x20custom\x20IAuthenticator\x20client');let _0x19cad1=_0x5e12ee,_0x50976e=_0x19cad1[_0x4131e5(0x246)]??_0x19cad1['default']?.[_0x4131e5(0x246)];if(!_0x50976e||typeof _0x50976e['withAuthenticator']!='function')throw new Error(_0x4131e5(0x1ab));return _0x1f7f49&&x(_0x50976e),_0x50976e[_0x4131e5(0x1b3)](_0x3136ef,_0x42f9a8,this[_0x4131e5(0x217)],this[_0x4131e5(0x1b0)],null,null,_0x1f7f49?.[_0x4131e5(0x20c)]??null,_0x1f7f49?.[_0x4131e5(0x1c8)]??null);}async[_0xb7ded2(0x229)](_0x359782,_0x61530c,_0x250c07){const _0x32c90f=_0xb7ded2;if(!await this[_0x32c90f(0x1c7)][_0x32c90f(0x237)](_0x359782))throw p(_0x32c90f(0x171),_0x32c90f(0x20b)+_0x359782+_0x32c90f(0x1c0)+_0x359782+_0x32c90f(0x23e));let _0x1fa202=_0x250c07?.[_0x32c90f(0x1da)]??0x5,_0x2d77f5=_0x250c07?.['alpha']??0.8;return _0x250c07?.['embedding']?this['indexManager'][_0x32c90f(0x229)](_0x359782,_0x61530c,_0x250c07[_0x32c90f(0x1ce)],_0x1fa202,_0x2d77f5,_0x250c07?.[_0x32c90f(0x20a)],b(_0x250c07)):this[_0x32c90f(0x1c7)]['queryText'](_0x359782,_0x61530c,_0x1fa202,_0x2d77f5,_0x250c07?.[_0x32c90f(0x20a)],b(_0x250c07));}async[_0xb7ded2(0x198)](_0x584fda,_0x2364a2,_0x5ba4c0){const _0x34e1a3=_0xb7ded2;if(_0x584fda[_0x34e1a3(0x1fb)]===0x0)throw p(_0x34e1a3(0x180),_0x34e1a3(0x1ef));let _0x273f00=this[_0x34e1a3(0x178)](),_0x2d11cb=_0x5ba4c0?.[_0x34e1a3(0x1da)]??0xa,_0x2cbc9d=_0x5ba4c0?.[_0x34e1a3(0x247)]??0.8;return _0x5ba4c0?.['embedding']?_0x273f00[_0x34e1a3(0x198)](_0x584fda,_0x2364a2,_0x5ba4c0[_0x34e1a3(0x1ce)],_0x2d11cb,_0x2cbc9d,_0x5ba4c0?.[_0x34e1a3(0x20a)],b(_0x5ba4c0)):_0x273f00['queryMultiIndexText'](_0x584fda,_0x2364a2,_0x2d11cb,_0x2cbc9d,_0x5ba4c0?.['filter'],b(_0x5ba4c0));}};import{SessionIndex as _0x259da3}from'@moss-js/moss-core';var h=class r{#e;#r;#s;#i=!0x1;#a;constructor(_0x4cfb78,_0x306448,_0x4e6938){this.#s=_0x4cfb78,this.#r=_0x306448,this.#e=_0x4e6938;}static async['_create'](_0x35a2fe,_0xf47c35,_0x484e3e,_0x98cfd5,_0x105ac5,_0x3d2dbb,_0x535006){const _0x322464=_0xb7ded2;let _0x284916=_0x259da3;_0x535006&&x(_0x284916);let _0x54ba6c=await _0x284916[_0x322464(0x17d)](_0x35a2fe,_0xf47c35,_0x484e3e,_0x98cfd5,_0x105ac5??null,_0x535006?.[_0x322464(0x20c)]??null,_0x535006?.[_0x322464(0x1c8)]??null);return r['_fromInner'](_0x35a2fe,_0xf47c35,_0x54ba6c,_0x3d2dbb);}static[_0xb7ded2(0x190)](_0x25cc42,_0x26f2cf,_0x505650,_0x36237d){return _0x36237d?.(_0x505650),new r(_0x25cc42,_0x26f2cf,_0x505650);}get[_0xb7ded2(0x1ed)](){return this.#s;}get[_0xb7ded2(0x1ea)](){const _0x31c758=_0xb7ded2;return this.#n(),this.#e[_0x31c758(0x1ea)];}get['modelId'](){return this.#r;}async[_0xb7ded2(0x20e)](_0x5a3872,_0x3b8636){const _0x3d668a=_0xb7ded2;this.#n();let _0x4f659a=_0x3b8636?{'upsert':_0x3b8636[_0x3d668a(0x1d4)]??!0x0}:void 0x0;if(this.#r===_0x3d668a(0x23f)){let _0x3d3b94=r.#t(_0x5a3872),_0x2a123f=_0x5a3872['map'](_0x1b5b53=>{const _0x1bd0c8=_0x3d668a;let _0x1a6048={..._0x1b5b53};return delete _0x1a6048[_0x1bd0c8(0x1ce)],_0x1a6048;}),_0x232644=await this.#e['addDocuments'](_0x2a123f,_0x3d3b94,_0x4f659a);return{'added':_0x232644[_0x3d668a(0x1c1)],'updated':_0x232644[_0x3d668a(0x23a)]};}let _0x2b3cbf=await this.#e[_0x3d668a(0x19f)](_0x5a3872,_0x4f659a);return{'added':_0x2b3cbf[_0x3d668a(0x1c1)],'updated':_0x2b3cbf[_0x3d668a(0x23a)]};}async[_0xb7ded2(0x177)](_0x3eae8a){const _0x30dfeb=_0xb7ded2;return this.#n(),await this.#e[_0x30dfeb(0x1df)](_0x3eae8a);}async['getDocs'](_0x1bb624){return this.#n(),await this.#e['getDocuments'](_0x1bb624??null);}async[_0xb7ded2(0x229)](_0xf8d8bc,_0x2fe9ad){const _0x458038=_0xb7ded2;this.#n();let _0x3e61ab=_0x2fe9ad?.['topK']??0x5,_0x12565d=_0x2fe9ad?.[_0x458038(0x247)]??0.8,_0x351d86=_0x2fe9ad?.['filter']??null,_0x20d28c=_0x2fe9ad?.[_0x458038(0x1ce)];if(_0x20d28c==null){if(this.#r==='custom')throw p('INVALID_ARGUMENT',_0x458038(0x189));return await this.#e[_0x458038(0x1bc)](_0xf8d8bc,_0x3e61ab,_0x12565d,_0x351d86);}return await this.#e[_0x458038(0x229)](_0xf8d8bc,_0x3e61ab,Array['from'](_0x20d28c),_0x12565d,_0x351d86);}async['loadIndex'](_0x37f50e,_0x4278f5){return this.#n(),this.#e['loadIndex'](_0x37f50e,_0x4278f5??null);}async['pushIndex'](){const _0x3f93f0=_0xb7ded2;return this.#n(),this.#e[_0x3f93f0(0x19a)]();}async['saveToDisk'](_0x60abcc){const _0x5761dc=_0xb7ded2;this.#n(),await this.#e[_0x5761dc(0x1a1)](_0x60abcc);}async['loadFromDisk'](_0x3e7105,_0x51121c){const _0xdf5bf7=_0xb7ded2;this.#n();let _0x1f7428=_0x51121c?.[_0xdf5bf7(0x1b9)]??!0x0;return await this.#e[_0xdf5bf7(0x1ad)](_0x3e7105,{'rebuildLegacy':_0x1f7428});}async[_0xb7ded2(0x1cb)](_0x27cea1){const _0x32b0e5=_0xb7ded2;return this.#n(),await this.#e[_0x32b0e5(0x1cb)](_0x27cea1);}#n(){const _0x15e3f7=_0xb7ded2;if(this.#i)throw new Error(_0x15e3f7(0x184)+this.#s+_0x15e3f7(0x1ec));}[_0xb7ded2(0x172)](){return this.#a??=this.#o(),this.#a;}async #o(){const _0xf22ed4=_0xb7ded2;this.#i=!0x0;let _0x2a56b3=this.#e[_0xf22ed4(0x172)];if(typeof _0x2a56b3!=_0xf22ed4(0x17f))throw new Error(_0xf22ed4(0x1ca));await _0x2a56b3[_0xf22ed4(0x235)](this.#e);}async[Symbol[_0xb7ded2(0x1bf)]](){const _0x56d7e1=_0xb7ded2;return this[_0x56d7e1(0x172)]();}async[_0xb7ded2(0x1e9)](){const _0x181b86=_0xb7ded2;this.#n(),this.#r!==_0x181b86(0x23f)&&await this.#e[_0x181b86(0x16b)]();}static#t(_0x5d5d99){const _0x40ca0b=_0xb7ded2;let _0x199a9c=_0x5d5d99[_0x40ca0b(0x20a)](_0x2b6dcc=>!_0x2b6dcc[_0x40ca0b(0x1ce)]||_0x2b6dcc[_0x40ca0b(0x1ce)][_0x40ca0b(0x1fb)]===0x0)[_0x40ca0b(0x1c6)](_0x480020=>_0x480020['id']);if(_0x199a9c[_0x40ca0b(0x1fb)]>0x0)throw new Error(_0x40ca0b(0x1a9)+_0x199a9c[_0x40ca0b(0x241)](',\x20')+_0x40ca0b(0x1b2));return _0x5d5d99['map'](_0x18b116=>Array['from'](_0x18b116[_0x40ca0b(0x1ce)]??[]));}};import{validateIndexName as _0x3067b3}from'@moss-js/moss-core';var ie=_0xb7ded2(0x1c2),ae=_0xb7ded2(0x17a),M=class extends Error{[_0xb7ded2(0x17e)];[_0xb7ded2(0x186)];constructor(_0x1fe103,_0x491f84){const _0x56fb81=_0xb7ded2;let _0x3db726=_0x491f84?':\x20'+_0x491f84:'';super('HTTP\x20error!\x20status:\x20'+_0x1fe103+_0x3db726),this[_0x56fb81(0x1ed)]='ManageApiError',this[_0x56fb81(0x17e)]=_0x1fe103,this[_0x56fb81(0x186)]=_0x491f84;}};function ue(){const _0x46de45=_0xb7ded2;return''+(typeof process<'u'&&process[_0x46de45(0x22c)][_0x46de45(0x191)]||ie)[_0x46de45(0x1fd)](/\/+$/,'')+ae;}function de(_0x31fc57){const _0x2e06a6=_0xb7ded2;return _0x31fc57?Object[_0x2e06a6(0x1cf)](Object[_0x2e06a6(0x1b5)](_0x31fc57)[_0x2e06a6(0x20a)](([,_0x537b8a])=>_0x537b8a!==void 0x0)):{};}async function j(_0x1aba3b,_0x216394,_0x33ea0f,_0x3d6566){const _0x360d69=_0xb7ded2;let _0x3cff5f={...de(_0x3d6566),'action':_0x33ea0f,'projectId':_0x1aba3b},_0x3ef2e6=await fetch(ue(),{'method':'POST','headers':{'Content-Type':_0x360d69(0x17c),'X-Project-Key':_0x216394},'body':JSON[_0x360d69(0x1cc)](_0x3cff5f),'signal':AbortSignal['timeout'](0x927c0)}),_0x3b7fb1=await _0x3ef2e6[_0x360d69(0x22a)]();if(!_0x3ef2e6['ok'])throw new M(_0x3ef2e6[_0x360d69(0x17e)],_0x3b7fb1);return _0x3b7fb1?JSON[_0x360d69(0x1a3)](_0x3b7fb1):{};}var W=_0xb7ded2(0x1e1),R=class{#e;#r;#s;#i=!0x1;#a;#n=new Set();constructor(_0x2d2285,_0x4aa5d8,_0x441ce8){this.#e=new w(_0x2d2285,_0x4aa5d8,_0x441ce8),this.#r=_0x2d2285,this.#s=typeof _0x4aa5d8=='string'?_0x4aa5d8:null;}async[_0xb7ded2(0x185)](){const _0x28cb25=_0xb7ded2;return this.#t(),this.#e[_0x28cb25(0x185)]();}async[_0xb7ded2(0x18a)](_0xb159dd,_0xda3c4c,_0x37398f){const _0x27a719=_0xb7ded2;this.#t();let _0x450307;return _0x37398f?.['modelId']!==void 0x0?_0x450307=_0x37398f['modelId']:_0x450307=_0xda3c4c['some'](_0x413302=>Array['isArray'](_0x413302['embedding'])&&_0x413302[_0x27a719(0x1ce)][_0x27a719(0x1fb)]>0x0)?'custom':W,this.#e[_0x27a719(0x18a)](_0xb159dd,_0xda3c4c,_0x450307,_0x37398f);}async[_0xb7ded2(0x1a8)](_0x2d891e,_0x176bea,_0x2e19ad){const _0x4cd157=_0xb7ded2;return this.#t(),this.#e[_0x4cd157(0x1a8)](_0x2d891e,_0x176bea,_0x2e19ad);}async[_0xb7ded2(0x1e0)](_0x57f57e){const _0x489db1=_0xb7ded2;return this.#t(),this.#e[_0x489db1(0x1e0)](_0x57f57e);}async['listIndexes'](){const _0x5be572=_0xb7ded2;return this.#t(),this.#e[_0x5be572(0x200)]();}async[_0xb7ded2(0x219)](_0x596e86){const _0x271122=_0xb7ded2;return this.#t(),this.#e[_0x271122(0x219)](_0x596e86);}async[_0xb7ded2(0x20e)](_0x56998f,_0x21680a,_0x57bcb3){const _0x1a7a7a=_0xb7ded2;return this.#t(),this.#e[_0x1a7a7a(0x20e)](_0x56998f,_0x21680a,_0x57bcb3);}async[_0xb7ded2(0x177)](_0x48ed57,_0x1fc2e3,_0x55e776){const _0x4901d8=_0xb7ded2;return this.#t(),this.#e[_0x4901d8(0x177)](_0x48ed57,_0x1fc2e3,_0x55e776);}async[_0xb7ded2(0x242)](_0x37ae5f){const _0xf1ed33=_0xb7ded2;return this.#t(),this.#e[_0xf1ed33(0x242)](_0x37ae5f);}async[_0xb7ded2(0x1f0)](_0x3323a2,_0x19d5fa,_0x3b3ba1){const _0x601b7d=_0xb7ded2;return this.#t(),_0x3067b3(_0x19d5fa),this.#o(_0x601b7d(0x1f0),{'rootUrl':_0x3323a2,'indexName':_0x19d5fa,'maxPages':_0x3b3ba1?.[_0x601b7d(0x20d)],'maxDocuments':_0x3b3ba1?.[_0x601b7d(0x1fc)],'maxDepth':_0x3b3ba1?.['maxDepth'],'includePaths':_0x3b3ba1?.[_0x601b7d(0x22f)],'excludePaths':_0x3b3ba1?.['excludePaths'],'respectRobots':_0x3b3ba1?.['respectRobots'],'parseDocuments':_0x3b3ba1?.[_0x601b7d(0x236)],'refreshCadence':_0x3b3ba1?.[_0x601b7d(0x1bb)],'modelId':_0x3b3ba1?.[_0x601b7d(0x1b8)]});}async[_0xb7ded2(0x226)](_0x5e58f6){const _0x2e3cff=_0xb7ded2;this.#t();let _0x3a9fc7=(await this.#o(_0x2e3cff(0x226),_0x5e58f6!==void 0x0?{'indexName':_0x5e58f6}:void 0x0))[_0x2e3cff(0x222)]??[];return _0x5e58f6===void 0x0?_0x3a9fc7:_0x3a9fc7[_0x2e3cff(0x20a)](_0x4e49d9=>_0x4e49d9[_0x2e3cff(0x22e)]===_0x5e58f6);}async[_0xb7ded2(0x1eb)](_0x316fb0){const _0x78e178=_0xb7ded2;return this.#t(),this.#o(_0x78e178(0x1eb),{'sourceId':_0x316fb0});}async['updateWebSource'](_0x132e37,_0x5a1838){const _0x38c56b=_0xb7ded2;return this.#t(),this.#o(_0x38c56b(0x1e4),{'sourceId':_0x132e37,'refreshCadence':_0x5a1838[_0x38c56b(0x1bb)],'rootUrl':_0x5a1838[_0x38c56b(0x233)],'includePaths':_0x5a1838[_0x38c56b(0x22f)],'excludePaths':_0x5a1838['excludePaths'],'maxDepth':_0x5a1838['maxDepth'],'maxPages':_0x5a1838[_0x38c56b(0x20d)],'resync':_0x5a1838[_0x38c56b(0x232)]});}async[_0xb7ded2(0x1e3)](_0x2bafba){const _0x5516fd=_0xb7ded2;return this.#t(),this.#o(_0x5516fd(0x1e3),{'sourceId':_0x2bafba});}async[_0xb7ded2(0x183)](_0x4b2c99){return this.#t(),this.#o('deleteWebSource',{'sourceId':_0x4b2c99});}async #o(_0x4187e1,_0x5b3ae7){const _0x409ef0=_0xb7ded2;if(this.#s===null)throw new Error(_0x409ef0(0x18d));return j(this.#r,this.#s,_0x4187e1,_0x5b3ae7);}async[_0xb7ded2(0x216)](_0x4a5a9e,_0x2d123c){return this.#t(),this.#e['getDocs'](_0x4a5a9e,_0x2d123c);}async[_0xb7ded2(0x18e)](_0x1e7cbd,_0x39c933){return this.#t(),this.#e['loadIndex'](_0x1e7cbd,_0x39c933);}async[_0xb7ded2(0x1a5)](_0x5b75f7,_0x547190){const _0x8ecec7=_0xb7ded2;return this.#t(),this.#e[_0x8ecec7(0x1a5)](_0x5b75f7,_0x547190);}async[_0xb7ded2(0x1f2)](_0x5aaab6){const _0x10f955=_0xb7ded2;return this.#t(),this.#e[_0x10f955(0x1f2)](_0x5aaab6);}async['unloadIndexes'](_0x5d0fff){return this.#t(),this.#e['unloadIndexes'](_0x5d0fff);}async[_0xb7ded2(0x229)](_0x7438c8,_0x4002c0,_0x36dd6e){return this.#t(),this.#e['query'](_0x7438c8,_0x4002c0,_0x36dd6e);}async['queryMultiIndex'](_0x4fef6d,_0x244526,_0x56cb8d){return this.#t(),this.#e['queryMultiIndex'](_0x4fef6d,_0x244526,_0x56cb8d);}async[_0xb7ded2(0x19c)](_0x505baf,_0x42774f=W,_0x521f5d){const _0x3f4673=_0xb7ded2;this.#t();let _0x218297=this.#e[_0x3f4673(0x169)],_0x12e6cb;if(this.#s!==null)_0x12e6cb=await h[_0x3f4673(0x221)](_0x505baf,_0x42774f,this.#r,this.#s,void 0x0,_0x218297,_0x521f5d);else{let _0x3cc55c=await this.#e[_0x3f4673(0x1b7)](_0x505baf,_0x42774f,_0x521f5d);_0x12e6cb=h[_0x3f4673(0x190)](_0x505baf,_0x42774f,_0x3cc55c,_0x218297);}await _0x12e6cb[_0x3f4673(0x1e9)]();for(let _0x1567b4 of this.#n)_0x1567b4[_0x3f4673(0x1f5)]()||this.#n[_0x3f4673(0x220)](_0x1567b4);return this.#n[_0x3f4673(0x212)](new WeakRef(_0x12e6cb)),_0x12e6cb;}#t(){const _0x1b95e8=_0xb7ded2;if(this.#i)throw new Error(_0x1b95e8(0x199));}[_0xb7ded2(0x172)](){return this.#a??=this.#u(),this.#a;}async #u(){const _0x1ff043=_0xb7ded2;this.#i=!0x0;let _0x404b33=[...this.#n][_0x1ff043(0x1c6)](_0x10731e=>_0x10731e['deref']())[_0x1ff043(0x20a)](_0x14efc9=>_0x14efc9!==void 0x0);this.#n['clear'](),await Promise[_0x1ff043(0x22b)](_0x404b33[_0x1ff043(0x1c6)](_0x5ad13f=>_0x5ad13f[_0x1ff043(0x172)]())),await this.#e['close']();}async[Symbol['asyncDispose']](){const _0x5aa60e=_0xb7ded2;return this[_0x5aa60e(0x172)]();}};export{M as ManageApiError,R as MossClient,h as SessionIndex,re as isMossError};
package/dist/moss.d.ts CHANGED
@@ -95,6 +95,9 @@ declare interface IdentityTarget {
95
95
  setIdentity(deviceId?: string | null, userId?: string | null, mossDeviceId?: string | null): void;
96
96
  }
97
97
 
98
+ /** True when `error` carries a stable Moss `code`, set by the native core or the SDK. */
99
+ export declare function isMossError(error: unknown): error is MossError;
100
+
98
101
  /**
99
102
  * ISO 8601 date string format.
100
103
  * @example "2025-09-26T15:04:05Z"
@@ -128,9 +131,14 @@ export declare interface LoadIndexesResult {
128
131
  */
129
132
  loaded: string[];
130
133
  /**
131
- * Names that failed to load, mapping name to error message.
134
+ * Names that failed to load, mapping name to a fixed public message.
132
135
  */
133
136
  failed: Record<string, string>;
137
+ /**
138
+ * Names that failed to load, mapping name to the error code. Set by the
139
+ * matching `@moss-js/moss-core`.
140
+ */
141
+ failedCodes?: Record<string, MossErrorCode>;
134
142
  }
135
143
 
136
144
  /**
@@ -146,6 +154,7 @@ export declare interface LoadIndexOptions {
146
154
  autoRefresh?: boolean;
147
155
  /**
148
156
  * Polling interval in seconds. Only used when autoRefresh is true.
157
+ * 0 uses the default, and the minimum is 1 second.
149
158
  * @default 600 (10 minutes)
150
159
  */
151
160
  pollingIntervalInSeconds?: number;
@@ -518,15 +527,21 @@ export declare class MossClient {
518
527
  *
519
528
  * The index must have been loaded via `loadIndex()` or `loadIndexes()`;
520
529
  * queries run entirely in-memory with no network round-trip. Querying an
521
- * index that is not loaded rejects with an error naming the load call.
530
+ * index that is not loaded rejects with a `NOT_FOUND` error naming the load call.
522
531
  *
523
532
  * Loaded foundation indexes require an exact model artifact identity before
524
533
  * Moss can generate query embeddings locally. For an older identity-less
525
534
  * index, provide a caller-generated vector through `options.embedding`.
526
535
  *
536
+ * A blank `query` (empty or only whitespace) with no `options.embedding`
537
+ * returns no results at every `alpha`, without running the embedding model.
538
+ * With an embedding, a blank `query` ranks by the embedding alone. An
539
+ * embedding holding NaN or infinity, or one whose length differs from the
540
+ * index dimension, rejects at every `alpha`.
541
+ *
527
542
  * @param indexName - Name of the target index to search.
528
543
  * @param query - The search query text.
529
- * @param options - Optional query configuration including topK (default: 5) and embedding overrides.
544
+ * @param options - Optional query configuration including topK (default: 5; 0 returns no results), embedding overrides, minScore, and candidateDepth.
530
545
  * @returns Promise that resolves to SearchResult with matching documents.
531
546
  * @throws {Error} If the index is not loaded.
532
547
  *
@@ -546,16 +561,18 @@ export declare class MossClient {
546
561
  *
547
562
  * All names must already be loaded (`loadIndex` / `loadIndexes`) and share
548
563
  * 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 and
550
- * returns raw cosine scores, `0.0` is keyword-only, and values in between
551
- * fuse both signals with Reciprocal Rank Fusion. Keyword scoring runs each
552
- * index's own BM25 and merges hits by score before fusion. `options.topK`
553
- * (default 10) caps the merged result, not each index. `options.filter`
554
- * applies uniformly to every index.
564
+ * works exactly as in `query` (default 0.8): `1.0` is embedding-only, `0.0`
565
+ * is keyword-only, and values in between fuse both signals. Every mix returns
566
+ * results in hybrid order with the same relevance `score` as single-index
567
+ * `query`, and `options.minScore` filters on that score. Keyword scoring
568
+ * runs each index's own BM25 and merges hits before fusion. `options.topK`
569
+ * (default 10) caps the merged result, not each index, and 0 returns no
570
+ * results. `options.filter` applies uniformly to every index. A blank
571
+ * `query` with no `options.embedding` returns no results and embeds nothing.
555
572
  *
556
573
  * @param indexNames - Names of the loaded indexes to search.
557
574
  * @param query - The search query text.
558
- * @param options - Optional topK, alpha, embedding, and filter.
575
+ * @param options - Optional topK, alpha, embedding, filter, minScore, and candidateDepth.
559
576
  * @returns SearchResult whose docs carry `indexName`.
560
577
  * @throws {Error} If no names are given, a name is not loaded, or models differ.
561
578
  *
@@ -624,6 +641,21 @@ export declare interface MossClientOptions {
624
641
  identity?: MossIdentity;
625
642
  }
626
643
 
644
+ /**
645
+ * An `Error` with a stable `code`, from the native core or the SDK.
646
+ * A core failure carries fixed text for each kind of failure, and `detail`
647
+ * holds the core error text. An SDK error describes its cause and has no `detail`.
648
+ */
649
+ export declare interface MossError extends Error {
650
+ /** The kind of failure, stable across releases. */
651
+ code: MossErrorCode;
652
+ /** The core error text, for logs and support. Diagnostic text, not a stable contract. */
653
+ detail?: string;
654
+ }
655
+
656
+ /** Stable code on every error the native core or the SDK reports. */
657
+ export declare type MossErrorCode = "INVALID_ARGUMENT" | "NOT_FOUND" | "UNAUTHORIZED" | "NETWORK" | "DESERIALIZATION" | "MODEL_UNAVAILABLE" | "INTERNAL";
658
+
627
659
  /**
628
660
  * Caller-managed stable identity for a MossClient lifetime. Supplied values
629
661
  * must be 1-256 UTF-8 bytes with no leading or trailing whitespace, Unicode
@@ -659,9 +691,9 @@ export declare type MossModel = "moss-minilm" | "moss-mediumlm" | "custom";
659
691
  */
660
692
  export declare interface MutationOptions {
661
693
  /**
662
- * Whether to update existing documents with the same ID.
663
- * Only applies to addDocs.
664
- * @default true
694
+ * Whether a document replaces a stored one with the same ID.
695
+ * `SessionIndex.addDocs` applies it locally and treats an omitted value as `true`.
696
+ * `MossClient.addDocs` sends it only when set, and the cloud service decides how to apply it.
665
697
  */
666
698
  upsert?: boolean;
667
699
  /**
@@ -820,6 +852,12 @@ export declare class SessionIndex {
820
852
  * For `modelId="custom"`, an explicit `options.embedding` is required.
821
853
  * For built-in models the query is embedded locally by the Rust core
822
854
  * on a native worker thread if `options.embedding` is omitted.
855
+ *
856
+ * A blank `query` (empty or only whitespace) with no `options.embedding`
857
+ * returns no results at every `alpha`, without running the embedding model.
858
+ * With an embedding, a blank `query` ranks by the embedding alone.
859
+ * A custom-model session still needs `options.embedding`.
860
+ * `options.topK` defaults to 5, and 0 returns no results.
823
861
  */
824
862
  query(query: string, options?: QueryOptions): Promise<SearchResult>;
825
863
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moss-js/moss",
3
- "version": "1.14.0",
3
+ "version": "1.16.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.29.0"
48
+ "@moss-js/moss-core": "0.31.0"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@eslint/js": "^9.39.4",