@harperfast/harper 5.2.10 → 5.2.13
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/dist/resources/Table.d.ts +2 -2
- package/dist/resources/Table.js +182 -61
- package/dist/resources/Table.js.map +1 -1
- package/dist/resources/databases.d.ts +1 -0
- package/dist/resources/databases.js +73 -40
- package/dist/resources/databases.js.map +1 -1
- package/dist/utility/errors/hdbError.d.ts +8 -0
- package/dist/utility/errors/hdbError.js +29 -0
- package/dist/utility/errors/hdbError.js.map +1 -1
- package/npm-shrinkwrap.json +38 -38
- package/package.json +2 -2
- package/resources/Table.ts +177 -62
- package/resources/databases.ts +74 -42
- package/studio/web/assets/{Chat-Br06zdMA.js → Chat-4RrB5134.js} +1 -1
- package/studio/web/assets/{FloatingChat-BWImX5fA.js → FloatingChat-omlNMDcJ.js} +3 -3
- package/studio/web/assets/{apiToken-DN0nmDsq.js → apiToken-Bke3wvfZ.js} +1 -1
- package/studio/web/assets/{applications-kSxVoyeU.js → applications-DvFDYJgK.js} +1 -1
- package/studio/web/assets/{cssMode-C1JeufH5.js → cssMode-C1vRa7zh.js} +1 -1
- package/studio/web/assets/{editor-qoo9CrGO.js → editor-3XRWEDWX.js} +1 -1
- package/studio/web/assets/{html-Dt4IIy04.js → html-CTY5tdMr.js} +1 -1
- package/studio/web/assets/{htmlMode-DXgKKr4C.js → htmlMode-CG1vSD9t.js} +1 -1
- package/studio/web/assets/{index-6onkYFOG.js → index-Dfpeofdu.js} +5 -5
- package/studio/web/assets/{index.lazy-BrCFnpNJ.js → index.lazy-B1VOIv-t.js} +1 -1
- package/studio/web/assets/{javascript-DNCQGUBc.js → javascript-CJeJzGnI.js} +1 -1
- package/studio/web/assets/{jsonMode-CR6HWruP.js → jsonMode-CYPBwM82.js} +1 -1
- package/studio/web/assets/{languageServices-BM4fI4rS.js → languageServices-IKH4GUHl.js} +1 -1
- package/studio/web/assets/{lspLanguageFeatures-DSa1ttcD.js → lspLanguageFeatures-BC8_gxKG.js} +1 -1
- package/studio/web/assets/{notifications-BHXLnh6x.js → notifications-BfKBpYcq.js} +1 -1
- package/studio/web/assets/{notifications-CUmtIA6z.js → notifications-DFbArTfC.js} +1 -1
- package/studio/web/assets/{profile-8BeFSF3j.js → profile-Q4-T6c-S.js} +1 -1
- package/studio/web/assets/{regions-C8qR0HhD.js → regions-CtkV0xje.js} +1 -1
- package/studio/web/assets/{register-B4n5i0SD.js → register-1ZZuMsiA.js} +2 -2
- package/studio/web/assets/{setComponentFile-g0_B0lgX.js → setComponentFile-ZWLcWv5X.js} +1 -1
- package/studio/web/assets/{setup-B0CTj_Q5.js → setup-DWprJyJy.js} +2 -2
- package/studio/web/assets/{status-C6Yib7-K.js → status--aNm8isn.js} +1 -1
- package/studio/web/assets/{toggleHighContrast-Dgta7bVi.js → toggleHighContrast-Cq_lt3XD.js} +1 -1
- package/studio/web/assets/{tsMode-CH_jHvU-.js → tsMode-pjgytARx.js} +1 -1
- package/studio/web/assets/{typescript-Co9LCXd5.js → typescript-Cdg0mqUh.js} +1 -1
- package/studio/web/assets/{useEntityRestURL-wKC8NsC_.js → useEntityRestURL-RZhaY8Rn.js} +1 -1
- package/studio/web/assets/{workers-CWeLxCXA.js → workers-BgoXIqQe.js} +1 -1
- package/studio/web/assets/{xml-BadC-0Rk.js → xml-BwSeDMiP.js} +1 -1
- package/studio/web/assets/{yaml-BiUfxPbC.js → yaml-DotCUG5l.js} +1 -1
- package/studio/web/index.html +1 -1
- package/utility/errors/hdbError.ts +26 -0
package/resources/databases.ts
CHANGED
|
@@ -40,7 +40,6 @@ import { PrimaryRocksDatabase } from './PrimaryRocksDatabase.ts';
|
|
|
40
40
|
import { replayLogs } from './replayLogs.ts';
|
|
41
41
|
import { totalmem } from 'node:os';
|
|
42
42
|
import { RocksIndexStore } from './RocksIndexStore.ts';
|
|
43
|
-
import { when } from '../utility/when.ts';
|
|
44
43
|
import { resolveRocksMemoryConfig } from '../utility/rocksMemoryConfig.ts';
|
|
45
44
|
import { isProcessRunning } from '../utility/processManagement/processManagement.js';
|
|
46
45
|
import {
|
|
@@ -1950,12 +1949,16 @@ export function table<TableResourceType>(tableDefinition: TableDefinition): Tabl
|
|
|
1950
1949
|
const uncertifiedCheckpoint =
|
|
1951
1950
|
attributeDescriptor?.lastIndexedKey !== undefined &&
|
|
1952
1951
|
(attributeDescriptor.checkpointCertified === undefined ||
|
|
1952
|
+
attributeDescriptor.checkpointAlgorithm !== CHECKPOINT_ALGORITHM ||
|
|
1953
1953
|
compareKeys(attributeDescriptor.checkpointCertified, attributeDescriptor.lastIndexedKey) !== 0);
|
|
1954
1954
|
attribute.lastIndexedKey =
|
|
1955
1955
|
indexOptionsChanged || uncertifiedCheckpoint
|
|
1956
1956
|
? undefined
|
|
1957
1957
|
: (attributeDescriptor?.lastIndexedKey ?? undefined);
|
|
1958
|
-
if (attribute.lastIndexedKey !== undefined)
|
|
1958
|
+
if (attribute.lastIndexedKey !== undefined) {
|
|
1959
|
+
attribute.checkpointCertified = attribute.lastIndexedKey;
|
|
1960
|
+
attribute.checkpointAlgorithm = CHECKPOINT_ALGORITHM;
|
|
1961
|
+
}
|
|
1959
1962
|
// Explicit reindex is the upgrade path from a legacy (un-versioned) custom-index
|
|
1960
1963
|
// object store to the versioned, VT-cacheable format. A full rebuild from scratch
|
|
1961
1964
|
// (lastIndexedKey === undefined) clears the store and rewrites every node, so the
|
|
@@ -2015,8 +2018,10 @@ export function table<TableResourceType>(tableDefinition: TableDefinition): Tabl
|
|
|
2015
2018
|
// workers / a reload would treat the still-partial index as ready and return incomplete results.
|
|
2016
2019
|
attribute.indexingPID = attributeDescriptor.indexingPID;
|
|
2017
2020
|
attribute.lastIndexedKey = attributeDescriptor.lastIndexedKey;
|
|
2018
|
-
if (attributeDescriptor.checkpointCertified !== undefined)
|
|
2021
|
+
if (attributeDescriptor.checkpointCertified !== undefined) {
|
|
2019
2022
|
attribute.checkpointCertified = attributeDescriptor.checkpointCertified;
|
|
2023
|
+
attribute.checkpointAlgorithm = attributeDescriptor.checkpointAlgorithm;
|
|
2024
|
+
}
|
|
2020
2025
|
// Carry the in-progress restart generation too, so persisting this metadata-only
|
|
2021
2026
|
// change doesn't drop it and break the crash-recovery trigger for the running backfill.
|
|
2022
2027
|
attribute.restartNumber = attributeDescriptor.restartNumber;
|
|
@@ -2024,6 +2029,10 @@ export function table<TableResourceType>(tableDefinition: TableDefinition): Tabl
|
|
|
2024
2029
|
attribute.indexingBuildId = attributeDescriptor.indexingBuildId;
|
|
2025
2030
|
if (attributeDescriptor.indexingFailed) attribute.indexingFailed = attributeDescriptor.indexingFailed;
|
|
2026
2031
|
}
|
|
2032
|
+
// The declared attribute never carries the stamp, so any rewrite of a descriptor that has
|
|
2033
|
+
// one would drop it and make a completed index look like a pre-stamp build.
|
|
2034
|
+
if (attribute.checkpointAlgorithm === undefined && attributeDescriptor?.checkpointAlgorithm !== undefined)
|
|
2035
|
+
attribute.checkpointAlgorithm = attributeDescriptor.checkpointAlgorithm;
|
|
2027
2036
|
attributesDbi.put(dbiKey, attribute);
|
|
2028
2037
|
}
|
|
2029
2038
|
// If a migration is in progress (indexingPID set), any newly opened dbi must also
|
|
@@ -2122,6 +2131,10 @@ export function canonicalizeIndexOptions(value: any): any {
|
|
|
2122
2131
|
}
|
|
2123
2132
|
return value;
|
|
2124
2133
|
}
|
|
2134
|
+
// Bumped when a change alters which keys a checkpoint may certify. A descriptor stamped by any other
|
|
2135
|
+
// version resumes as uncertified (full rebuild) rather than being trusted, and a completed index keeps
|
|
2136
|
+
// the stamp of the build that wrote it.
|
|
2137
|
+
export const CHECKPOINT_ALGORITHM = 2;
|
|
2125
2138
|
const MAX_OUTSTANDING_INDEXING = 1000;
|
|
2126
2139
|
const MIN_OUTSTANDING_INDEXING = 10;
|
|
2127
2140
|
const INDEXING_YIELD_INTERVAL = 100;
|
|
@@ -2263,9 +2276,43 @@ async function runIndexing(Table, attributes, indicesToRemove) {
|
|
|
2263
2276
|
new SchemaEventMsg(process.pid, 'schema-change', Table.databaseName, Table.tableName)
|
|
2264
2277
|
);
|
|
2265
2278
|
let lastResolution;
|
|
2279
|
+
// The checkpoint and completion barriers have to cover every mutation still in flight: any of them
|
|
2280
|
+
// may reject after those barriers read hadIndexingErrors.
|
|
2281
|
+
const pendingMutations = new Set();
|
|
2282
|
+
let settleWaiter;
|
|
2283
|
+
const track = (result, onRejected) => {
|
|
2284
|
+
if (!result?.then) return result;
|
|
2285
|
+
const tracked = result.then(
|
|
2286
|
+
() => {
|
|
2287
|
+
pendingMutations.delete(tracked);
|
|
2288
|
+
settleWaiter?.();
|
|
2289
|
+
return false;
|
|
2290
|
+
},
|
|
2291
|
+
(error) => {
|
|
2292
|
+
pendingMutations.delete(tracked);
|
|
2293
|
+
settleWaiter?.();
|
|
2294
|
+
onRejected(error);
|
|
2295
|
+
return true;
|
|
2296
|
+
}
|
|
2297
|
+
);
|
|
2298
|
+
pendingMutations.add(tracked);
|
|
2299
|
+
return result;
|
|
2300
|
+
};
|
|
2301
|
+
// The tracked promises absorb their own rejections, so one failure never abandons its siblings.
|
|
2302
|
+
const drainMutations = async () => {
|
|
2303
|
+
if (!pendingMutations.size) return false;
|
|
2304
|
+
return (await Promise.all([...pendingMutations])).some(Boolean);
|
|
2305
|
+
};
|
|
2306
|
+
// Waiting on a chosen entry would stall behind a slow one the others have already overtaken.
|
|
2307
|
+
const nextSettlement = () =>
|
|
2308
|
+
new Promise((resolve) => {
|
|
2309
|
+
settleWaiter = () => {
|
|
2310
|
+
settleWaiter = undefined;
|
|
2311
|
+
resolve(undefined);
|
|
2312
|
+
};
|
|
2313
|
+
});
|
|
2266
2314
|
for (const index of indicesToRemove) {
|
|
2267
|
-
|
|
2268
|
-
if (lastResolution?.then) lastResolution.then(undefined, (error) => onIndexPutRejected(index.name, error));
|
|
2315
|
+
track(index.drop(), (error) => onIndexPutRejected(index.name, error));
|
|
2269
2316
|
}
|
|
2270
2317
|
let interrupted;
|
|
2271
2318
|
let indexed = 0;
|
|
@@ -2276,25 +2323,30 @@ async function runIndexing(Table, attributes, indicesToRemove) {
|
|
|
2276
2323
|
if (start === undefined) {
|
|
2277
2324
|
for (const attribute of attributes) {
|
|
2278
2325
|
if (attribute.dbi.clearAsync) {
|
|
2279
|
-
// LMDB
|
|
2280
|
-
|
|
2326
|
+
// LMDB enqueues this ahead of the index writes, so the scan need not wait for it — but the
|
|
2327
|
+
// barriers must, or a rejected clear certifies a checkpoint over stale entries.
|
|
2328
|
+
track(attribute.dbi.clearAsync(), (error) => onIndexPutRejected(attribute.name, error));
|
|
2281
2329
|
} else {
|
|
2282
2330
|
await attribute.dbi.clear();
|
|
2283
2331
|
}
|
|
2284
2332
|
}
|
|
2285
2333
|
}
|
|
2286
|
-
let outstanding = 0;
|
|
2287
2334
|
// A resumed scan starts at the checkpoint, so it must only name a key whose every predecessor is
|
|
2288
2335
|
// durably indexed: persisted once the writes it covers have settled and flushed, frozen after any
|
|
2289
2336
|
// record fails so the retry re-covers it, and stamped with its own key (see the trigger in table()).
|
|
2290
2337
|
const persistCheckpoint = async (key) => {
|
|
2291
2338
|
if (hadIndexingErrors) return;
|
|
2292
2339
|
try {
|
|
2340
|
+
// Everything still in flight was issued for a key at or before this one: the scan has not
|
|
2341
|
+
// moved past it yet. So a failure among them is a failure this checkpoint would cover.
|
|
2342
|
+
const failed = await drainMutations();
|
|
2343
|
+
if (failed) return;
|
|
2293
2344
|
await flushIndexStores(Table.primaryStore.rootStore);
|
|
2294
2345
|
const puts = [];
|
|
2295
2346
|
for (const attribute of attributes) {
|
|
2296
2347
|
attribute.lastIndexedKey = key;
|
|
2297
2348
|
attribute.checkpointCertified = key;
|
|
2349
|
+
attribute.checkpointAlgorithm = CHECKPOINT_ALGORITHM;
|
|
2298
2350
|
puts.push(Table.dbisDB.put(attribute.key, attribute));
|
|
2299
2351
|
}
|
|
2300
2352
|
await Promise.all(puts);
|
|
@@ -2314,9 +2366,8 @@ async function runIndexing(Table, attributes, indicesToRemove) {
|
|
|
2314
2366
|
const atInterval = ++indexed % INDEXING_YIELD_INTERVAL === 0;
|
|
2315
2367
|
// TODO: Do we ever need to interrupt due to a schema change that was not a restart?
|
|
2316
2368
|
//if (Table.schemaVersion !== schemaVersion) return; // break out if there are any schema changes and let someone else pick it up
|
|
2317
|
-
|
|
2318
|
-
//
|
|
2319
|
-
// outstanding-based yield below never fires for them. Track that this row did synchronous
|
|
2369
|
+
// Custom indexes (e.g. HNSW) index synchronously and leave pendingMutations empty, so the
|
|
2370
|
+
// backpressure yield below never fires for them. Track that this row did synchronous
|
|
2320
2371
|
// indexing work so we can still yield the event loop after it.
|
|
2321
2372
|
let didSynchronousIndexing = false;
|
|
2322
2373
|
// every index operation needs to be guarded by the version still be the same. If it has already changed before
|
|
@@ -2340,8 +2391,7 @@ async function runIndexing(Table, attributes, indicesToRemove) {
|
|
|
2340
2391
|
const values = getIndexedValues(value, index.indexNulls);
|
|
2341
2392
|
if (values) {
|
|
2342
2393
|
for (let i = 0, l = values.length; i < l; i++) {
|
|
2343
|
-
|
|
2344
|
-
if (lastResolution?.then) lastResolution.then(undefined, onPutRejected);
|
|
2394
|
+
track(index.put(values[i], key), onPutRejected);
|
|
2345
2395
|
}
|
|
2346
2396
|
}
|
|
2347
2397
|
} catch (error) {
|
|
@@ -2359,20 +2409,11 @@ async function runIndexing(Table, attributes, indicesToRemove) {
|
|
|
2359
2409
|
}
|
|
2360
2410
|
}
|
|
2361
2411
|
}
|
|
2362
|
-
when(
|
|
2363
|
-
lastResolution,
|
|
2364
|
-
() => outstanding--,
|
|
2365
|
-
() => outstanding--
|
|
2366
|
-
);
|
|
2367
2412
|
if (workerData && workerData.restartNumber !== manageThreads.restartNumber) {
|
|
2368
2413
|
interrupted = true;
|
|
2369
2414
|
}
|
|
2370
2415
|
if (interrupted) {
|
|
2371
|
-
|
|
2372
|
-
await lastResolution;
|
|
2373
|
-
} catch {
|
|
2374
|
-
// already counted and logged by the rejection handler above
|
|
2375
|
-
}
|
|
2416
|
+
await drainMutations();
|
|
2376
2417
|
await checkpointing;
|
|
2377
2418
|
await persistCheckpoint(key);
|
|
2378
2419
|
return;
|
|
@@ -2381,29 +2422,17 @@ async function runIndexing(Table, attributes, indicesToRemove) {
|
|
|
2381
2422
|
nextCheckpointAt = performance.now() + indexingCheckpointPeriodMs;
|
|
2382
2423
|
nextCheckpointRecord = indexed + indexingCheckpointMinRecords;
|
|
2383
2424
|
await checkpointing;
|
|
2384
|
-
checkpointing =
|
|
2385
|
-
lastResolution,
|
|
2386
|
-
() => persistCheckpoint(key),
|
|
2387
|
-
() => {}
|
|
2388
|
-
);
|
|
2425
|
+
checkpointing = persistCheckpoint(key);
|
|
2389
2426
|
}
|
|
2390
|
-
|
|
2391
|
-
|
|
2427
|
+
// Checked once per record, so a record's own fan-out can overshoot before the bound applies.
|
|
2428
|
+
while (pendingMutations.size > MAX_OUTSTANDING_INDEXING) await nextSettlement();
|
|
2429
|
+
if (atInterval || didSynchronousIndexing || pendingMutations.size > MIN_OUTSTANDING_INDEXING)
|
|
2430
|
+
await yieldEventTurn();
|
|
2392
2431
|
}
|
|
2393
2432
|
}
|
|
2394
2433
|
await checkpointing;
|
|
2395
|
-
//
|
|
2396
|
-
|
|
2397
|
-
try {
|
|
2398
|
-
await lastResolution;
|
|
2399
|
-
} catch (error) {
|
|
2400
|
-
hadIndexingErrors = true;
|
|
2401
|
-
logger.error(error);
|
|
2402
|
-
}
|
|
2403
|
-
// Yield one more event turn so any queued when() error callbacks (which fire as
|
|
2404
|
-
// microtasks when their tracked promise settles) have a chance to set hadIndexingErrors
|
|
2405
|
-
// before we decide whether to mark indexing as complete.
|
|
2406
|
-
await new Promise((resolve) => setImmediate(resolve));
|
|
2434
|
+
// A mutation that rejects after completion is declared has no build left to park.
|
|
2435
|
+
await drainMutations();
|
|
2407
2436
|
// the tail since the last checkpoint is not durable until flushed; announcing the index complete
|
|
2408
2437
|
// before that would outlive a crash that loses it
|
|
2409
2438
|
if (!hadIndexingErrors) {
|
|
@@ -2443,6 +2472,9 @@ async function runIndexing(Table, attributes, indicesToRemove) {
|
|
|
2443
2472
|
for (const attribute of attributes) {
|
|
2444
2473
|
delete attribute.lastIndexedKey;
|
|
2445
2474
|
delete attribute.checkpointCertified;
|
|
2475
|
+
// Survives completion, unlike the checkpoint fields: without it an index built here is
|
|
2476
|
+
// indistinguishable from one a release that could skip a failed record declared complete.
|
|
2477
|
+
attribute.checkpointAlgorithm = CHECKPOINT_ALGORITHM;
|
|
2446
2478
|
delete attribute.indexingPID;
|
|
2447
2479
|
delete attribute.indexingFailed;
|
|
2448
2480
|
delete attribute.restartNumber;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{S as n,_ as r,a as i,b as a,c as o,d as s,f as c,g as l,h as u,l as d,m as f,n as p,o as m,p as h,r as g,s as _,t as v,v as y,x as b,y as x}from"./vendor-core-c2JRRJpV.js";import{i as S,t as C}from"./button-BIsUKRZq.js";import{a as ee}from"./vendor-datadog-CLUcJXOo.js";import{r as te}from"./vendor-react-CJV_K1u4.js";import{L as ne,k as re,q as ie,z as ae}from"./vendor-tanstack-DxzraizX.js";import{n as oe}from"./setSessionStorage-B0bf71m4.js";import{It as se}from"./vendor-ui-BUjK0h8a.js";import{t as w}from"./createLucideIcon-CzW9508A.js";import{n as ce,r as le,t as ue}from"./chevron-up-DtKGqDn3.js";import{c as de,f as fe,g as pe,h as me,i as he,l as ge,m as _e,p as ve,r as ye,t as be,u as xe}from"./setComponentFile-
|
|
1
|
+
import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{S as n,_ as r,a as i,b as a,c as o,d as s,f as c,g as l,h as u,l as d,m as f,n as p,o as m,p as h,r as g,s as _,t as v,v as y,x as b,y as x}from"./vendor-core-c2JRRJpV.js";import{i as S,t as C}from"./button-BIsUKRZq.js";import{a as ee}from"./vendor-datadog-CLUcJXOo.js";import{r as te}from"./vendor-react-CJV_K1u4.js";import{L as ne,k as re,q as ie,z as ae}from"./vendor-tanstack-DxzraizX.js";import{n as oe}from"./setSessionStorage-B0bf71m4.js";import{It as se}from"./vendor-ui-BUjK0h8a.js";import{t as w}from"./createLucideIcon-CzW9508A.js";import{n as ce,r as le,t as ue}from"./chevron-up-DtKGqDn3.js";import{c as de,f as fe,g as pe,h as me,i as he,l as ge,m as _e,p as ve,r as ye,t as be,u as xe}from"./setComponentFile-ZWLcWv5X.js";import{t as Se}from"./x-DIzaLEdK.js";import{n as Ce}from"./setLocalStorage-D_kflv4U.js";import{t as we}from"./useLocalStorage-BqMR3D8_.js";import{An as Te,Dr as Ee,En as De,H as Oe,It as ke,Mr as Ae,Mt as je,Nt as Me,Or as Ne,Pt as Pe,Tr as Fe,V as Ie,Z as Le,br as Re,c as ze,cr as Be,d as Ve,f as He,fr as Ue,ft as We,hr as Ge,in as Ke,m as qe,or as Je,ur as Ye,ut as Xe,yr as Ze,yt as Qe}from"./index-Dfpeofdu.js";import{t as $e}from"./useEntityRestURL-RZhaY8Rn.js";import{n as et,t as tt}from"./FloatingChat-omlNMDcJ.js";import{n as nt}from"./getAnalytics-GHK8ORfM.js";var rt=w(`between-horizontal-start`,[[`rect`,{width:`13`,height:`7`,x:`8`,y:`3`,rx:`1`,key:`pkso9a`}],[`path`,{d:`m2 9 3 3-3 3`,key:`1agib5`}],[`rect`,{width:`13`,height:`7`,x:`8`,y:`14`,rx:`1`,key:`1q5fc1`}]]),it=w(`book`,[[`path`,{d:`M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20`,key:`k3hazp`}]]),at=w(`chart-area`,[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M7 11.207a.5.5 0 0 1 .146-.353l2-2a.5.5 0 0 1 .708 0l3.292 3.292a.5.5 0 0 0 .708 0l4.292-4.292a.5.5 0 0 1 .854.353V16a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1z`,key:`q0gr47`}]]),ot=w(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),st=w(`file-pen`,[[`path`,{d:`M12.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v9.34`,key:`o6klzx`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10.378 12.622a1 1 0 0 1 3 3.003L8.36 20.637a2 2 0 0 1-.854.506l-2.867.837a.5.5 0 0 1-.62-.62l.836-2.869a2 2 0 0 1 .506-.853z`,key:`zhnas1`}]]),ct=w(`logs`,[[`path`,{d:`M3 5h1`,key:`1mv5vm`}],[`path`,{d:`M3 12h1`,key:`lp3yf2`}],[`path`,{d:`M3 19h1`,key:`w6f3n9`}],[`path`,{d:`M8 5h1`,key:`1nxr5w`}],[`path`,{d:`M8 12h1`,key:`1con00`}],[`path`,{d:`M8 19h1`,key:`k7p10e`}],[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}]]),lt=w(`message-square-heart`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7.5 9.5c0 .687.265 1.383.697 1.844l3.009 3.264a1.14 1.14 0 0 0 .407.314 1 1 0 0 0 .783-.004 1.14 1.14 0 0 0 .398-.31l3.008-3.264A2.77 2.77 0 0 0 16.5 9.5 2.5 2.5 0 0 0 12 8a2.5 2.5 0 0 0-4.5 1.5`,key:`1faxuh`}]]),ut=w(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),dt=w(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]);async function ft(){await S.delete(`/Chat/Messages/`)}var T=e(ee(),1),E=te();function pt({setMessages:e}){let[t,n]=(0,T.useState)(!1),r=(0,T.useCallback)(async()=>{if(!t){n(!0);try{await ft(),e([])}catch(e){console.error(`Failed to clear chat:`,e)}finally{n(!1)}}},[t,e]);return(0,E.jsxs)(`button`,{type:`button`,className:`clear-chat-button gap-1`,onClick:r,disabled:t,title:`Clear chat`,children:[t?(0,E.jsx)(Ze,{className:`animate-spin`,size:18}):(0,E.jsx)(Ye,{size:18}),`Clear`]})}async function mt(){let{data:e}=await S.get(`/Chat/Messages/`);return e}var ht=`vercel.ai.error`,gt=Symbol.for(ht),_t,vt,D=class e extends (vt=Error,_t=gt,vt){constructor({name:e,message:t,cause:n}){super(t),this[_t]=!0,this.name=e,this.cause=n}static isInstance(t){return e.hasMarker(t,ht)}static hasMarker(e,t){let n=Symbol.for(t);return typeof e==`object`&&!!e&&n in e&&typeof e[n]==`boolean`&&e[n]===!0}};function yt(e){return e==null?`unknown error`:typeof e==`string`?e:e instanceof Error?e.toString():JSON.stringify(e)}var bt=`AI_InvalidArgumentError`,xt=`vercel.ai.error.${bt}`,St=Symbol.for(xt),Ct,wt,Tt=class extends (wt=D,Ct=St,wt){constructor({message:e,cause:t,argument:n}){super({name:bt,message:e,cause:t}),this[Ct]=!0,this.argument=n}static isInstance(e){return D.hasMarker(e,xt)}},Et=`AI_JSONParseError`,Dt=`vercel.ai.error.${Et}`,Ot=Symbol.for(Dt),kt,At,jt=class extends (At=D,kt=Ot,At){constructor({text:e,cause:t}){super({name:Et,message:`JSON parsing failed: Text: ${e}.
|
|
2
2
|
Error message: ${yt(t)}`,cause:t}),this[kt]=!0,this.text=e}static isInstance(e){return D.hasMarker(e,Dt)}},Mt=`AI_TypeValidationError`,Nt=`vercel.ai.error.${Mt}`,Pt=Symbol.for(Nt),Ft,It,O=class e extends (It=D,Ft=Pt,It){constructor({value:e,cause:t,context:n}){let r=`Type validation failed`;if(n?.field&&(r+=` for ${n.field}`),n?.entityName||n?.entityId){r+=` (`;let e=[];n.entityName&&e.push(n.entityName),n.entityId&&e.push(`id: "${n.entityId}"`),r+=e.join(`, `),r+=`)`}super({name:Mt,message:`${r}: Value: ${JSON.stringify(e)}.
|
|
3
3
|
Error message: ${yt(t)}`,cause:t}),this[Ft]=!0,this.value=e,this.context=n}static isInstance(e){return D.hasMarker(e,Nt)}static wrap({value:t,cause:n,context:r}){return e.isInstance(n)&&n.value===t&&n.context?.field===r?.field&&n.context?.entityName===r?.entityName&&n.context?.entityId===r?.entityId?n:new e({value:t,cause:n,context:r})}},Lt=class extends Error{constructor(e,t){super(e),this.name=`ParseError`,this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}},Rt=10,zt=13,k=32;function Bt(e){}function Vt(e){if(typeof e==`function`)throw TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");let{onEvent:t=Bt,onError:n=Bt,onRetry:r=Bt,onComment:i,maxBufferSize:a}=e,o=[],s=0,c=!0,l,u=``,d=0,f,p=!1;function m(e){if(p)throw Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(c&&(c=!1,e.charCodeAt(0)===239&&e.charCodeAt(1)===187&&e.charCodeAt(2)===191&&(e=e.slice(3))),o.length===0){let t=g(e);t!==``&&(o.push(t),s=t.length),h();return}if(e.indexOf(`
|
|
4
4
|
`)===-1&&e.indexOf(`\r`)===-1){o.push(e),s+=e.length,h();return}o.push(e);let t=o.join(``);o.length=0,s=0;let n=g(t);n!==``&&(o.push(n),s=n.length),h()}function h(){a!==void 0&&(s+u.length<=a||(p=!0,o.length=0,s=0,l=void 0,u=``,d=0,f=void 0,n(new Lt(`Buffered data exceeded max buffer size of ${a} characters`,{type:`max-buffer-size-exceeded`}))))}function g(e){let n=0;if(e.indexOf(`\r`)===-1){let r=e.indexOf(`
|