bunnyquery 1.21.0 → 1.21.3
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 -6
- package/bunnyquery.js +118 -34
- package/dist/engine.cjs +106 -28
- package/dist/engine.cjs.map +1 -1
- package/dist/engine.d.mts +26 -2
- package/dist/engine.d.ts +26 -2
- package/dist/engine.mjs +106 -28
- package/dist/engine.mjs.map +1 -1
- package/package.json +1 -1
- package/src/engine/citations.ts +12 -0
- package/src/engine/config.ts +16 -2
- package/src/engine/prompts/chat_system_prompt.ts +3 -3
- package/src/engine/prompts/indexing_system_prompt.ts +3 -3
- package/src/engine/prompts/indexing_user_message.ts +20 -0
- package/src/engine/requests.ts +39 -2
- package/src/engine/retrieval_memory.ts +21 -6
- package/src/engine/session.ts +42 -9
package/README.md
CHANGED
|
@@ -165,10 +165,11 @@ Mounts the widget. Returns the `BunnyQuery` object.
|
|
|
165
165
|
| `hostDomain` | `string` | `null` | db-CDN host for temporary file URLs. Defaults to `skapi.app` (dev) / `skapi.com` (prod). |
|
|
166
166
|
| `attachmentParsers` | `array` | `null` | Client-side attachment parsers. See [Attachment parser plugins](#attachment-parser-plugins). |
|
|
167
167
|
| `windowedIndexing` | `boolean` | `true` | Server-driven windowed indexing for text and grid files (see [file types](#supported-file-types)). Pass `false` to fall back to agent-driven paging, which keeps the traversal inside the model's turn budget and the tab open. |
|
|
168
|
+
| `workerIndexEndings` | `boolean` | `false` | The worker writes the ending (done marker, run status) of a file read in one pass, such as an image, so closing or opening a page mid-pass cannot leave it 'working' or mark it "the page was closed". Turn on only once the skapi workers in your region carry the 2026-11-25 change. |
|
|
168
169
|
| `allowAnonymous` | `boolean` | `null` | Open the chat with no login for visitors without an account. `null` follows the project's own "Allow anonymous users" setting (`getConnectionInfo().conf.require_login`); `true`/`false` pins it. |
|
|
169
170
|
| `webAccess` | `boolean` | `null` | Whether the chat's answers may reach the open web (Claude `web_fetch`, OpenAI `web_search`). The project's own **Web access for answers** switch on its Project Settings page (the `web_access` key of the project's `bq::settings` record, **off** unless the owner turned it on) is the **ceiling**, and this option may only restrict below it: `effective = projectSetting && webAccess !== false`. `null` or `true` follows the project; `false` turns the web off for this page whatever the project says; a value above the project setting has no effect. With the web off, answers come only from the project's files and database. Indexing is not affected. |
|
|
170
171
|
| `skipDuplicateFiles` | `boolean` | `null` | Whether a chat attachment the signed-in user **already uploaded** to this project (same stored file name, same size in bytes, same uploader, found from the file's `src::` record, and a stored copy that finished indexing or is still being indexed) is skipped: it is neither uploaded nor indexed again, the chip reads "already uploaded", and the message uses the stored copy's url. The project's **Skip duplicate files** setting (the `skip_duplicate_files` key of `bq::settings`, **on** unless the owner turned it off) is the **ceiling**, and this option may only restrict below it: `effective = projectSetting && skipDuplicateFiles !== false`. `null` or `true` follows the project; `false` lets this page re-upload duplicates; a value above the project setting has no effect. A stored copy whose indexing failed or was cancelled is not a duplicate, so the file uploads as usual. The check never blocks an upload: a failed lookup, or one slower than 15 seconds, uploads as usual. |
|
|
171
|
-
| `reuseMcpToolList` | `boolean` | `
|
|
172
|
+
| `reuseMcpToolList` | `boolean` | `true` | OpenAI chat turns only: reuse the MCP tool listing OpenAI returned on an earlier turn of this page, so OpenAI does not fetch it again (about 0.6 s per turn). On unless `false`. Each reused turn's request and stored history row is about 31 to 34 KB larger. See `reuseMcpToolList` under `configureChatEngine`. |
|
|
172
173
|
| `liveStreaming` | `boolean` | `false` | Deliver the streamed reply over skapi's websocket as well as the poll, so each piece lands the moment the server relays it instead of on the next one-second poll tick. Streaming itself is not an option: the widget streams every reply whenever the page's `skapi-js` can carry skapi's half of the stream flag (it checks for `forwardRequestStream` and `forwardRequestFinalize`), and otherwise warns once and buffers. Off unless you ask for it: skapi's `joinRealtime` **replaces** the connection's group, so for the length of a turn it takes the room out from under whatever else your app uses realtime for. Purely an accelerator; with it off the reply still streams, on the poll's cadence. Before 1.16.0 this key meant "stream at all" and the socket was `liveStreamingRealtime`; that name is now ignored. |
|
|
173
174
|
| `statusPush` | `boolean` | `false` | Indexing status over skapi's websocket: each indexing pass asks the server for status messages, its poll then reads once a minute while they arrive and at once when one names it, and the chat re-reads its history when the socket reconnects. Off unless you ask for it, because it keeps a websocket open on your page's skapi instance (your own realtime callback never sees these messages). Needs skapi-js 2.5.0 or newer; with an older one it stays off. Purely an accelerator: every status on screen still comes from reading the request. |
|
|
174
175
|
|
|
@@ -246,6 +247,14 @@ picture** and **reads any text in it (OCR)**. Works on both Claude and OpenAI.
|
|
|
246
247
|
Only images referenced in the **most recent** message are inlined (older links
|
|
247
248
|
may have expired).
|
|
248
249
|
|
|
250
|
+
When an image file is indexed, the model transcribes every character at whatever
|
|
251
|
+
angle it sits and reports how the text is turned (`text_rotation`). With the
|
|
252
|
+
2026-11-25 skapi worker, a photo whose orientation tag or format the AI would
|
|
253
|
+
misread (a sideways phone photo, a `.tif` or `.bmp` scan) goes out as an upright
|
|
254
|
+
converted copy, a photo whose text is still turned gets one second look turned
|
|
255
|
+
upright, and the transcription is stored as the file's page text, so a search for
|
|
256
|
+
a serial or part number finds the photo. This applies to new and re-indexed files.
|
|
257
|
+
|
|
249
258
|
### 2. PDFs: text pages as text, the rest as page images
|
|
250
259
|
|
|
251
260
|
`.pdf`
|
|
@@ -272,7 +281,7 @@ search it for an exact phrase or number and cite the page.
|
|
|
272
281
|
|
|
273
282
|
```
|
|
274
283
|
.xls .xlsx .xlsm grids: rows stored by the server directly, plus embedded photos
|
|
275
|
-
.ods OpenDocument sheets:
|
|
284
|
+
.ods OpenDocument sheets: rows stored by the server, like .xlsx
|
|
276
285
|
.csv .tsv .tab row-bounded windows with absolute row numbers
|
|
277
286
|
.doc .docx .docm word processor documents
|
|
278
287
|
.ppt .pptx .pptm slide decks
|
|
@@ -305,6 +314,12 @@ one record per row itself, with no model call and no tokens spent on the rows.
|
|
|
305
314
|
Word, text and e-mail windows are read in parallel lanes like PDF pages, and a
|
|
306
315
|
project indexes up to three documents at once.
|
|
307
316
|
|
|
317
|
+
A document whose pages are pictures (a scanned `.hwpx`, `.hwp`, `.docx`, `.pptx`,
|
|
318
|
+
`.odt` and so on, with no text or only a title) is read like a scanned PDF: with
|
|
319
|
+
the 2026-11-25 skapi worker, each page-sized picture is shown to the model as a
|
|
320
|
+
page, and its transcription is stored as that page's text. This applies to new and
|
|
321
|
+
re-indexed files.
|
|
322
|
+
|
|
308
323
|
### 4. Everything else extractable: inlined as text server-side
|
|
309
324
|
|
|
310
325
|
The skapi proxy downloads the file, extracts its text **server-side**, and
|
|
@@ -534,9 +549,10 @@ helpers. See the `.d.ts` shipped with `bunnyquery/engine`.
|
|
|
534
549
|
| `poll` | `number?` | Value attached as `poll` on every request. Omit it if your `forwardRequest` already resolves with the final body; pass `0` for the deployed `skapi-js@latest` (needed for the early ack + a manual `.poll()` handle that powers queued-send cancel, the widget's case). |
|
|
535
550
|
| `attachmentParsers` | `array?` | Client-side attachment parsers, registered at configure time. More can be added later with `registerAttachmentParser()`. See [Attachment parser plugins](#attachment-parser-plugins). |
|
|
536
551
|
| `windowedIndexing` | `boolean?` | Opt in to **server-driven** windowed indexing for text and grid files (see [file types](#supported-file-types)). Off by default in the engine; the widget passes it as `true`. The deployed skapi workers support it; only leave it off against a self-hosted worker that does not yet strip the `_skapi_window` directive, where it would reach the provider as an unknown body field and fail the call terminally with no retry. |
|
|
552
|
+
| `workerIndexEndings` | `boolean?` | The worker writes the done marker and run status of a single-pass indexing file (an image, or any file not rendered, windowed or paged), and the engine no longer marks such a run "Indexing stopped ... (the page was closed)". The engine always sends the request flag (`index_end` on the file's `_skapi_file_urls` entry; older workers ignore it); this switch only stops the client-side "lost" verdict. Off unless `true`: with a worker that predates it, a page closed mid-pass would leave the run 'working'. bunnyquery.com turns it on. |
|
|
537
553
|
| `webAccess` | `boolean?` | Whether a chat turn may reach the open web: Claude's `web_fetch` and OpenAI's `web_search` are attached to a chat request only when this resolves to `true`. The project's own `web_access` setting (the `bq::settings` record, read through `configureProjectSettings`; **off** unless the project owner turned it on) is the **ceiling** and this option may only restrict below it: `effective = projectSetting && webAccess !== false`. Leave it out or pass `true` to follow the project; `false` turns the web off for your host; a value above the project setting has no effect. `webAccessEnabled(serviceId)` and `resolveWebAccess(serviceId, override?)` answer the resolved switch (sync from the cache, or awaiting the settings fetch; `override` is a per-call host value that restricts the same way). Indexing passes keep their tools regardless. Pass the same value to `buildChatSystemPrompt({ webAccess })` so the prompt matches the tool list. |
|
|
538
554
|
| `skipDuplicateFiles` | `boolean?` | Whether an attachment the signed-in user already uploaded to the project (same stored name, same size, same uploader) is skipped by `ChatSession`'s upload path: not uploaded, not indexed, the turn using the stored copy's url. The project's `skip_duplicate_files` setting (**on** unless the owner turned it off) is the **ceiling** and this option may only restrict: `effective = projectSetting && skipDuplicateFiles !== false`. The check runs only when the host implements the optional `findDuplicateUpload(file)` hook; `findDuplicateUpload(skapi, { name, size }, userId, { service?, timeoutMs? })` from the barrel is the ready-made implementation, and bunnyquery.com uses it too: an ends-with `getUniqueId` lookup narrowed to `src::<name>` and `src::.../<name>`, then the first record whose `data.size_bytes` and `user_id` match AND whose stored copy finished indexing (`done::<path>` exists) or is still being indexed (its `run::<path>` record is `working` and started less than `RUN_RECORD_WORKING_STALE_MS`, 6 hours, ago). The match carries `indexing: 'done' | 'running'`. A copy whose indexing failed or was cancelled is not a match. It never throws and answers within `timeoutMs` (default `DUPLICATE_LOOKUP_TIMEOUT_MS`, 15 seconds): a failed or slow lookup answers `null` and the file uploads as usual. `skipDuplicateFilesEnabled(serviceId)` and `resolveSkipDuplicateFiles(serviceId)` answer the resolved switch. |
|
|
539
|
-
| `reuseMcpToolList` | `boolean?` | OpenAI chat turns sent by `ChatSession` only: keep the `mcp_list_tools` item a response returned and send it in the next turn's `input`, so OpenAI skips the MCP tool handshake (about 0.6 s). **Off** unless `true
|
|
555
|
+
| `reuseMcpToolList` | `boolean?` | OpenAI chat turns sent by `ChatSession` only: keep the `mcp_list_tools` item a response returned and send it in the next turn's `input`, so OpenAI skips the MCP tool handshake (about 0.6 s). **Off** unless `true` (the widget and bunnyquery.com turn it on; verified live on an OpenAI project 2026-11-25). Details and costs under "MCP tool listing reuse" below. |
|
|
540
556
|
| `forwardRequestFinalize` | `function?` | `skapi.forwardRequestFinalize`, bound to your Skapi instance. Stores the version of a streamed turn that history keeps (the engine sends the assembled provider body, so it reads back exactly like a buffered turn) and releases that request's chunks. Without it a streamed turn is never finalized and its row stays empty. Together with `forwardRequestStream` it is what turns streaming on. |
|
|
541
557
|
| `forwardRequestStream` | `function?` | `skapi.forwardRequestStream`, bound to your Skapi instance. The **second half of the durability guarantee**: a row that settles while no poll is attached (closed tab, discarded background tab, slept device) is never finalized, so its answer stays in the chunk store and its history row is terminal and empty. Given the request id this drains that turn's chunks in one pass; the engine parses them exactly as it parses a live stream and finalizes what it read, so each row is recovered at most once. Without it the engine mints no recovery marker at all, and without the pair the engine does not stream. |
|
|
542
558
|
| `onLiveStreamUpdate` | `function?` | Observation hook for a streaming turn (`{ serverItemId, ownerKey, phase, text, thinkingText, toolNames, complete, errored }`). The engine already paints the answer text itself, so this is only for affordances it does not decide the presentation of. Never throw from it. |
|
|
@@ -575,12 +591,12 @@ Mythos) and only on chat turns, never on indexing passes. The barrel exports
|
|
|
575
591
|
`normalizeAnswerMode`, `answerModeFrom`, `projectAnswerMode(serviceId)`,
|
|
576
592
|
`resolveAnswerMode(serviceId)` and `chatEffortFields(platform, model, mode)`.
|
|
577
593
|
|
|
578
|
-
**MCP tool listing reuse (OpenAI, off by default).** With `reuseMcpToolList: true` in
|
|
594
|
+
**MCP tool listing reuse (OpenAI, off by default in the engine, on in the widget).** With `reuseMcpToolList: true` in
|
|
579
595
|
`configureChatEngine`, on an OpenAI chat turn sent by `ChatSession` the engine keeps the
|
|
580
596
|
`mcp_list_tools` item the response returned and puts it in the next turn's `input`, right
|
|
581
597
|
after the system message, so OpenAI does not ask the MCP server for its tools again (four
|
|
582
|
-
requests, about 0.6 s).
|
|
583
|
-
|
|
598
|
+
requests, about 0.6 s). Verified on a live OpenAI chat on 2026-11-25: the next turn sent only
|
|
599
|
+
`initialize` before its first tool call. The item is kept in memory only, per exact MCP server URL, signed-in
|
|
584
600
|
or anonymous, project and user; a page reload starts empty. If a turn that carried it
|
|
585
601
|
fails, the entry is dropped and the turn is not retried (its error shows as usual). An
|
|
586
602
|
error that names the item turns reuse off for that project in this browser (localStorage);
|
package/bunnyquery.js
CHANGED
|
@@ -220,6 +220,9 @@
|
|
|
220
220
|
function windowedIndexingEnabled() {
|
|
221
221
|
return _config?.windowedIndexing === true;
|
|
222
222
|
}
|
|
223
|
+
function workerIndexEndingsEnabled() {
|
|
224
|
+
return _config?.workerIndexEndings === true;
|
|
225
|
+
}
|
|
223
226
|
function statusPushEnabled() {
|
|
224
227
|
return _config?.statusPush === true && typeof _config?.onRequestStatus === "function";
|
|
225
228
|
}
|
|
@@ -998,8 +1001,8 @@ WHEN THE DATA DOES NOT HAVE IT, SAY SO. Once you have searched the way these rul
|
|
|
998
1001
|
KEEP WHAT THE DATA SAYS APART FROM WHAT YOU WORKED OUT. A total you computed, a comparison, a trend, an interpretation or a recommendation is yours, not the data's: label it as such ("calculated from...", "this suggests...") and name the rows or files it was made from. Never present an estimate, an assumption or an inference as something the data states.
|
|
999
1002
|
These three rules govern every claim about the project's data. They do not limit the About BunnyQuery section (answer product questions from it), a greeting, or text the user explicitly asks you to write.`;
|
|
1000
1003
|
const webRule = webAccess ? `WEB ACCESS IS ON for this project: when the user asks for something that is not in the project's data, you may search the web for it, but every such fact must be marked as coming from the web (name the site), kept apart from what the project's data says, and never used to fill in or complete a document's content or a record. This is the one exception to the four sources named above.` : `This chat has no web tool: the web is never a source here.`;
|
|
1001
|
-
const documentRules = `DOCUMENTS (a contract, a report, a manual, a letter, any uploaded file the user asks about the content of):
|
|
1002
|
-
WRONG ANSWER: when the user says an answer is wrong (or sends "This answer seems wrong. Please check it again against the documents."), re-read the pages you cited and search again, passing searchText "question" = the user's ORIGINAL question that the disputed answer answered, never the complaint message itself. Then do exactly one of: correct the answer only; correct the answer and call correctSearchLink (when it is among your tools); or keep the answer and quote the text that supports it. Call correctSearchLink only with the page and an exact quote that prove it, and never change data on the user's word alone.`;
|
|
1004
|
+
const documentRules = `DOCUMENTS (a contract, a report, a manual, a letter, any uploaded file the user asks about the content of): when the user NAMED a file (its file name; a document title, a quote or a code they mention is NOT a file name: searchText finds those inside the files), first find its storage path by its "src::" record (see WHERE INDEXED CONTENT LIVES) using the name the user used, then find the page with searchText and that path. A spreadsheet's sheets are page text too: a hit names its sheet and rows, and the row itself is a record (its unique_id is the hit's row_id_prefix plus the row number); a spreadsheet indexed before 2026-11-25 has no page text, so read its rows instead (readFileContent, or its records). When they did not name a file, your FIRST call is searchText without a path: no table list, no file lookup before it. Never list or look up files (getUniqueId on "src::") to find out whether a document, quote or title exists before searching: searchText's hits name the file, and a search that finds nothing says what it could not cover. Either way follow searchText's description to the end, including asking the user once, after quick results, before it searches all files. QUOTE THE EXACT TEXT it returned and CITE THE FILE AND THE PAGE ("report.pdf, page 7"), or for a hit with "sheet" THE FILE AND THE SHEET ("quote.xlsx, sheet \uCD1D\uAD04"), never a sheet page's number; never present a paraphrase as a quote. A file with no page text is read with readFileContent instead and cited by its file name. In a long file (a manual, a book), when a search of the whole file gives too many hits or none that fit, call getFileOutline and search the chapter that fits with searchText page_from and page_to. When the user asks about the content of the documents, pass searchText "question": that question in the user's own words, without names or personal details that are not about the documents. Leave "question" out for anything else.
|
|
1005
|
+
WRONG ANSWER: when the user says an answer is wrong (or sends "This answer seems wrong. Please check it again against the documents."), re-read the pages you cited (for a sheet hit, the rows: by its row_id_prefix, never readFileContent on a sheet page) and search again, passing searchText "question" = the user's ORIGINAL question that the disputed answer answered, never the complaint message itself. Then do exactly one of: correct the answer only; correct the answer and call correctSearchLink (when it is among your tools); or keep the answer and quote the text that supports it. Call correctSearchLink only with the page and an exact quote that prove it, and never change data on the user's word alone.`;
|
|
1003
1006
|
const groupIsPublic = indexGroupLiteral === '"public"' || indexGroupLiteral === "0";
|
|
1004
1007
|
const accessGroupRule = `THIS PROJECT INDEXES AT access_group ${indexGroupLiteral}: pass access_group ${indexGroupLiteral} EXPLICITLY on EVERY query that names a table_name, whether it filters by index, by tag or by nothing, and never rely on a default: a group left off is NOT "all groups", and any user but the project's owner is then answered from access_group 0 (public) alone${groupIsPublic ? "" : `, so a table indexed at ${indexGroupLiteral} would look empty with its records sitting right there`}. Files uploaded before the project's setting changed may sit at another group, so when a table query comes back empty, retry it in the other groups among 0, 1 and "private" before concluding there is nothing. Reference is the exception: reference ALONE spans EVERY table and EVERY access group, so getRecords with reference "src::<the file's storage path>" is the one call that returns a whole file's records wherever the indexer put them; adding table_name narrows it to that table, and access_group WITHOUT table_name fails.`;
|
|
1005
1008
|
let systemPrompt = `
|
|
@@ -1008,7 +1011,7 @@ Scope: Only answer questions about this project and its data. Do not answer ques
|
|
|
1008
1011
|
Knowledge lookup: before saying you don't know, or that something isn't in the chat history, ALWAYS search this project's data with the tools: the project's data lives in its database, not in the earlier messages of this chat.
|
|
1009
1012
|
${groundingRules}
|
|
1010
1013
|
${webRule}
|
|
1011
|
-
FINDING THE DATA: the database is the way in, for every kind of file.
|
|
1014
|
+
FINDING THE DATA: the database is the way in, for every kind of file. A question about what the documents SAY (a procedure, a passage, a definition, how to fix or do something), or one that names a code, a number or a phrase to find (a quote no., a part no., a name), starts with searchText (DOCUMENTS below), not with getTables: the sheets of spreadsheets are in page text too. searchText finds WHICH file, sheet and row holds a value; a total, count or list over rows is still computed from the full row set (NUMBERS FROM A SPREADSHEET below). Everything else (numbers, rows, records, lists, counts, files) follows the search path in getTables' description, with one exception for this project: when getTables' one page is the whole list (end_of_list true), skip its table-name search even when no name fits: you already see every table, and a table is never named after a company, a person or a single fact, so when no table fits, the answer is in a document's text: use searchText (DOCUMENTS below). Pick EVERY table that could hold the answer, not the first that fits. Read getIndexes and getTags one page each, never with fetch_all: name and tag lists can be millions of characters long and are never read whole, so when the name is not on that page, search for it with the user's words as their descriptions say. Never call getTags with neither table_name nor tag: that lists every tag of every table. Then getRecords in that table and group with the selector that matched (an index, one exact tag, or none for the whole table), always with fetch_all true. WHERE INDEXED CONTENT LIVES: a document's extracted content (PDF, Word, slides, scans) is in table "document_entries", one record per row / entry / section, with its page in "page"; spreadsheet rows are in "spreadsheet_rows". Files indexed before 2026-11-20 may still hold theirs in other tables, so a file's records are found wherever they are with getRecords reference "src::<path>" (see the access group rule below); every later mention of a file's records means this call. Every stored file has a record whose unique_id is "src::<its storage path>", so getUniqueId with unique_id "src::" and condition "gte" lists every file across every table (add the start of a path to narrow it; condition "lte" with a file name alone finds it in any folder).
|
|
1012
1015
|
NUMBERS FROM A SPREADSHEET are computed from the ROWS, never from one page and never from a guess. Each row of each sheet is one record in its table: reference "src::<path>", unique_id "row::<path>#<sheet>#R<n>", the cells by header name, plus "_sheet", "_row", "_grain" ("detail" or "summary") and, on a total or preamble row, "_row_type". Its tags carry the file name, the sheet, the grain and up to four key values of the row (a name, a code), so getRecords with one exact tag selects every row about that thing across all the files in the table. Workbooks state the same money more than once: a detail sheet, then per-song, per-album and per-artist sheets that re-total it, plus a summary. Use rows whose "_grain" is "detail" and whose "_row_type" is not "total", pick ONE sheet per file and say which, and never add a sheet to its summary. Fetch the COMPLETE matching set, keep only the rows whose column or tag names what was asked, then add them up carefully, in groups, and check that the group sums agree with the grand total. A FILE TOTAL IS NOT A ROW'S TOTAL: the biggest number on a summary sheet is the whole file, not the thing asked about, so check every figure is scoped to what the question named (filter by the column that identifies it). Quote the row count, the sheet(s) and the file(s) the figure was made from and label it as calculated.
|
|
1013
1016
|
${documentRules}
|
|
1014
1017
|
${accessGroupRule}
|
|
@@ -1058,13 +1061,13 @@ Project description: """${serviceDescription}"""`;
|
|
|
1058
1061
|
const { projectId, serviceName, serviceDescription } = params;
|
|
1059
1062
|
const accessGroup = params.accessGroup === "public" || params.accessGroup === "private" ? params.accessGroup : "authorized";
|
|
1060
1063
|
let systemPrompt = `You are a background indexing agent for project ${projectId}.
|
|
1061
|
-
- Image files (.jpg, .jpeg, .png, .gif, .webp) are ALREADY attached inline as image content blocks in the same message: look at them directly, and never fetch an image URL.
|
|
1064
|
+
- Image files (.jpg, .jpeg, .png, .gif, .webp) are ALREADY attached inline as image content blocks in the same message: look at them directly, and never fetch an image URL. Any other image file (.tif, .tiff, .bmp, .heic) is attached only when the message shows an image of it (the server attaches a converted copy when it can); when none is attached, index it from its metadata and never guess its contents.
|
|
1062
1065
|
- Most files (office documents like .docx/.xlsx/.pptx/.hwp/.hwpx/.ods, email messages (.eml), and text/data/code files like .csv/.tsv/.json/.xml/.txt/.md and source code) have ALREADY been extracted on the server and included inline in the user message between the "BEGIN FILE CONTENT" / "END FILE CONTENT" markers - read that directly. If the inline content is a "[skapi: ...]" note, the file could not be extracted - index it from its metadata only.
|
|
1063
1066
|
- BIG SPREADSHEETS / TEXT: the inline content may be only the FIRST part of a large file (it can end with a truncation or "more remains" note). UNLESS this message already embeds a window of the file (in which case the message tells you not to call readFileContent, and you must not), read big spreadsheets and big text/data files WITH THE readFileContent TOOL: it returns the file ONE WINDOW at a time (spreadsheets as coordinate-tagged grid rows, text as a range of characters). Pass the file's storage path. After each window: datafy it into records and SAVE them, THEN if the window says MORE REMAINS call readFileContent again with the cursor it gives you. Repeat until it says END OF FILE, so the WHOLE file is indexed - never stop after the first window.
|
|
1064
1067
|
- PDFs (scanned or not): you do NOT read a PDF with a tool or a URL. Its pages are RENDERED and embedded directly in the user message as IMAGE blocks, a WINDOW of pages at a time. LOOK at the embedded page images and datafy every one. The note beside them tells you whether MORE pages remain: if so, save this window's records and stop (a follow-up pass shows the next window automatically); only when the note says it was the LAST window is the PDF fully seen. Do NOT call readFileContent or web_fetch for a PDF.
|
|
1065
1068
|
- VISION: when the message (a readFileContent window, an embedded PDF page, or an inline attachment) includes IMAGES - scanned/rendered PDF pages, or photos embedded in a spreadsheet next to a row/block - LOOK at them and capture what they show as record data (the reading/values in a scanned table, the part/defect/condition visible in a photo). The image IS part of the data; correlate each photo with its labelled block ("PHOTO A3" markers tie a photo to that grid row).
|
|
1066
|
-
- TRANSCRIBE, DO NOT DESCRIBE. When an image contains ANY text - a label, tag, stamp, form field, serial/part number, handwriting - your FIRST job is to read the characters out and store them VERBATIM, not to describe the scene. A record saying "a red inspection tag with handwritten markings" is worthless: it is unsearchable and every such photo produces the same sentence. Put the characters you can actually read into these EXACT fields, not variations of them: "printed_text" (the pre-printed wording), "handwritten_text" (what a person wrote by hand), and, when you can resolve one, "part_no", "tag_id" and "date". Same reason as the fixed table names: a field called photo_text in one pass and visible_text_notes in the next cannot be queried together. Read PARTIAL values rather than skipping: "500.7402.
|
|
1067
|
-
- IMAGE FILES uploaded as the file itself: if ANY readable character appears ANYWHERE in the image (a label, a stamp, a sign in the background) it counts as an image WITH text - transcribe it per the rule above, and also capture the layout (what appears where) and every entity named. Only a truly text-free image gets description first: a one-line caption, then the objects present with their attributes (type, color, count, condition, position). Either way, save what you extract onto the file's "src::" record with updateRecords, TAG every entity and identifier visible, and INDEX the one number the image offers (a measured value, an amount, a count).
|
|
1069
|
+
- TRANSCRIBE, DO NOT DESCRIBE. When an image contains ANY text - a label, tag, stamp, form field, serial/part number, handwriting - your FIRST job is to read the characters out and store them VERBATIM, not to describe the scene. A record saying "a red inspection tag with handwritten markings" is worthless: it is unsearchable and every such photo produces the same sentence. Put the characters you can actually read into these EXACT fields, not variations of them: "printed_text" (the pre-printed wording), "handwritten_text" (what a person wrote by hand), and, when you can resolve one, "part_no", "serial_no", "tag_id" and "date". Every identifier you read (a serial number, a part number, a tag id, a model code) ALSO goes into "printed_text" or "handwritten_text", exactly as it appears, because those two fields are the image's searchable text. Text can appear at ANY angle (sideways, upside down, mirrored, along a curve): read it in its own orientation, and never call text unreadable only because it is turned. When it is upside down or sideways, watch the look-alikes (6 and 9, 0 and O, 1 and I, Latin and Cyrillic letters of the same shape). Same reason as the fixed table names: a field called photo_text in one pass and visible_text_notes in the next cannot be queried together. Read PARTIAL values rather than skipping: "500.7402.5[?][?]" beats nothing. Write [?] for each character that is genuinely unreadable and copy handwriting character for character - do NOT invent a character, and do NOT replace the whole transcription with a description of what the object looks like. A scene description is a nice extra AFTER the text, never instead of it.
|
|
1070
|
+
- IMAGE FILES uploaded as the file itself: if ANY readable character appears ANYWHERE in the image (a label, a stamp, a sign in the background) it counts as an image WITH text - transcribe it per the rule above, and also capture the layout (what appears where) and every entity named. Only a truly text-free image gets description first: a one-line caption, then the objects present with their attributes (type, color, count, condition, position). Either way, save what you extract onto the file's "src::" record with updateRecords, TAG every entity and identifier visible, and INDEX the one number the image offers (a measured value, an amount, a count). On that same record ALSO set "text_rotation" and "text_legibility". "text_rotation" is the CLOCKWISE turn, 0, 90, 180 or 270, that would make the image's main text upright AS THE IMAGE IS SHOWN TO YOU: 0 when it already reads normally; 180 when it is upside down; 90 when its lines run from bottom to top (the tops of the letters face left); 270 when its lines run from top to bottom (the tops of the letters face right). "text_legibility" is "clear", "partial" or "unreadable" ("none" when there is no text).
|
|
1068
1071
|
- Whatever the file type, this file's identity is "src::" + its storage path (the "storage path" metadata line) - never the inline content or a temporary URL. That record ALREADY EXISTS: the upload pipeline creates it in table "file_summaries" (access group "${accessGroup}") before indexing starts, so posting it again is rejected as a duplicate unique_id. Reference it from every record you write, and add what you learn to it with updateRecords. If that update unexpectedly reports the record does not exist, post it yourself ONCE with that exact "src::" unique_id (table "file_summaries", access group "${accessGroup}") and carry on; this is the ONE exception to the do-NOT-post-the-file-record rules elsewhere in these instructions, because the source identity must never be dropped just because an update failed.
|
|
1069
1072
|
- ACCESS GROUP (hard rule): every record you write for this file - the file record, per-row records, chapters, summaries, intermediates - MUST be posted with access group "${accessGroup}". Pass it explicitly on every postRecords call; do not leave it out and do not vary it between passes of the same file. An access group is part of a record's table key, so records saved under a different group than the file are in a different table and will not come back with the rest of it: a "public" file whose rows were saved as "authorized" is one an anonymous visitor can see the name of and none of the contents of, and a re-index cannot find the strays to clean them up. The one exception is the EXTRACTED MEDIA records in "__MEDIA__", which the pipeline creates for you - leave their group alone and only enrich them.
|
|
1070
1073
|
- REACHABILITY (hard rule): every record you write while indexing this file MUST be reachable from the file's "src::<storage path>" record by following reference - either reference that record directly, or reference something that already reaches it. A record with no reference, or one pointing outside this file's chain, is an ORPHAN: deleting or re-indexing the file removes the reachable records and leaves the orphan behind forever, where it keeps turning up in later answers as stale data. If you create an intermediate record that OTHER records reference (a page record that rows hang off, a sheet or section record), set source.can_remove_referencing_records to true on it; the delete cascade passes a delete through a record only when that record carries the flag OR a unique_id starting "src::" (the file record cascades because its unique_id starts with "src::"; the intermediates you create carry no "src::" id, so they need the flag), and it cascades ONE LEVEL AT A TIME, so EVERY intermediate record in a chain needs its own marker - an unmarked link stops the cascade there and everything below it survives as orphans. When in doubt, reference the file record directly and keep the chain flat.
|
|
@@ -1136,6 +1139,12 @@ ${options.inlineContentPlaceholder}
|
|
|
1136
1139
|
return head + `
|
|
1137
1140
|
Read this file with the readFileContent tool, using the storage path above - do NOT fetch a URL and do NOT rely on a single sample. readFileContent returns the file ONE WINDOW at a time: spreadsheets as coordinate-tagged grid rows (e.g. 'R4 A:E&I NUMBER | B:E1007'), text as a character range, and windows may include embedded photos - LOOK at any images and datafy what they show. Page through EVERY window: for each window SAVE records for its rows/items/pages (postRecords, one record per row/item; spreadsheet rows in "spreadsheet_rows", everything else in "document_entries"), THEN if the window says MORE REMAINS call readFileContent again with the cursor it gives you. Repeat until it says END OF FILE, so the WHOLE file is indexed. Do NOT stop after the first window and do NOT just write a summary. Set every record's reference to exactly "src::" + the storage path above; that file record already exists, so enrich it with updateRecords instead of posting it again.` + (attachment.url ? `
|
|
1138
1141
|
(A temporary URL is provided ONLY as a fallback if readFileContent fails: ${attachment.url})` : "");
|
|
1142
|
+
}
|
|
1143
|
+
if (options?.imageFile) {
|
|
1144
|
+
return head + `- temporary URL: ${attachment.url}
|
|
1145
|
+
` + (options.imageFile === "attached" ? `
|
|
1146
|
+
This is an IMAGE file, attached to this message as an image: read it there, not from the URL. ` : `
|
|
1147
|
+
This is an IMAGE file in a format the AI cannot take directly. When an image of it is attached to this message (the server converts it when it can), read it there; when none is attached, index the file from its metadata only and do not guess its contents. `) + `Transcribe every character FIRST, at whatever angle the text is: "printed_text", "handwritten_text", and "part_no" / "serial_no" / "tag_id", with every identifier also written inside "printed_text" or "handwritten_text". Then set "text_rotation" and "text_legibility" on the file's "src::" record, and only then describe what the image shows.`;
|
|
1139
1148
|
}
|
|
1140
1149
|
return head + `- temporary URL (fetch this to read the file contents): ${attachment.url}`;
|
|
1141
1150
|
}
|
|
@@ -1717,16 +1726,19 @@ Index the REMAINING windows - one record per row/item, looking at any page image
|
|
|
1717
1726
|
if (typeof value === "number" && isFinite(value)) pushUnique(list, String(value));
|
|
1718
1727
|
else pushUnique(list, value);
|
|
1719
1728
|
}
|
|
1720
|
-
function pushHit(list, path, page) {
|
|
1729
|
+
function pushHit(list, path, page, sheet) {
|
|
1721
1730
|
if (typeof path !== "string" || !path.trim()) return;
|
|
1722
1731
|
var n = typeof page === "number" ? page : Number(page);
|
|
1723
1732
|
if (!isFinite(n) || n <= 0) return;
|
|
1724
1733
|
n = Math.floor(n);
|
|
1734
|
+
var sh = typeof sheet === "string" && sheet.trim() ? sheet.trim() : "";
|
|
1725
1735
|
for (var i = 0; i < list.length; i++) {
|
|
1726
|
-
if (list[i].path === path && list[i].page === n) return;
|
|
1736
|
+
if (sh ? list[i].path === path && list[i].sheet === sh : list[i].path === path && list[i].page === n) return;
|
|
1727
1737
|
}
|
|
1728
1738
|
if (list.length >= RETRIEVAL_NOTE_MAX_ITEMS) return;
|
|
1729
|
-
|
|
1739
|
+
var hit = { path: path.trim(), page: n };
|
|
1740
|
+
if (sh) hit.sheet = sh;
|
|
1741
|
+
list.push(hit);
|
|
1730
1742
|
}
|
|
1731
1743
|
function pathFromSrcId(value) {
|
|
1732
1744
|
if (typeof value !== "string") return null;
|
|
@@ -1773,7 +1785,7 @@ Index the REMAINING windows - one record per row/item, looking at any page image
|
|
|
1773
1785
|
return;
|
|
1774
1786
|
}
|
|
1775
1787
|
if (typeof node.path === "string" && node.page !== void 0) {
|
|
1776
|
-
pushHit(note.hits, node.path, node.page);
|
|
1788
|
+
pushHit(note.hits, node.path, node.page, node.sheet);
|
|
1777
1789
|
}
|
|
1778
1790
|
for (var k in node) {
|
|
1779
1791
|
if (!Object.prototype.hasOwnProperty.call(node, k)) continue;
|
|
@@ -1902,8 +1914,16 @@ Index the REMAINING windows - one record per row/item, looking at any page image
|
|
|
1902
1914
|
}
|
|
1903
1915
|
byFile[h.path].push(h.page);
|
|
1904
1916
|
}
|
|
1917
|
+
var sheetsOf = {};
|
|
1918
|
+
for (var s2 = 0; s2 < note.hits.length; s2++) {
|
|
1919
|
+
var hs = note.hits[s2];
|
|
1920
|
+
if (hs.sheet) {
|
|
1921
|
+
if (!sheetsOf[hs.path]) sheetsOf[hs.path] = [];
|
|
1922
|
+
if (sheetsOf[hs.path].indexOf(hs.sheet) === -1) sheetsOf[hs.path].push(hs.sheet);
|
|
1923
|
+
}
|
|
1924
|
+
}
|
|
1905
1925
|
parts.push("searchText hits " + order.map(function(p) {
|
|
1906
|
-
return p + " p" + byFile[p].join(", p");
|
|
1926
|
+
return sheetsOf[p] ? p + " sheet " + sheetsOf[p].join(", sheet ") : p + " p" + byFile[p].join(", p");
|
|
1907
1927
|
}).join("; "));
|
|
1908
1928
|
}
|
|
1909
1929
|
if (note.tools.length) parts.push("tools " + note.tools.join(", "));
|
|
@@ -2297,6 +2317,13 @@ Index the REMAINING windows - one record per row/item, looking at any page image
|
|
|
2297
2317
|
return { detail, pagesPerWindow: RENDER_PAGES_PER_WINDOW, tile: 1 };
|
|
2298
2318
|
}
|
|
2299
2319
|
var IMAGE_URL_REGEX = /\bhttps?:\/\/[^\s<>"'()\[\]]+?\.(?:jpg|jpeg|png|gif|webp)(?:\?[^\s<>"'()\[\]]*)?/gi;
|
|
2320
|
+
var INDEX_IMAGE_OTHER_EXT = /\.(?:tiff?|bmp|heic|heif)$/i;
|
|
2321
|
+
function indexingImageFile(attachment) {
|
|
2322
|
+
const url = typeof attachment.url === "string" ? attachment.url : "";
|
|
2323
|
+
if (url && new RegExp(IMAGE_URL_REGEX.source, "i").test(url)) return "attached";
|
|
2324
|
+
if (INDEX_IMAGE_OTHER_EXT.test(attachment.name || "") || INDEX_IMAGE_OTHER_EXT.test(attachment.storagePath || "")) return "maybe";
|
|
2325
|
+
return void 0;
|
|
2326
|
+
}
|
|
2300
2327
|
function transformContentWithImages(content) {
|
|
2301
2328
|
if (typeof content !== "string" || !content) {
|
|
2302
2329
|
return content;
|
|
@@ -2736,10 +2763,20 @@ Index the REMAINING windows - one record per row/item, looking at any page image
|
|
|
2736
2763
|
save_media: !continuing
|
|
2737
2764
|
}))
|
|
2738
2765
|
} : {};
|
|
2739
|
-
const
|
|
2766
|
+
const singlePass = !visionFile && !windowedRead && !pagedRead && !continuing;
|
|
2767
|
+
const imageFile = singlePass && !parsedContent && !serverExtract ? indexingImageFile(attachment) : void 0;
|
|
2768
|
+
const fileUrlDetail = imageFile && platform === "openai" ? getOpenAIImageDetail(info.model || DEFAULT_OPENAI_MODEL) : void 0;
|
|
2769
|
+
const skapiFileUrls = attachment.url && attachment.storagePath ? {
|
|
2770
|
+
_skapi_file_urls: [{
|
|
2771
|
+
path: attachment.storagePath,
|
|
2772
|
+
url: attachment.url,
|
|
2773
|
+
...singlePass ? { index_end: true } : {},
|
|
2774
|
+
...fileUrlDetail ? { detail: fileUrlDetail } : {}
|
|
2775
|
+
}]
|
|
2776
|
+
} : {};
|
|
2740
2777
|
const userMessage = visionFile && renderPlaceholder ? buildIndexingRenderMessage(attachment, renderPlaceholder, renderFrom) : windowedRead && windowPlaceholder ? buildIndexingWindowMessage(attachment, windowPlaceholder, false) : continuing ? buildIndexingContinueMessage(attachment) : buildIndexingUserMessage(
|
|
2741
2778
|
attachment,
|
|
2742
|
-
parsedContent ? { inlineContent: parsedContent } : placeholder ? { inlineContentPlaceholder: placeholder } : pagedRead ? { pagedRead: true } : void 0
|
|
2779
|
+
parsedContent ? { inlineContent: parsedContent } : placeholder ? { inlineContentPlaceholder: placeholder } : pagedRead ? { pagedRead: true } : imageFile ? { imageFile } : void 0
|
|
2743
2780
|
);
|
|
2744
2781
|
const systemPrompt = buildIndexingSystemPrompt({
|
|
2745
2782
|
// The model copies this id verbatim into project_id tool calls, so it must be
|
|
@@ -3619,10 +3656,20 @@ Index the REMAINING windows - one record per row/item, looking at any page image
|
|
|
3619
3656
|
var out = [];
|
|
3620
3657
|
var hitPaths = [];
|
|
3621
3658
|
var byPath = {};
|
|
3659
|
+
var sheetsByPath = {};
|
|
3622
3660
|
var i;
|
|
3623
3661
|
for (i = 0; i < note.hits.length; i++) {
|
|
3624
3662
|
var h = note.hits[i];
|
|
3625
3663
|
if (!h || typeof h.path !== "string" || !isMintablePath(h.path)) continue;
|
|
3664
|
+
if (typeof h.sheet === "string" && h.sheet) {
|
|
3665
|
+
if (!byPath[h.path]) {
|
|
3666
|
+
byPath[h.path] = [];
|
|
3667
|
+
hitPaths.push(h.path);
|
|
3668
|
+
}
|
|
3669
|
+
if (!sheetsByPath[h.path]) sheetsByPath[h.path] = [];
|
|
3670
|
+
if (sheetsByPath[h.path].indexOf(h.sheet) === -1) sheetsByPath[h.path].push(h.sheet);
|
|
3671
|
+
continue;
|
|
3672
|
+
}
|
|
3626
3673
|
var page = typeof h.page === "number" ? h.page : Number(h.page);
|
|
3627
3674
|
if (!isFinite(page) || page <= 0) continue;
|
|
3628
3675
|
page = Math.floor(page);
|
|
@@ -3634,6 +3681,10 @@ Index the REMAINING windows - one record per row/item, looking at any page image
|
|
|
3634
3681
|
}
|
|
3635
3682
|
for (i = 0; i < hitPaths.length; i++) {
|
|
3636
3683
|
var p = hitPaths[i];
|
|
3684
|
+
var sheets = sheetsByPath[p] || [];
|
|
3685
|
+
for (var sj = 0; sj < sheets.length; sj++) {
|
|
3686
|
+
out.push({ path: p, label: citationFileName(p) + " \xB7 " + sheets[sj] });
|
|
3687
|
+
}
|
|
3637
3688
|
var pages = byPath[p].slice().sort(function(a, b) {
|
|
3638
3689
|
return a - b;
|
|
3639
3690
|
});
|
|
@@ -5695,6 +5746,18 @@ Index the REMAINING windows - one record per row/item, looking at any page image
|
|
|
5695
5746
|
/** Pages watching a project's background indexing queue (watchIndexQueue). */
|
|
5696
5747
|
this._iqWatches = [];
|
|
5697
5748
|
this._chainsRestored = false;
|
|
5749
|
+
/**
|
|
5750
|
+
* A run closed idle (a complete queue look found no pass of it) whose record still says
|
|
5751
|
+
* 'working': when it is THIS user's run of a client-driven file and no browser tab here
|
|
5752
|
+
* keeps its chain (a reload, a discarded tab, or a browser without localStorage lost
|
|
5753
|
+
* it), nothing will ever send its next pass, so run:: says CHAIN_LOST_TEXT. Never for a
|
|
5754
|
+
* worker-driven file (the worker writes its endings), another user's run (their chain is
|
|
5755
|
+
* in their browser), or a run whose next pass is being looked for.
|
|
5756
|
+
*/
|
|
5757
|
+
/** Files the last queue look listed pending or running, settled bubbles included. */
|
|
5758
|
+
this._rawListedIndexKeys = {};
|
|
5759
|
+
/** Runs found idle on one complete look, waiting for a second before "lost" (see below). */
|
|
5760
|
+
this._lostLooks = {};
|
|
5698
5761
|
/**
|
|
5699
5762
|
* Pick up indexing passes the WORKER minted, which no client ever dispatched.
|
|
5700
5763
|
*
|
|
@@ -6090,6 +6153,7 @@ Index the REMAINING windows - one record per row/item, looking at any page image
|
|
|
6090
6153
|
_recordLiveIndexKeys(lists) {
|
|
6091
6154
|
var next = {};
|
|
6092
6155
|
var running = {};
|
|
6156
|
+
var rawListed = {};
|
|
6093
6157
|
var truncated = false;
|
|
6094
6158
|
var runningTruncated = false;
|
|
6095
6159
|
var settledIds = {};
|
|
@@ -6112,6 +6176,11 @@ Index the REMAINING windows - one record per row/item, looking at any page image
|
|
|
6112
6176
|
for (var i = 0; i < list.length; i++) {
|
|
6113
6177
|
var item = list[i];
|
|
6114
6178
|
if (!item || item.status !== "pending" && item.status !== "running") continue;
|
|
6179
|
+
var rawRef = parseIndexingRequestText(listedRequestText(item));
|
|
6180
|
+
if (rawRef) {
|
|
6181
|
+
if (rawRef.path) rawListed[rawRef.path] = true;
|
|
6182
|
+
if (rawRef.name) rawListed[rawRef.name] = true;
|
|
6183
|
+
}
|
|
6115
6184
|
if (item.id && settledIds[item.id]) continue;
|
|
6116
6185
|
var text = listedRequestText(item);
|
|
6117
6186
|
if (!isIndexingRequestText(text)) continue;
|
|
@@ -6153,6 +6222,7 @@ Index the REMAINING windows - one record per row/item, looking at any page image
|
|
|
6153
6222
|
}
|
|
6154
6223
|
}
|
|
6155
6224
|
this.state.liveIndexKeys = next;
|
|
6225
|
+
this._rawListedIndexKeys = rawListed;
|
|
6156
6226
|
if (this.state.liveIndexRunningChecked !== !runningTruncated) changed = true;
|
|
6157
6227
|
var settledNow = this.state.liveIndexSettled || {};
|
|
6158
6228
|
var settledNext = {};
|
|
@@ -9975,33 +10045,40 @@ Index the REMAINING windows - one record per row/item, looking at any page image
|
|
|
9975
10045
|
else if (!Object.keys(self._openMap()).length && !self._viewMounted()) self._stopStatusPush();
|
|
9976
10046
|
});
|
|
9977
10047
|
}
|
|
9978
|
-
|
|
9979
|
-
|
|
9980
|
-
|
|
9981
|
-
* keeps its chain (a reload, a discarded tab, or a browser without localStorage lost
|
|
9982
|
-
* it), nothing will ever send its next pass, so run:: says CHAIN_LOST_TEXT. Never for a
|
|
9983
|
-
* worker-driven file (the worker writes its endings), another user's run (their chain is
|
|
9984
|
-
* in their browser), or a run whose next pass is being looked for.
|
|
9985
|
-
*/
|
|
10048
|
+
_lostKey(run) {
|
|
10049
|
+
return run.projectId + "\0" + run.storagePath + "\0" + run.since;
|
|
10050
|
+
}
|
|
9986
10051
|
_flipIfChainLost(run) {
|
|
9987
10052
|
var self = this;
|
|
9988
|
-
if (!run.owner) return;
|
|
10053
|
+
if (!run.owner) return false;
|
|
10054
|
+
var raw = this._rawListedIndexKeys || {};
|
|
10055
|
+
if (raw[run.storagePath] || run.filename && raw[run.filename]) {
|
|
10056
|
+
delete this._lostLooks[this._lostKey(run)];
|
|
10057
|
+
return true;
|
|
10058
|
+
}
|
|
10059
|
+
var lk = this._lostKey(run);
|
|
10060
|
+
if (!this._lostLooks[lk]) {
|
|
10061
|
+
this._lostLooks[lk] = 1;
|
|
10062
|
+
return true;
|
|
10063
|
+
}
|
|
10064
|
+
delete this._lostLooks[lk];
|
|
9989
10065
|
var live = null;
|
|
9990
10066
|
try {
|
|
9991
10067
|
live = this.host.getIdentity();
|
|
9992
10068
|
} catch (e2) {
|
|
9993
10069
|
live = null;
|
|
9994
10070
|
}
|
|
9995
|
-
if (!live || !live.userId || live.userId !== run.owner || live.projectId !== run.projectId) return;
|
|
10071
|
+
if (!live || !live.userId || live.userId !== run.owner || live.projectId !== run.projectId) return false;
|
|
9996
10072
|
var name = run.filename || run.storagePath.split("/").pop() || run.storagePath;
|
|
9997
|
-
if (this._isWorkerDrivenIndexing(name, void 0)) return;
|
|
9998
|
-
if (
|
|
10073
|
+
if (this._isWorkerDrivenIndexing(name, void 0)) return false;
|
|
10074
|
+
if (workerIndexEndingsEnabled() && !isPagedReadFile(name, void 0)) return false;
|
|
10075
|
+
if (this._chainKept(run.projectId, run.storagePath)) return false;
|
|
9999
10076
|
for (var q = 0; q < this.bgTaskQueue.length; q++) {
|
|
10000
10077
|
var e = this.bgTaskQueue[q];
|
|
10001
|
-
if (e && e.projectId === run.projectId && e.storagePath === run.storagePath) return;
|
|
10078
|
+
if (e && e.projectId === run.projectId && e.storagePath === run.storagePath) return false;
|
|
10002
10079
|
}
|
|
10003
10080
|
if (this._recPending) for (var c in this._recPending) {
|
|
10004
|
-
if (this._recPending[c].kind === "indexing" && this._recPending[c].projectId === run.projectId) return;
|
|
10081
|
+
if (this._recPending[c].kind === "indexing" && this._recPending[c].projectId === run.projectId) return false;
|
|
10005
10082
|
}
|
|
10006
10083
|
var projectId = run.projectId, path = run.storagePath;
|
|
10007
10084
|
runSettleSideEffect(projectId, bgIndexingQueueName(live.userId, projectId), "lost:" + projectId + ":" + path + ":" + run.since, function() {
|
|
@@ -10014,6 +10091,7 @@ Index the REMAINING windows - one record per row/item, looking at any page image
|
|
|
10014
10091
|
}
|
|
10015
10092
|
});
|
|
10016
10093
|
});
|
|
10094
|
+
return false;
|
|
10017
10095
|
}
|
|
10018
10096
|
/** A file run the queue says is live, or that this page has a pass queued for. */
|
|
10019
10097
|
_fileRunLive(run) {
|
|
@@ -10045,8 +10123,8 @@ Index the REMAINING windows - one record per row/item, looking at any page image
|
|
|
10045
10123
|
var closed = [];
|
|
10046
10124
|
for (var k in runs) {
|
|
10047
10125
|
if (runs[k].projectId !== projectId || this._fileRunLive(runs[k])) continue;
|
|
10126
|
+
if (this._flipIfChainLost(runs[k])) continue;
|
|
10048
10127
|
closed.push(runs[k].storagePath);
|
|
10049
|
-
this._flipIfChainLost(runs[k]);
|
|
10050
10128
|
delete runs[k];
|
|
10051
10129
|
if (!this._fileRunsIdle) this._fileRunsIdle = {};
|
|
10052
10130
|
this._fileRunsIdle[k] = true;
|
|
@@ -13081,7 +13159,7 @@ Index the REMAINING windows - one record per row/item, looking at any page image
|
|
|
13081
13159
|
(function() {
|
|
13082
13160
|
var MCP_PROD = "https://mcp.skapi.com";
|
|
13083
13161
|
var MCP_DEV = "https://mcp-dev.broadwayinc.computer";
|
|
13084
|
-
var BQ_VERSION = "1.21.
|
|
13162
|
+
var BQ_VERSION = "1.21.3" ;
|
|
13085
13163
|
var ATTACHMENT_URL_EXPIRES_SECONDS = 600;
|
|
13086
13164
|
var GOOGLE_AUTH_URL = "https://accounts.google.com/o/oauth2/v2/auth";
|
|
13087
13165
|
var GOOGLE_TOKEN_URL = "https://oauth2.googleapis.com/token";
|
|
@@ -18135,12 +18213,16 @@ Index the REMAINING windows - one record per row/item, looking at any page image
|
|
|
18135
18213
|
// a project that turned it off.
|
|
18136
18214
|
skipDuplicateFiles: null,
|
|
18137
18215
|
// Reuse the MCP tool listing OpenAI returned on an earlier chat turn, so
|
|
18138
|
-
// OpenAI skips fetching it again (about 0.6 s per turn).
|
|
18139
|
-
//
|
|
18140
|
-
reuseMcpToolList:
|
|
18216
|
+
// OpenAI skips fetching it again (about 0.6 s per turn). On unless false
|
|
18217
|
+
// (verified live on dev 2026-11-25). See configureChatEngine `reuseMcpToolList`.
|
|
18218
|
+
reuseMcpToolList: true,
|
|
18141
18219
|
// Server-driven windowed indexing; read at configureChatEngine time.
|
|
18142
18220
|
// Listed here so the defaults object is the full opt surface.
|
|
18143
18221
|
windowedIndexing: true,
|
|
18222
|
+
// The worker writes the ending of a file read in one pass (an image); see the
|
|
18223
|
+
// engine's configureChatEngine `workerIndexEndings`. Opt-in until every region's
|
|
18224
|
+
// worker carries it.
|
|
18225
|
+
workerIndexEndings: false,
|
|
18144
18226
|
// Deliver the streamed reply over skapi's WEBSOCKET as well as the poll.
|
|
18145
18227
|
// OFF unless the embedder asks, because this widget runs on someone else's
|
|
18146
18228
|
// page with someone else's skapi instance: skapi's joinRealtime REPLACES
|
|
@@ -18245,6 +18327,8 @@ Index the REMAINING windows - one record per row/item, looking at any page image
|
|
|
18245
18327
|
// MAX_INDEXING_RESUME_PASSES, which needs the tab kept open and stops early
|
|
18246
18328
|
// on a big file. Pass windowedIndexing: false in init opts to opt back out.
|
|
18247
18329
|
windowedIndexing: S.opts.windowedIndexing !== false,
|
|
18330
|
+
// single-pass files: the worker writes their done:: / run:: (opt-in, see defaults)
|
|
18331
|
+
workerIndexEndings: S.opts.workerIndexEndings === true,
|
|
18248
18332
|
// Client-side attachment parsers (e.g. an .hwp parser) passed via init opts.
|
|
18249
18333
|
attachmentParsers: S.opts.attachmentParsers || void 0,
|
|
18250
18334
|
// Web access for chat answers. Handed over ONLY when the embedder
|
|
@@ -18256,8 +18340,8 @@ Index the REMAINING windows - one record per row/item, looking at any page image
|
|
|
18256
18340
|
// Skip duplicate uploads. Same hand-over rule: only a pinned boolean is
|
|
18257
18341
|
// passed, and the project's setting is the ceiling the engine applies.
|
|
18258
18342
|
skipDuplicateFiles: typeof S.opts.skipDuplicateFiles === "boolean" ? S.opts.skipDuplicateFiles : void 0,
|
|
18259
|
-
// OpenAI MCP tool-list reuse across chat turns:
|
|
18260
|
-
reuseMcpToolList: S.opts.reuseMcpToolList
|
|
18343
|
+
// OpenAI MCP tool-list reuse across chat turns: on unless an explicit false.
|
|
18344
|
+
reuseMcpToolList: S.opts.reuseMcpToolList !== false,
|
|
18261
18345
|
// ---- live streaming (mirrored in agent.vue's ai_agent.ts) --------
|
|
18262
18346
|
// Streaming itself is not passed: the engine streams whenever the two
|
|
18263
18347
|
// hooks below are handed over, which skapiEngineTransport does only when
|