bunnyquery 1.18.0 → 1.19.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 +22 -16
- package/bunnyquery.css +14 -0
- package/bunnyquery.js +8818 -7335
- package/dist/engine.cjs +8518 -7380
- package/dist/engine.cjs.map +1 -1
- package/dist/engine.d.mts +458 -193
- package/dist/engine.d.ts +458 -193
- package/dist/engine.mjs +8512 -7381
- package/dist/engine.mjs.map +1 -1
- package/package.json +1 -1
- package/src/engine/config.ts +72 -138
- package/src/engine/duplicates.ts +114 -35
- package/src/engine/findings.ts +305 -0
- package/src/engine/history.ts +27 -2
- package/src/engine/host.ts +25 -1
- package/src/engine/index.ts +15 -1
- package/src/engine/indexing_groups.ts +18 -0
- package/src/engine/prompts/chat_system_prompt.ts +2 -1
- package/src/engine/prompts/indexing_system_prompt.ts +2 -2
- package/src/engine/prompts/indexing_user_message.ts +4 -3
- package/src/engine/requests.ts +57 -3
- package/src/engine/retrieval_memory.ts +11 -0
- package/src/engine/session.ts +859 -83
- package/styles/chat.css +14 -0
package/src/engine/requests.ts
CHANGED
|
@@ -5,9 +5,7 @@
|
|
|
5
5
|
* original are dependency-injection seams:
|
|
6
6
|
* - `skapi.clientSecretRequest*` -> resolveForwardRequest*() in config.ts,
|
|
7
7
|
* which dispatches through the host's
|
|
8
|
-
* `forwardRequest*` keys
|
|
9
|
-
* `clientSecretRequest*` ones a host written
|
|
10
|
-
* before the rename still injects
|
|
8
|
+
* `forwardRequest*` keys (the only ones read)
|
|
11
9
|
* - MCP endpoint URL -> chatEngineConfig().mcpBaseUrl
|
|
12
10
|
* - `poll` on each request -> pollOpt() (set per consumer; see config.ts)
|
|
13
11
|
* - Vue `reactive`/`ref` removed (bgTaskQueue/agentViewMounted are app-level
|
|
@@ -1399,6 +1397,53 @@ export const BG_INDEXING_QUEUE_SUFFIX = '-bg';
|
|
|
1399
1397
|
* fall back to the live-queue probe (fetchLiveIndexingKeys) before reading
|
|
1400
1398
|
* absence as anything.
|
|
1401
1399
|
*/
|
|
1400
|
+
/** What the MCP's /internal/index-reset answered. */
|
|
1401
|
+
export type IndexResetResult = {
|
|
1402
|
+
path: string;
|
|
1403
|
+
/** The access group the old file record had, or null when there was none. */
|
|
1404
|
+
access_group: string | number | null;
|
|
1405
|
+
removed: number;
|
|
1406
|
+
missing: number;
|
|
1407
|
+
failed: number;
|
|
1408
|
+
decorations: number;
|
|
1409
|
+
ambiguous: number;
|
|
1410
|
+
ms?: number;
|
|
1411
|
+
};
|
|
1412
|
+
|
|
1413
|
+
/**
|
|
1414
|
+
* Clear a file's index on the SERVER before a Reindex or an Overwrite (owner,
|
|
1415
|
+
* 2026-11-20): the MCP's /internal/index-reset removes the file record (and, through its
|
|
1416
|
+
* cascade, everything referencing it), the agent's decorated per-window ids and the
|
|
1417
|
+
* done::/run:: markers, in parallel, as the signed-in user. Reached through the host's
|
|
1418
|
+
* forwardRequest with "$ACCESS_TOKEN", which skapi fills in with the caller's own token,
|
|
1419
|
+
* so no client code ever holds it.
|
|
1420
|
+
*
|
|
1421
|
+
* Resolves to the server's answer, or null when the call could not be made or answered
|
|
1422
|
+
* something else (an older MCP without the route, a timeout): the caller then clears
|
|
1423
|
+
* the index itself, as it always did. Never rejects.
|
|
1424
|
+
*/
|
|
1425
|
+
export async function resetFileIndexOnServer(args: { service: string; owner?: string; storagePath: string }): Promise<IndexResetResult | null> {
|
|
1426
|
+
try {
|
|
1427
|
+
const base = String(mcpUrl() || '').replace(/\/+$/, '');
|
|
1428
|
+
if (!base || !args || !args.service || !args.storagePath) return null;
|
|
1429
|
+
const res: any = await forwardRequest({
|
|
1430
|
+
service: args.service,
|
|
1431
|
+
...(args.owner ? { owner: args.owner } : {}),
|
|
1432
|
+
url: base + '/internal/index-reset',
|
|
1433
|
+
method: 'POST',
|
|
1434
|
+
headers: { 'content-type': 'application/json', Authorization: 'Bearer $ACCESS_TOKEN' },
|
|
1435
|
+
data: { project_id: args.service, path: args.storagePath },
|
|
1436
|
+
});
|
|
1437
|
+
const body = typeof res === 'string' ? JSON.parse(res) : res;
|
|
1438
|
+
if (body && typeof body === 'object' && typeof body.removed === 'number' && body.path === args.storagePath) {
|
|
1439
|
+
return body as IndexResetResult;
|
|
1440
|
+
}
|
|
1441
|
+
return null;
|
|
1442
|
+
} catch {
|
|
1443
|
+
return null;
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1402
1447
|
export function indexDoneUniqueId(storagePath: string): string {
|
|
1403
1448
|
return 'done::' + storagePath;
|
|
1404
1449
|
}
|
|
@@ -1510,6 +1555,15 @@ export type BgTaskEntry = {
|
|
|
1510
1555
|
* once everything finishes. Absent for work with no chat turn behind it (the dbfile
|
|
1511
1556
|
* page, an attachment-only send, a worker-adopted pass), which appends as before. */
|
|
1512
1557
|
stageId?: string;
|
|
1558
|
+
/** Settled from the 10-second queue check instead of its own poll (owner, 2026-11-20).
|
|
1559
|
+
* Set by drainBgTaskQueue on every pass when the host has csrHistoryItemLookup, and on
|
|
1560
|
+
* adoption for the worker's lanes. Polls on one queue run one at a time in skapi-js, so
|
|
1561
|
+
* a pass that finished waited behind every pass ahead of it; see
|
|
1562
|
+
* ChatSession._settleByListing. */
|
|
1563
|
+
byListing?: boolean;
|
|
1564
|
+
/** When this client first tracked the pass (ms). A pass missing from a listing taken
|
|
1565
|
+
* BEFORE that proves nothing about it. */
|
|
1566
|
+
adoptedAt?: number;
|
|
1513
1567
|
};
|
|
1514
1568
|
|
|
1515
1569
|
// Token the indexing agent appends to its final message ONLY when it has fully read and
|
|
@@ -146,6 +146,9 @@ function readArguments(note: RetrievalNote, args: any): void {
|
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
/** Collect { path, page } pairs out of a tool RESULT, bounded. */
|
|
149
|
+
/** A JSON string inside a tool result longer than this is not parsed for hits. */
|
|
150
|
+
const RESULT_STRING_MAX_CHARS = 2 * 1024 * 1024;
|
|
151
|
+
|
|
149
152
|
function readHits(note: RetrievalNote, result: any): void {
|
|
150
153
|
var parsed = parseJsonLoose(result);
|
|
151
154
|
if (!parsed || typeof parsed !== 'object') return;
|
|
@@ -164,6 +167,14 @@ function readHits(note: RetrievalNote, result: any): void {
|
|
|
164
167
|
if (!Object.prototype.hasOwnProperty.call(node, k)) continue;
|
|
165
168
|
var v = node[k];
|
|
166
169
|
if (v && typeof v === 'object') walk(v, depth + 1);
|
|
170
|
+
// The MCP's paginated envelope carries the tool's own result as a JSON STRING
|
|
171
|
+
// ({"message": "Response retrieved...", "content": "{\"hits\": [...]}"}), so the
|
|
172
|
+
// hits were never seen and no turn remembered its pages (found 2026-11-20).
|
|
173
|
+
else if (typeof v === 'string' && v.length > 1 && v.length <= RESULT_STRING_MAX_CHARS
|
|
174
|
+
&& (v.charAt(0) === '{' || v.charAt(0) === '[')) {
|
|
175
|
+
var inner = parseJsonLoose(v);
|
|
176
|
+
if (inner && typeof inner === 'object') walk(inner, depth + 1);
|
|
177
|
+
}
|
|
167
178
|
}
|
|
168
179
|
};
|
|
169
180
|
walk(parsed, 0);
|