bunnyquery 1.20.0 → 1.21.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 +45 -4
- package/bunnyquery.css +49 -0
- package/bunnyquery.js +3821 -1547
- package/dist/engine.cjs +3742 -1489
- package/dist/engine.cjs.map +1 -1
- package/dist/engine.d.mts +1452 -693
- package/dist/engine.d.ts +1452 -693
- package/dist/engine.mjs +3725 -1486
- package/dist/engine.mjs.map +1 -1
- package/package.json +1 -1
- package/src/engine/config.ts +75 -13
- package/src/engine/errors.ts +38 -0
- package/src/engine/history.ts +71 -11
- package/src/engine/host.ts +51 -4
- package/src/engine/index.ts +38 -9
- package/src/engine/prompts/chat_system_prompt.ts +0 -1
- package/src/engine/reconciler.ts +594 -0
- package/src/engine/requests.ts +58 -9
- package/src/engine/session.ts +3567 -1426
- package/src/widget.css +34 -0
- package/styles/chat.css +15 -0
- package/src/engine/findings.ts +0 -305
package/dist/engine.d.mts
CHANGED
|
@@ -1,149 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Retrieval memory: a compact note of what a chat turn RETRIEVED, kept with the
|
|
3
|
-
* turn so a follow-up question skips discovery.
|
|
4
|
-
*
|
|
5
|
-
* THE PROBLEM. The provider runs the tool loop on its side and history keeps
|
|
6
|
-
* only the answer text (budget.ts), so on "and what does page 3 say?" the model
|
|
7
|
-
* starts from nothing: it looks the file up again, guesses a table and an access
|
|
8
|
-
* group again, and routinely lands somewhere else, which is how an answer flips
|
|
9
|
-
* between two turns about the same document.
|
|
10
|
-
*
|
|
11
|
-
* WHAT THE ENGINE CAN SEE. The provider's final body carries the tool loop:
|
|
12
|
-
* - Anthropic Messages: content[] blocks `mcp_tool_use` (name, input) and
|
|
13
|
-
* `mcp_tool_result` (content), plus `server_tool_use` / `web_*_tool_result`
|
|
14
|
-
* for the built-in web tools;
|
|
15
|
-
* - OpenAI Responses: output[] items `mcp_call` (name, arguments as a JSON
|
|
16
|
-
* string, output as a string) and `web_search_call`.
|
|
17
|
-
* The polling worker stores that body on the row (spilling to S3 past 300 KB,
|
|
18
|
-
* never truncating), and a streamed turn's assembled body keeps the same blocks
|
|
19
|
-
* (sse.ts copies each block's skeleton and its JSON input verbatim), so the
|
|
20
|
-
* same reader works live, after a stream and after a reload. When a body has no
|
|
21
|
-
* tool blocks at all (a host that strips them, a provider shape this does not
|
|
22
|
-
* know), the note falls back to what the ANSWER names: db: file links and src::
|
|
23
|
-
* paths. Nothing is ever invented: an empty note is null, not a guess.
|
|
24
|
-
*
|
|
25
|
-
* WHAT IS KEPT, per turn: files (storage paths), tables, access groups,
|
|
26
|
-
* searchText hits as path + page, the tool names, and whether a web tool ran.
|
|
27
|
-
* Arguments are read by KEY, never by position, and only the keys the
|
|
28
|
-
* BunnyQuery tools use for those four things; a query's filter values, a
|
|
29
|
-
* record's data and a tool result's text are never copied, so the note cannot
|
|
30
|
-
* leak a page of a document into every later turn.
|
|
31
|
-
*
|
|
32
|
-
* HOW IT REACHES THE MODEL. buildBoundedChatMessages appends the formatted note
|
|
33
|
-
* to the LLM copy of the assistant turn it belongs to (never the displayed
|
|
34
|
-
* bubble), for the newest RETRIEVAL_NOTES_MAX turns and within
|
|
35
|
-
* RETRIEVAL_NOTES_TOKEN_BUDGET tokens, so the memory is bounded however long
|
|
36
|
-
* the chat gets. A host that never attaches `_retrieval` sees byte-identical
|
|
37
|
-
* requests to today.
|
|
38
|
-
*/
|
|
39
|
-
type RetrievalHit = {
|
|
40
|
-
path: string;
|
|
41
|
-
page: number;
|
|
42
|
-
};
|
|
43
|
-
type RetrievalNote = {
|
|
44
|
-
/** Storage paths (the part after "src::") the turn read, queried or linked. */
|
|
45
|
-
files: string[];
|
|
46
|
-
/** Table names the turn queried. */
|
|
47
|
-
tables: string[];
|
|
48
|
-
/** Access groups the turn queried at, as written in the call. */
|
|
49
|
-
accessGroups: string[];
|
|
50
|
-
/** searchText hits: the page a term was found on, per file. */
|
|
51
|
-
hits: RetrievalHit[];
|
|
52
|
-
/** Tool names, in order of first use. */
|
|
53
|
-
tools: string[];
|
|
54
|
-
/** A web tool ran in this turn (web_search / web_fetch). */
|
|
55
|
-
web: boolean;
|
|
56
|
-
/** 'tools' when read off the body's tool blocks; 'answer' when only the
|
|
57
|
-
* answer text was available to read. */
|
|
58
|
-
source: 'tools' | 'answer' | 'body';
|
|
59
|
-
};
|
|
60
|
-
/** How many of the newest turns carry their note into the request. */
|
|
61
|
-
declare const RETRIEVAL_NOTES_MAX = 6;
|
|
62
|
-
/** Ceiling on the estimated tokens all carried notes may add to one request. */
|
|
63
|
-
declare const RETRIEVAL_NOTES_TOKEN_BUDGET = 1200;
|
|
64
|
-
/** Per-list cap inside one note (files, tables, groups, hits, tools). */
|
|
65
|
-
declare const RETRIEVAL_NOTE_MAX_ITEMS = 8;
|
|
66
|
-
/** Hard cap on one formatted note. */
|
|
67
|
-
declare const RETRIEVAL_NOTE_MAX_CHARS = 600;
|
|
68
|
-
/** The marker a carried note opens with; also what keeps it out of the model's own voice. */
|
|
69
|
-
declare const RETRIEVAL_NOTE_PREFIX = "[Retrieval note, not shown to the user";
|
|
70
|
-
/**
|
|
71
|
-
* What an ANSWER names: db: file links ("[name](db:path)") and src:: ids. The
|
|
72
|
-
* fallback for a body with no tool blocks, and merged into a tool note too so a
|
|
73
|
-
* file the model linked but never queried (it knew the path from history) is
|
|
74
|
-
* still remembered.
|
|
75
|
-
*/
|
|
76
|
-
declare function retrievalNoteFromText(text: string | null | undefined): RetrievalNote | null;
|
|
77
|
-
/**
|
|
78
|
-
* The note for one assistant turn: the body's tool loop when it has one, else
|
|
79
|
-
* what the answer names, else null. `answerText` is the extracted answer, read
|
|
80
|
-
* for file links in both cases.
|
|
81
|
-
*/
|
|
82
|
-
declare function extractRetrievalNote(body: any, answerText?: string | null): RetrievalNote | null;
|
|
83
|
-
/**
|
|
84
|
-
* True when `body` is a provider response this module can read: an Anthropic
|
|
85
|
-
* Messages body (`content` array) or an OpenAI Responses body (`output` array).
|
|
86
|
-
*/
|
|
87
|
-
declare function providerBodyWasRead(body: any): boolean;
|
|
88
|
-
/** True when the value is a note this module produced (or an equivalent shape). */
|
|
89
|
-
declare function isRetrievalNote(value: any): value is RetrievalNote;
|
|
90
|
-
/**
|
|
91
|
-
* One line the model reads. Sections are omitted when empty, the whole thing is
|
|
92
|
-
* capped at RETRIEVAL_NOTE_MAX_CHARS, and it opens with RETRIEVAL_NOTE_PREFIX so
|
|
93
|
-
* the model can tell it from its own earlier words. Returns '' for an empty note.
|
|
94
|
-
*/
|
|
95
|
-
declare function formatRetrievalNote(note: RetrievalNote | null | undefined): string;
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Saved search findings (owner, 2026-11-20): where a hard search found its answer, kept in
|
|
99
|
-
* the project's database so the same question, from anyone, later goes straight to the page.
|
|
100
|
-
*
|
|
101
|
-
* WHAT IS SAVED: the LOCATION, never the answer. One record per file page in table
|
|
102
|
-
* "search_findings", unique_id "find::<path>#p<page>", reference "src::<path>" (so a
|
|
103
|
-
* re-index or a delete of the file removes its findings through the cascade), the file's own
|
|
104
|
-
* access group (a finding is never visible to someone who cannot read the file), and tags:
|
|
105
|
-
* the key words of the question and the search terms that found the page, normalized the way
|
|
106
|
-
* every BunnyQuery tag is (tagForms). The chat reads the page again before answering, so a
|
|
107
|
-
* finding can never replay an outdated answer; it only skips the hunt.
|
|
108
|
-
*
|
|
109
|
-
* WHEN: after a chat turn that needed a real search (FINDING_MIN_TOOL_CALLS or more tool
|
|
110
|
-
* calls) and whose answer links a file that a searchText hit found on a page, or, when the
|
|
111
|
-
* turn read the file with readFileContent instead, the pages its answer cites of that file. Read from the
|
|
112
|
-
* provider body the turn already has, by the engine, so it costs no model step. Nothing is
|
|
113
|
-
* invented: no hit on a linked file, no finding. No page text and no result text is copied.
|
|
114
|
-
*
|
|
115
|
-
* The engine never writes records itself: the host's saveSearchFinding hook does (config.ts).
|
|
116
|
-
*/
|
|
117
|
-
|
|
118
|
-
declare const FINDINGS_TABLE = "search_findings";
|
|
119
|
-
declare const FINDING_ID_PREFIX = "find::";
|
|
120
|
-
/** The words of a question or a search term that say WHAT is looked for. */
|
|
121
|
-
declare function keyWords(text: string | null | undefined): string[];
|
|
122
|
-
type SearchFinding = {
|
|
123
|
-
storagePath: string;
|
|
124
|
-
page: number;
|
|
125
|
-
uniqueId: string;
|
|
126
|
-
tags: string[];
|
|
127
|
-
data: {
|
|
128
|
-
path: string;
|
|
129
|
-
page: number;
|
|
130
|
-
question_words: string[];
|
|
131
|
-
search_terms: string[];
|
|
132
|
-
found_at: number;
|
|
133
|
-
};
|
|
134
|
-
};
|
|
135
|
-
/**
|
|
136
|
-
* The findings one finished chat turn earns, or [] (see the file comment for the rules).
|
|
137
|
-
* `note` is the turn's retrieval note (its searchText hits and the files its answer links).
|
|
138
|
-
*/
|
|
139
|
-
declare function findingsForTurn(args: {
|
|
140
|
-
question: string | null | undefined;
|
|
141
|
-
body: any;
|
|
142
|
-
note: RetrievalNote | null | undefined;
|
|
143
|
-
answer: string | null | undefined;
|
|
144
|
-
now?: number;
|
|
145
|
-
}): SearchFinding[];
|
|
146
|
-
|
|
147
1
|
/**
|
|
148
2
|
* Client-side attachment-parser plugins.
|
|
149
3
|
*
|
|
@@ -499,6 +353,27 @@ declare function patchProjectSettings(service: string, patch: ProjectSettingsDat
|
|
|
499
353
|
*/
|
|
500
354
|
declare function clearProjectSettings(service?: string): void;
|
|
501
355
|
|
|
356
|
+
/**
|
|
357
|
+
* Engine configuration / dependency injection.
|
|
358
|
+
*
|
|
359
|
+
* The engine is framework- and transport-agnostic: it never imports a skapi
|
|
360
|
+
* instance or `import.meta.env`. Each consumer calls `configureChatEngine()`
|
|
361
|
+
* once at startup to inject the skapi transport functions, the MCP base URL,
|
|
362
|
+
* and (optionally) the `poll` value to attach to every forwarded request.
|
|
363
|
+
*
|
|
364
|
+
* Why `poll` is configurable: agent.vue uses the npm-bundled skapi-js and OMITS
|
|
365
|
+
* `poll` (its request auto-resolves with the final body), whereas
|
|
366
|
+
* the BunnyQuery widget uses the deployed skapi-js@latest and must pass
|
|
367
|
+
* `poll: 0` to get the early ack + a manual `.poll()` handle (needed for queued-
|
|
368
|
+
* send cancel). So the request builders include `poll` only when it is set.
|
|
369
|
+
*
|
|
370
|
+
* THE TRANSPORT IS THE forwardRequest FAMILY ONLY (owner, 2026-11-20: clientSecretRequest
|
|
371
|
+
* is being deprecated). The old `clientSecretRequest*` keys are no longer read: a host
|
|
372
|
+
* injects `forwardRequest`, `forwardRequestHistory` and, to stream,
|
|
373
|
+
* `forwardRequestFinalize` and `forwardRequestStream`, all from skapi-js 2.1.0 or newer.
|
|
374
|
+
* Every call goes through the resolveForwardRequest* functions below.
|
|
375
|
+
*/
|
|
376
|
+
|
|
502
377
|
/**
|
|
503
378
|
* One report about a turn that is streaming, as handed to `onLiveStreamUpdate`.
|
|
504
379
|
*
|
|
@@ -553,6 +428,7 @@ type ForwardRequestFinalizeFn = (requestId: string, data: any, options: {
|
|
|
553
428
|
method: string;
|
|
554
429
|
service?: string;
|
|
555
430
|
owner?: string;
|
|
431
|
+
ifAbsent?: boolean;
|
|
556
432
|
}) => Promise<any>;
|
|
557
433
|
/** The chunk read-back call, identical under its new and its deprecated key. */
|
|
558
434
|
type ForwardRequestStreamFn = (requestId: string, options: {
|
|
@@ -626,11 +502,13 @@ interface ChatEngineConfig {
|
|
|
626
502
|
* only ever inferred here); the worker writes their marker itself.
|
|
627
503
|
* Must be best-effort: tolerate the marker already existing and never
|
|
628
504
|
* throw. Optional so older consumers keep the pre-marker inference.
|
|
505
|
+
* May return a promise that rejects when the write failed (not for "already
|
|
506
|
+
* there"): the engine then writes it again, a few times, with backoff.
|
|
629
507
|
*/
|
|
630
508
|
mintIndexDoneMarker?: (info: {
|
|
631
509
|
service: string;
|
|
632
510
|
storagePath: string;
|
|
633
|
-
}) => void
|
|
511
|
+
}) => void | Promise<unknown>;
|
|
634
512
|
/**
|
|
635
513
|
* Create-or-update the per-file indexing RUN record ("run::<path>",
|
|
636
514
|
* reference "src::<path>", table __INDEXING__). The record is the durable
|
|
@@ -644,7 +522,9 @@ interface ChatEngineConfig {
|
|
|
644
522
|
* overwrite a terminal status (done/error/cancelled) — a late create from
|
|
645
523
|
* a slow enqueue must not resurrect a run another writer already closed.
|
|
646
524
|
* Must be best-effort and never throw. Optional: without it the engine
|
|
647
|
-
* behaves exactly as before (legacy scan/probe path).
|
|
525
|
+
* behaves exactly as before (legacy scan/probe path). May return a promise
|
|
526
|
+
* that rejects when the write failed: the engine then writes it again, a few
|
|
527
|
+
* times, with backoff.
|
|
648
528
|
*/
|
|
649
529
|
upsertIndexRunRecord?: (info: {
|
|
650
530
|
service: string;
|
|
@@ -657,7 +537,7 @@ interface ChatEngineConfig {
|
|
|
657
537
|
error?: string;
|
|
658
538
|
queue?: string;
|
|
659
539
|
};
|
|
660
|
-
}) => void
|
|
540
|
+
}) => void | Promise<unknown>;
|
|
661
541
|
/**
|
|
662
542
|
* Deliver each relayed chunk over skapi's WEBSOCKET as well, so text lands as it
|
|
663
543
|
* is relayed instead of on the next poll tick. Off unless a host asks.
|
|
@@ -827,18 +707,6 @@ interface ChatEngineConfig {
|
|
|
827
707
|
pages_saved?: number;
|
|
828
708
|
pages_total?: number | null;
|
|
829
709
|
} | null>;
|
|
830
|
-
/**
|
|
831
|
-
* Save one search finding (findings.ts): where a hard search found its answer, as a
|
|
832
|
-
* record in table "search_findings" with the given unique_id, tags and data, reference
|
|
833
|
-
* "src::<storagePath>" and the ACCESS GROUP OF THAT FILE (read it; skip the save when
|
|
834
|
-
* the file has no record). When the unique_id is taken, add the new tags to the existing
|
|
835
|
-
* record instead. Best effort: never throw into the engine. Optional: without it nothing
|
|
836
|
-
* is saved.
|
|
837
|
-
*/
|
|
838
|
-
saveSearchFinding?: (finding: SearchFinding & {
|
|
839
|
-
service: string;
|
|
840
|
-
owner?: string;
|
|
841
|
-
}) => Promise<any> | void;
|
|
842
710
|
/**
|
|
843
711
|
* The request ids of one file's indexing passes: the unique ids "pass::<storagePath>#<id>"
|
|
844
712
|
* the worker writes as each pass starts (getUniqueId, prefix "pass::<storagePath>#", every
|
|
@@ -847,9 +715,56 @@ interface ChatEngineConfig {
|
|
|
847
715
|
* (ChatSession.loadRunPasses). Without it the history pages the indexing queue as before.
|
|
848
716
|
*/
|
|
849
717
|
listIndexPasses?: (service: string, storagePath: string) => Promise<string[]>;
|
|
718
|
+
/**
|
|
719
|
+
* THE RECONCILER'S READS (reconciler plan, section 3; skapi-js 2.7.0 or newer). All
|
|
720
|
+
* three are optional, and a host hands over only what its skapi-js has: with
|
|
721
|
+
* `forwardRequestStatus` AND `forwardRequestRead` the engine follows every waiting
|
|
722
|
+
* item with one batch read per look (ChatSession's reconciler) instead of one poll
|
|
723
|
+
* per request; without them it keeps today's polls, and its looks re-attach a
|
|
724
|
+
* failed poll through the old by-id read (csrHistoryItemLookup).
|
|
725
|
+
*
|
|
726
|
+
* skapi.forwardRequestStatus(requests, { service, owner, deadline, fresh, signal }):
|
|
727
|
+
* the status of up to 100 requests per call, no bodies.
|
|
728
|
+
*/
|
|
729
|
+
forwardRequestStatus?: (requests: any[], opts?: any) => Promise<{
|
|
730
|
+
list: any[];
|
|
731
|
+
[key: string]: any;
|
|
732
|
+
}>;
|
|
733
|
+
/** skapi.forwardRequestRead({ id, url, method, since, service, owner, deadline, fresh,
|
|
734
|
+
* signal }): one request as an envelope that always carries its status, with a
|
|
735
|
+
* streamed turn's chunks after `since`. Read once per item that just turned terminal. */
|
|
736
|
+
forwardRequestRead?: (params: any) => Promise<any>;
|
|
737
|
+
/** skapi.forwardRequestQueueCounters(queues, { service, owner, deadline, fresh,
|
|
738
|
+
* signal }): the tiny counter rows of up to 20 queues. Read on every look; the
|
|
739
|
+
* requests themselves are read only when a counter moved, on a trigger, or once a
|
|
740
|
+
* minute. Optional even with the two above: without it every look reads statuses. */
|
|
741
|
+
forwardRequestQueueCounters?: (queues: string[], opts?: any) => Promise<{
|
|
742
|
+
queues: {
|
|
743
|
+
[name: string]: any;
|
|
744
|
+
};
|
|
745
|
+
}>;
|
|
746
|
+
/**
|
|
747
|
+
* Ask the host to refresh what it shows of a project's records, because indexing
|
|
748
|
+
* work of that project just settled and none is left in this page's queue. A data
|
|
749
|
+
* hook: called with no chat view mounted too (the files page, the records page), and
|
|
750
|
+
* only in the tab that holds the project's settle lock. Optional; never throws.
|
|
751
|
+
*/
|
|
752
|
+
refreshRecords?: (projectId: string) => void;
|
|
850
753
|
}
|
|
851
754
|
declare function configureChatEngine(config: ChatEngineConfig): void;
|
|
852
755
|
declare function chatEngineConfig(): ChatEngineConfig;
|
|
756
|
+
/**
|
|
757
|
+
* The host handed over the reconciler's two reads (batch status and envelope read), so
|
|
758
|
+
* the engine follows waiting items with batch reads instead of one poll each. False on
|
|
759
|
+
* an older skapi-js: the engine then keeps today's polls (see forwardRequestStatus).
|
|
760
|
+
*/
|
|
761
|
+
declare function reconcilerReadsEnabled(): boolean;
|
|
762
|
+
/**
|
|
763
|
+
* A send may carry a client reference (`cref`). Only with the reconciler's reads: the
|
|
764
|
+
* same skapi-js (2.7.0) brought both, and an older one drops the key anyway, so a send
|
|
765
|
+
* whose ack was lost could never be matched by it.
|
|
766
|
+
*/
|
|
767
|
+
declare function crefSupported(): boolean;
|
|
853
768
|
/** True when the consumer has opted in to live streaming of chat turns. */
|
|
854
769
|
/** Socket delivery of the stream: the host asked (`liveStreaming`) AND the turn streams. */
|
|
855
770
|
/** Request status push is on: the host asked for it and handed over onRequestStatus. */
|
|
@@ -980,6 +895,140 @@ declare function streamRecoveryEnabled(): boolean;
|
|
|
980
895
|
*/
|
|
981
896
|
declare function skapiSupportsStreaming(sk: any): boolean;
|
|
982
897
|
|
|
898
|
+
/**
|
|
899
|
+
* The reconciler's clock and the cross-tab settle lock (reconciler plan, sections 3 and 4b,
|
|
900
|
+
* BUNNYQUERY_CHAT_RECONCILER_PLAN.md).
|
|
901
|
+
*
|
|
902
|
+
* WHAT LIVES HERE. Only the parts that know nothing about chats: one timer chain per page
|
|
903
|
+
* (LookScheduler), the triggers that pull its next look forward, the deadline and the
|
|
904
|
+
* generation that make a hung look harmless, the backoff after a failed look, and the lock
|
|
905
|
+
* that keeps side effects (a next indexing pass, run::/done:: writes, a finalize, a records
|
|
906
|
+
* refresh) to one tab. What a look actually reads and applies is ChatSession's
|
|
907
|
+
* (_reconcileLook in session.ts), handed in as a hook, so this file is testable on its own
|
|
908
|
+
* and the session keeps its own state private.
|
|
909
|
+
*
|
|
910
|
+
* THE RULES IT ENFORCES (owner, 2026-11-24, plan 4b):
|
|
911
|
+
* 1. One loop. One setTimeout handle for the whole page, whatever the number of waiting
|
|
912
|
+
* requests. Scheduling always clears the previous handle first.
|
|
913
|
+
* 2. Returns never add work. A trigger while a look runs sets ONE follow-up look (the
|
|
914
|
+
* triggers are merged), never a second loop or a second timer. A trigger while no look
|
|
915
|
+
* runs starts the look now.
|
|
916
|
+
* 3. A look that does not finish within LOOK_DEADLINE_MS is over: it counts as failed
|
|
917
|
+
* (nothing on screen changes), its in-flight reads are aborted, and anything its
|
|
918
|
+
* generation returns later is ignored by the session (alive() is false).
|
|
919
|
+
*/
|
|
920
|
+
/** How long one look may take in all. */
|
|
921
|
+
declare const LOOK_DEADLINE_MS: number;
|
|
922
|
+
/** The visible cadence while anything is waiting. */
|
|
923
|
+
declare const LOOK_FAST_MS: number;
|
|
924
|
+
/** The visible cadence while request status frames arrive (statusPush), and the hidden
|
|
925
|
+
* cadence while a client-driven indexing chain is open. */
|
|
926
|
+
declare const LOOK_SLOW_MS: number;
|
|
927
|
+
/** Re-read every open item at least this often, whatever the queue counters say. */
|
|
928
|
+
declare const LOOK_STALE_MS: number;
|
|
929
|
+
/** Why a look runs. Several merge into one look. */
|
|
930
|
+
type LookTrigger = 'tick' | 'return' | 'visible' | 'wake' | 'online' | 'pageshow' | 'reconnect' | 'view' | 'frame' | 'unknown' | 'promote' | 'send' | 'signin' | 'add';
|
|
931
|
+
declare function isReturnTrigger(t: string): boolean;
|
|
932
|
+
/** One look as the session sees it. */
|
|
933
|
+
type LookRequest = {
|
|
934
|
+
/** Generation: grows by one per look. */
|
|
935
|
+
gen: number;
|
|
936
|
+
triggers: {
|
|
937
|
+
[k: string]: true;
|
|
938
|
+
};
|
|
939
|
+
/** Any trigger was a return (see RETURN_TRIGGERS). */
|
|
940
|
+
isReturn: boolean;
|
|
941
|
+
/** Aborts every read of this look at its deadline (undefined without AbortController). */
|
|
942
|
+
signal: any;
|
|
943
|
+
/** False once the deadline passed or a newer look started: drop every result. */
|
|
944
|
+
alive: () => boolean;
|
|
945
|
+
/** Milliseconds left before the deadline (at least 1). */
|
|
946
|
+
remaining: () => number;
|
|
947
|
+
};
|
|
948
|
+
/** How a look ended: 'ok' (it read what it needed), 'transient' (a read failed on the way:
|
|
949
|
+
* backoff, nothing changed), 'auth' (the sign-in is gone), 'idle' (nothing to do). */
|
|
950
|
+
type LookOutcome = 'ok' | 'transient' | 'auth' | 'idle';
|
|
951
|
+
interface LookHooks {
|
|
952
|
+
/** Run one look. Never called twice at once. */
|
|
953
|
+
runLook(req: LookRequest): Promise<LookOutcome>;
|
|
954
|
+
/** Is there anything to follow: `visible` = anything at all (the 3 s cadence), `hidden`
|
|
955
|
+
* = something worth a look once a minute while the tab is hidden. */
|
|
956
|
+
work(): {
|
|
957
|
+
visible: boolean;
|
|
958
|
+
hidden: boolean;
|
|
959
|
+
};
|
|
960
|
+
/** Status frames are arriving (statusPush): the visible cadence slows to a minute. */
|
|
961
|
+
pushLive(): boolean;
|
|
962
|
+
/** The reconnecting / sign-in flags changed (for the views). */
|
|
963
|
+
onFlags(flags: {
|
|
964
|
+
reconnecting: boolean;
|
|
965
|
+
signInNeeded: boolean;
|
|
966
|
+
}): void;
|
|
967
|
+
}
|
|
968
|
+
/**
|
|
969
|
+
* The one timer chain. See the file note for the rules.
|
|
970
|
+
*/
|
|
971
|
+
declare class LookScheduler {
|
|
972
|
+
private hooks;
|
|
973
|
+
private timer;
|
|
974
|
+
/** When the pending timer should fire, on both clocks (wake detection). */
|
|
975
|
+
private expectPerf;
|
|
976
|
+
private expectWall;
|
|
977
|
+
private running;
|
|
978
|
+
/** Triggers that arrived while a look ran: exactly one more look runs with them. */
|
|
979
|
+
private pending;
|
|
980
|
+
/** Resolvers of trigger() promises, by the look that will serve them. */
|
|
981
|
+
private waitCurrent;
|
|
982
|
+
private waitNext;
|
|
983
|
+
private backoff;
|
|
984
|
+
private listening;
|
|
985
|
+
private stopped;
|
|
986
|
+
gen: number;
|
|
987
|
+
reconnecting: boolean;
|
|
988
|
+
signInNeeded: boolean;
|
|
989
|
+
/** Diagnostics (and the throwaway checks): looks started, timers armed. */
|
|
990
|
+
looks: number;
|
|
991
|
+
timersArmed: number;
|
|
992
|
+
constructor(hooks: LookHooks);
|
|
993
|
+
/** Pull the next look forward to now. Resolves when the look that serves it ends. */
|
|
994
|
+
trigger(kind: LookTrigger): Promise<void>;
|
|
995
|
+
/** Triggers gathered for a look about to start (see trigger). */
|
|
996
|
+
private starting;
|
|
997
|
+
private waitStarting;
|
|
998
|
+
/** Make sure the chain runs at its cadence when there is work. Never adds a timer when
|
|
999
|
+
* one is armed or a look is running, so calling it from every add is free. */
|
|
1000
|
+
ensure(): void;
|
|
1001
|
+
/** The sign-in came back (or the host says so): looks resume at once. */
|
|
1002
|
+
signedIn(): void;
|
|
1003
|
+
/** Stop the chain (tests, teardown). A later trigger or ensure starts it again. */
|
|
1004
|
+
stop(): void;
|
|
1005
|
+
isRunning(): boolean;
|
|
1006
|
+
private _flags;
|
|
1007
|
+
private _listen;
|
|
1008
|
+
private _start;
|
|
1009
|
+
private _finish;
|
|
1010
|
+
private scheduling;
|
|
1011
|
+
private _scheduleNext;
|
|
1012
|
+
private _arm;
|
|
1013
|
+
}
|
|
1014
|
+
/** Has this side effect run in any tab (within a day)? */
|
|
1015
|
+
declare function sideEffectDone(key: string): boolean;
|
|
1016
|
+
/**
|
|
1017
|
+
* Run `fn` once across the tabs, under the settle lock of (project, queue). `key` names
|
|
1018
|
+
* the side effect (e.g. "resume:<request id>"). Never throws; `fn` may be async.
|
|
1019
|
+
*
|
|
1020
|
+
* Done only when it worked: the side effect is marked in flight (FX_INFLIGHT_MS, so the
|
|
1021
|
+
* other tabs leave it alone) while `fn` runs, and done when `fn` returns, or when the
|
|
1022
|
+
* promise it returns resolves. A throw or a rejected promise clears the mark and `fn` runs
|
|
1023
|
+
* again after a backoff, up to FX_MAX_TRIES times in this tab; a later call with the same
|
|
1024
|
+
* key (the next look, another tab) can still run it after that. A tab that finds it in
|
|
1025
|
+
* flight elsewhere looks again once that mark would have expired, so a tab that died
|
|
1026
|
+
* mid-write does not leave it undone.
|
|
1027
|
+
*/
|
|
1028
|
+
declare function runSettleSideEffect(projectId: string, queue: string, key: string, fn: () => any, attempt?: number, tries?: number): void;
|
|
1029
|
+
/** A client reference for one send: 1 to 64 letters, digits, "_" or "-". */
|
|
1030
|
+
declare function newClientRef(): string;
|
|
1031
|
+
|
|
983
1032
|
/**
|
|
984
1033
|
* Duplicate-upload detection for chat attachments (reliability plan, owner's
|
|
985
1034
|
* yes 2026-10-12): "has the signed-in user already uploaded THIS file to this
|
|
@@ -1529,6 +1578,115 @@ declare function isAuthExpiredError(input: any): boolean;
|
|
|
1529
1578
|
* reduced to by getErrorMessage, because the view usually only keeps the text.
|
|
1530
1579
|
*/
|
|
1531
1580
|
declare function isProviderApiKeyError(input: any): boolean;
|
|
1581
|
+
/**
|
|
1582
|
+
* The server's own "that request is gone" answer to a read of it (the row was removed:
|
|
1583
|
+
* cancelled while queued, or cleaned up). A fact about the request, unlike every
|
|
1584
|
+
* failure isTransportFailure covers.
|
|
1585
|
+
*/
|
|
1586
|
+
declare function isNotExistsError(err: any): boolean;
|
|
1587
|
+
/**
|
|
1588
|
+
* True when a READ of a request failed on the way: no network, no answer in time, rate
|
|
1589
|
+
* limited, a server fault (5xx), an aborted read. Such a failure says nothing about the
|
|
1590
|
+
* request itself, which may be running or already answered, so a caller must never
|
|
1591
|
+
* turn it into an error bubble or a failed run record (reconciler plan, section 3 item 4).
|
|
1592
|
+
*/
|
|
1593
|
+
declare function isTransportFailure(err: any): boolean;
|
|
1594
|
+
|
|
1595
|
+
/**
|
|
1596
|
+
* Retrieval memory: a compact note of what a chat turn RETRIEVED, kept with the
|
|
1597
|
+
* turn so a follow-up question skips discovery.
|
|
1598
|
+
*
|
|
1599
|
+
* THE PROBLEM. The provider runs the tool loop on its side and history keeps
|
|
1600
|
+
* only the answer text (budget.ts), so on "and what does page 3 say?" the model
|
|
1601
|
+
* starts from nothing: it looks the file up again, guesses a table and an access
|
|
1602
|
+
* group again, and routinely lands somewhere else, which is how an answer flips
|
|
1603
|
+
* between two turns about the same document.
|
|
1604
|
+
*
|
|
1605
|
+
* WHAT THE ENGINE CAN SEE. The provider's final body carries the tool loop:
|
|
1606
|
+
* - Anthropic Messages: content[] blocks `mcp_tool_use` (name, input) and
|
|
1607
|
+
* `mcp_tool_result` (content), plus `server_tool_use` / `web_*_tool_result`
|
|
1608
|
+
* for the built-in web tools;
|
|
1609
|
+
* - OpenAI Responses: output[] items `mcp_call` (name, arguments as a JSON
|
|
1610
|
+
* string, output as a string) and `web_search_call`.
|
|
1611
|
+
* The polling worker stores that body on the row (spilling to S3 past 300 KB,
|
|
1612
|
+
* never truncating), and a streamed turn's assembled body keeps the same blocks
|
|
1613
|
+
* (sse.ts copies each block's skeleton and its JSON input verbatim), so the
|
|
1614
|
+
* same reader works live, after a stream and after a reload. When a body has no
|
|
1615
|
+
* tool blocks at all (a host that strips them, a provider shape this does not
|
|
1616
|
+
* know), the note falls back to what the ANSWER names: db: file links and src::
|
|
1617
|
+
* paths. Nothing is ever invented: an empty note is null, not a guess.
|
|
1618
|
+
*
|
|
1619
|
+
* WHAT IS KEPT, per turn: files (storage paths), tables, access groups,
|
|
1620
|
+
* searchText hits as path + page, the tool names, and whether a web tool ran.
|
|
1621
|
+
* Arguments are read by KEY, never by position, and only the keys the
|
|
1622
|
+
* BunnyQuery tools use for those four things; a query's filter values, a
|
|
1623
|
+
* record's data and a tool result's text are never copied, so the note cannot
|
|
1624
|
+
* leak a page of a document into every later turn.
|
|
1625
|
+
*
|
|
1626
|
+
* HOW IT REACHES THE MODEL. buildBoundedChatMessages appends the formatted note
|
|
1627
|
+
* to the LLM copy of the assistant turn it belongs to (never the displayed
|
|
1628
|
+
* bubble), for the newest RETRIEVAL_NOTES_MAX turns and within
|
|
1629
|
+
* RETRIEVAL_NOTES_TOKEN_BUDGET tokens, so the memory is bounded however long
|
|
1630
|
+
* the chat gets. A host that never attaches `_retrieval` sees byte-identical
|
|
1631
|
+
* requests to today.
|
|
1632
|
+
*/
|
|
1633
|
+
type RetrievalHit = {
|
|
1634
|
+
path: string;
|
|
1635
|
+
page: number;
|
|
1636
|
+
};
|
|
1637
|
+
type RetrievalNote = {
|
|
1638
|
+
/** Storage paths (the part after "src::") the turn read, queried or linked. */
|
|
1639
|
+
files: string[];
|
|
1640
|
+
/** Table names the turn queried. */
|
|
1641
|
+
tables: string[];
|
|
1642
|
+
/** Access groups the turn queried at, as written in the call. */
|
|
1643
|
+
accessGroups: string[];
|
|
1644
|
+
/** searchText hits: the page a term was found on, per file. */
|
|
1645
|
+
hits: RetrievalHit[];
|
|
1646
|
+
/** Tool names, in order of first use. */
|
|
1647
|
+
tools: string[];
|
|
1648
|
+
/** A web tool ran in this turn (web_search / web_fetch). */
|
|
1649
|
+
web: boolean;
|
|
1650
|
+
/** 'tools' when read off the body's tool blocks; 'answer' when only the
|
|
1651
|
+
* answer text was available to read. */
|
|
1652
|
+
source: 'tools' | 'answer' | 'body';
|
|
1653
|
+
};
|
|
1654
|
+
/** How many of the newest turns carry their note into the request. */
|
|
1655
|
+
declare const RETRIEVAL_NOTES_MAX = 6;
|
|
1656
|
+
/** Ceiling on the estimated tokens all carried notes may add to one request. */
|
|
1657
|
+
declare const RETRIEVAL_NOTES_TOKEN_BUDGET = 1200;
|
|
1658
|
+
/** Per-list cap inside one note (files, tables, groups, hits, tools). */
|
|
1659
|
+
declare const RETRIEVAL_NOTE_MAX_ITEMS = 8;
|
|
1660
|
+
/** Hard cap on one formatted note. */
|
|
1661
|
+
declare const RETRIEVAL_NOTE_MAX_CHARS = 600;
|
|
1662
|
+
/** The marker a carried note opens with; also what keeps it out of the model's own voice. */
|
|
1663
|
+
declare const RETRIEVAL_NOTE_PREFIX = "[Retrieval note, not shown to the user";
|
|
1664
|
+
/**
|
|
1665
|
+
* What an ANSWER names: db: file links ("[name](db:path)") and src:: ids. The
|
|
1666
|
+
* fallback for a body with no tool blocks, and merged into a tool note too so a
|
|
1667
|
+
* file the model linked but never queried (it knew the path from history) is
|
|
1668
|
+
* still remembered.
|
|
1669
|
+
*/
|
|
1670
|
+
declare function retrievalNoteFromText(text: string | null | undefined): RetrievalNote | null;
|
|
1671
|
+
/**
|
|
1672
|
+
* The note for one assistant turn: the body's tool loop when it has one, else
|
|
1673
|
+
* what the answer names, else null. `answerText` is the extracted answer, read
|
|
1674
|
+
* for file links in both cases.
|
|
1675
|
+
*/
|
|
1676
|
+
declare function extractRetrievalNote(body: any, answerText?: string | null): RetrievalNote | null;
|
|
1677
|
+
/**
|
|
1678
|
+
* True when `body` is a provider response this module can read: an Anthropic
|
|
1679
|
+
* Messages body (`content` array) or an OpenAI Responses body (`output` array).
|
|
1680
|
+
*/
|
|
1681
|
+
declare function providerBodyWasRead(body: any): boolean;
|
|
1682
|
+
/** True when the value is a note this module produced (or an equivalent shape). */
|
|
1683
|
+
declare function isRetrievalNote(value: any): value is RetrievalNote;
|
|
1684
|
+
/**
|
|
1685
|
+
* One line the model reads. Sections are omitted when empty, the whole thing is
|
|
1686
|
+
* capped at RETRIEVAL_NOTE_MAX_CHARS, and it opens with RETRIEVAL_NOTE_PREFIX so
|
|
1687
|
+
* the model can tell it from its own earlier words. Returns '' for an empty note.
|
|
1688
|
+
*/
|
|
1689
|
+
declare function formatRetrievalNote(note: RetrievalNote | null | undefined): string;
|
|
1532
1690
|
|
|
1533
1691
|
declare var CONTEXT_WINDOW_DEFAULT: Record<string, number>;
|
|
1534
1692
|
declare var CONTEXT_WINDOW_BY_MODEL: Record<string, number>;
|
|
@@ -2662,402 +2820,8 @@ interface SseParser {
|
|
|
2662
2820
|
}
|
|
2663
2821
|
declare function createSseParser(): SseParser;
|
|
2664
2822
|
|
|
2665
|
-
declare const MCP_NAME = "BunnyQuery";
|
|
2666
|
-
declare const DEFAULT_CLAUDE_MODEL = "claude-haiku-5-5";
|
|
2667
|
-
declare const DEFAULT_OPENAI_MODEL = "gpt-6-luna";
|
|
2668
2823
|
/**
|
|
2669
|
-
*
|
|
2670
|
-
*
|
|
2671
|
-
* There are two of them and they are NOT the same flag:
|
|
2672
|
-
*
|
|
2673
|
-
* * `transport.stream` is SKAPI's. It tells the polling worker to read the
|
|
2674
|
-
* destination's response incrementally and append the raw bytes to the chunk
|
|
2675
|
-
* table, and it is never sent on to the destination.
|
|
2676
|
-
* * `body.stream` is the DESTINATION's own field, and BunnyQuery is the party
|
|
2677
|
-
* that may set it: skapi relays bytes and knows no vendor, so it cannot know
|
|
2678
|
-
* that Anthropic Messages and OpenAI Responses both happen to spell it
|
|
2679
|
-
* `stream` at the top level of the body.
|
|
2680
|
-
*
|
|
2681
|
-
* Setting one without the other fails QUIETLY, which is why they are produced by
|
|
2682
|
-
* one function from one boolean and returned as one object:
|
|
2683
|
-
*
|
|
2684
|
-
* * body streams, skapi buffers -> the row stores an SSE TRANSCRIPT where
|
|
2685
|
-
* extractClaudeText / extractOpenAIText expect a parsed document, so the turn
|
|
2686
|
-
* reads back as an empty answer with nothing in the logs to say why.
|
|
2687
|
-
* * skapi streams, the body never asked -> the destination sends one plain
|
|
2688
|
-
* document, the relay chops it into chunks, the frame parser finds no framing
|
|
2689
|
-
* at all, and the row settles with a status and no body.
|
|
2690
|
-
*
|
|
2691
|
-
* Two frozen constants rather than a fresh object per call: the pair is a
|
|
2692
|
-
* CONSTANT, and an object literal built at each call site is exactly the shape
|
|
2693
|
-
* that drifts when someone edits one arm.
|
|
2694
|
-
*/
|
|
2695
|
-
type ChatStreamWiring = {
|
|
2696
|
-
/** Spread into the forwardRequest OPTIONS (skapi's relay switch). `realtime`
|
|
2697
|
-
* belongs here and never in `body`: it is skapi's, not the destination's. */
|
|
2698
|
-
transport: {
|
|
2699
|
-
stream?: true;
|
|
2700
|
-
realtime?: true;
|
|
2701
|
-
};
|
|
2702
|
-
/** Spread into `data` (the destination's own switch). */
|
|
2703
|
-
body: {
|
|
2704
|
-
stream?: true;
|
|
2705
|
-
};
|
|
2706
|
-
};
|
|
2707
|
-
declare function chatStreamWiring(queue?: string): ChatStreamWiring;
|
|
2708
|
-
/**
|
|
2709
|
-
* The body fields a CHAT turn's answer mode adds, for the one provider and model the turn
|
|
2710
|
-
* runs on. An empty object, i.e. nothing at all, for 'standard' (the default) and for any
|
|
2711
|
-
* model not known to accept the field, so a project that never set a mode sends the exact
|
|
2712
|
-
* request it sent before the setting existed. OpenAI takes `reasoning: {effort}`, Claude
|
|
2713
|
-
* takes `output_config: {effort}`. Never used by an indexing pass.
|
|
2714
|
-
*/
|
|
2715
|
-
declare function chatEffortFields(platform: 'claude' | 'openai', model: string | undefined, mode: AnswerMode | undefined): Record<string, any>;
|
|
2716
|
-
/** How a given model should be shown a rendered document. */
|
|
2717
|
-
type VisionProfile = {
|
|
2718
|
-
/** Per-image `detail` (OpenAI only). */
|
|
2719
|
-
detail: string;
|
|
2720
|
-
/** Pages the worker renders into one window. */
|
|
2721
|
-
pagesPerWindow: number;
|
|
2722
|
-
/** Horizontal bands per page; 1 renders the whole page as one image. */
|
|
2723
|
-
tile: number;
|
|
2724
|
-
};
|
|
2725
|
-
/**
|
|
2726
|
-
* Resolve the render profile for a model.
|
|
2727
|
-
*
|
|
2728
|
-
* Three tiers, and they fail for different reasons, which is why one set of knobs cannot
|
|
2729
|
-
* serve all of them:
|
|
2730
|
-
* - full: everything ABOVE gpt-5.4-nano - the base models, mini, and every gpt-5.6
|
|
2731
|
-
* including 5.6-nano. These already transcribe dense scans correctly, so they get
|
|
2732
|
-
* 'original' detail and are otherwise untouched.
|
|
2733
|
-
* - gpt-5.4-nano: also gets 'original', so it sees exactly the SAME pixels as the full
|
|
2734
|
-
* tier. Its gap therefore is not resolution, and tiling would do nothing for it. What
|
|
2735
|
-
* it lacks is room: a smaller window leaves the same output budget divided between
|
|
2736
|
-
* fewer pages.
|
|
2737
|
-
* - downsampled (below the 'original' floor: gpt-5.3-nano, gpt-5-nano, gpt-4.1-nano):
|
|
2738
|
-
* capped at 'high', which resamples the page onto a 512px grid no matter what DPI it
|
|
2739
|
-
* was rendered at. Render resolution is wasted on these entirely; the only way to give
|
|
2740
|
-
* them readable text is to make each image cover less of the page, which is `tile`.
|
|
2741
|
-
*/
|
|
2742
|
-
declare function getVisionProfile(model?: string): VisionProfile;
|
|
2743
|
-
type ClaudeRole = 'user' | 'assistant';
|
|
2744
|
-
type ClaudeMessage = {
|
|
2745
|
-
role: ClaudeRole;
|
|
2746
|
-
content: string;
|
|
2747
|
-
};
|
|
2748
|
-
type OpenAIMessage = {
|
|
2749
|
-
role: ClaudeRole;
|
|
2750
|
-
content: string;
|
|
2751
|
-
};
|
|
2752
|
-
type ClaudeMcpToolConfig = {
|
|
2753
|
-
enabled?: boolean;
|
|
2754
|
-
defer_loading?: boolean;
|
|
2755
|
-
};
|
|
2756
|
-
type ClaudeMcpServerRequest = {
|
|
2757
|
-
name: string;
|
|
2758
|
-
url: string;
|
|
2759
|
-
authorizationToken?: string;
|
|
2760
|
-
defaultConfig?: ClaudeMcpToolConfig;
|
|
2761
|
-
configs?: Record<string, ClaudeMcpToolConfig>;
|
|
2762
|
-
};
|
|
2763
|
-
declare function transformContentWithImages(content: string): string | Array<Record<string, any>>;
|
|
2764
|
-
declare function transformContentWithOpenAIImages(content: string, detail?: string): string | Array<Record<string, any>>;
|
|
2765
|
-
type CallClaudeWithMcpParams = {
|
|
2766
|
-
prompt: string;
|
|
2767
|
-
messages?: ClaudeMessage[];
|
|
2768
|
-
service: string;
|
|
2769
|
-
owner: string;
|
|
2770
|
-
userId?: string;
|
|
2771
|
-
model?: string;
|
|
2772
|
-
maxTokens?: number;
|
|
2773
|
-
system?: string;
|
|
2774
|
-
mcpServer: ClaudeMcpServerRequest;
|
|
2775
|
-
extractContent?: ExtractDirective[];
|
|
2776
|
-
fileUrls?: FileUrlDirective[];
|
|
2777
|
-
onResponse?: (res: any) => void;
|
|
2778
|
-
onError?: (err: any) => void;
|
|
2779
|
-
/**
|
|
2780
|
-
* Attach Claude's `web_fetch` to this turn. A per-call host value under the
|
|
2781
|
-
* same ceiling rule as the config option: the project's `web_access` setting
|
|
2782
|
-
* is the most a turn can have, and `false` here (or in the config) takes it
|
|
2783
|
-
* off. Omitted follows the config option and the project. See config.ts
|
|
2784
|
-
* resolveWebAccess.
|
|
2785
|
-
*/
|
|
2786
|
-
webAccess?: boolean;
|
|
2787
|
-
};
|
|
2788
|
-
declare const POLL_INTERVAL = 3000;
|
|
2789
|
-
declare const STREAM_POLL_INTERVAL = 1000;
|
|
2790
|
-
declare const MAX_CONCURRENT_BG_POLLS = 6;
|
|
2791
|
-
/**
|
|
2792
|
-
* What a chat turn hands the OpenAI request builder about itself, and what the builder
|
|
2793
|
-
* writes back. Created per turn by ChatSession; a host that calls the builder directly
|
|
2794
|
-
* and passes nothing gets exactly the request it always got.
|
|
2795
|
-
*/
|
|
2796
|
-
type ChatTurnContext = {
|
|
2797
|
-
/**
|
|
2798
|
-
* Reuse the MCP tool listing OpenAI returned on an earlier chat turn (OpenAI only).
|
|
2799
|
-
* Every OpenAI turn otherwise starts with OpenAI asking our MCP server for its tools,
|
|
2800
|
-
* four sequential requests (server/discover, initialize, notifications/initialized,
|
|
2801
|
-
* tools/list), about 0.6 s before the model starts. OpenAI's docs: "As long as the
|
|
2802
|
-
* mcp_list_tools item is present in the context of an API request, the API will not
|
|
2803
|
-
* fetch a list of tools from the MCP server again at each turn."
|
|
2804
|
-
*/
|
|
2805
|
-
reuseMcpToolList?: boolean;
|
|
2806
|
-
/** Who the turn runs as. Part of the listing key: a different user can see a different list. */
|
|
2807
|
-
userId?: string;
|
|
2808
|
-
/** Written by the builder: the key this turn's listing is stored under. */
|
|
2809
|
-
mcpToolsKey?: string;
|
|
2810
|
-
/** Written by the builder: true when a stored listing rode in this turn's input. */
|
|
2811
|
-
mcpToolsInjected?: boolean;
|
|
2812
|
-
/** Written by the builder: the project the listing belongs to (for the per-project off verdict). */
|
|
2813
|
-
mcpToolsService?: string;
|
|
2814
|
-
/** Written by the builder: the id of the listing that rode in this turn's input. */
|
|
2815
|
-
mcpToolsItemId?: string;
|
|
2816
|
-
/** Set by ChatSession once the turn's outcome was applied, so a later handler cannot apply it twice. */
|
|
2817
|
-
settled?: boolean;
|
|
2818
|
-
};
|
|
2819
|
-
declare function callClaudeWithMcp({ prompt, messages, service, owner, userId, model, maxTokens, system, mcpServer, extractContent, fileUrls, webAccess, }: CallClaudeWithMcpParams): Promise<any>;
|
|
2820
|
-
declare function callClaudeWithPublicMcp(prompt: string, service: string, owner: string, messages?: ClaudeMessage[], system?: string, model?: string, userId?: string, extractContent?: ExtractDirective[], fileUrls?: FileUrlDirective[], onResponse?: (res: any) => void, onError?: (err: any) => void, mcpScope?: {
|
|
2821
|
-
anonymous?: boolean;
|
|
2822
|
-
publicProjectId?: string;
|
|
2823
|
-
}): Promise<any>;
|
|
2824
|
-
declare function callOpenAIWithPublicMcp(prompt: string, service: string, owner: string, messages?: OpenAIMessage[], system?: string, model?: string, userId?: string, extractContent?: ExtractDirective[], fileUrls?: FileUrlDirective[], onResponse?: (res: any) => void, onError?: (err: any) => void, mcpScope?: {
|
|
2825
|
-
anonymous?: boolean;
|
|
2826
|
-
publicProjectId?: string;
|
|
2827
|
-
}, turn?: ChatTurnContext): Promise<any>;
|
|
2828
|
-
type AttachmentSaveInfo = {
|
|
2829
|
-
platform: 'claude' | 'openai';
|
|
2830
|
-
model?: string;
|
|
2831
|
-
service: string;
|
|
2832
|
-
/** The PUBLIC project ID (formatted token, skapi.project_id). Shown to the model; falls back to `service`. */
|
|
2833
|
-
publicProjectId?: string;
|
|
2834
|
-
owner: string;
|
|
2835
|
-
/**
|
|
2836
|
-
* Queue base for this indexing pass: "<userId>-bg". REQUIRED, and it must be
|
|
2837
|
-
* the SAME value the chat turn uses (ChatSession.dispatchComposedMessage's
|
|
2838
|
-
* `id.userId || id.projectId`) — the backend serialises requests that share a
|
|
2839
|
-
* queue name and runs different ones IN PARALLEL, so a pass enqueued under a
|
|
2840
|
-
* different base does not hold the chat back at all. It was optional once,
|
|
2841
|
-
* defaulting to `service`; the chatbox omitted it, and its files were indexed
|
|
2842
|
-
* on "<projectId>-bg" while its question ran on "<userId>-bg" — the question
|
|
2843
|
-
* was answered from a file nothing had read yet. Pass `userId || projectId`.
|
|
2844
|
-
*/
|
|
2845
|
-
userId: string;
|
|
2846
|
-
serviceName?: string;
|
|
2847
|
-
serviceDescription?: string;
|
|
2848
|
-
attachment: {
|
|
2849
|
-
name: string;
|
|
2850
|
-
storagePath: string;
|
|
2851
|
-
mime?: string;
|
|
2852
|
-
size?: number;
|
|
2853
|
-
url: string;
|
|
2854
|
-
/**
|
|
2855
|
-
* Access group this file's records are written at (the uploader's choice,
|
|
2856
|
-
* already applied to the "src::" record). Threaded into the indexing
|
|
2857
|
-
* prompts so the agent's own records land in the same group; omitted
|
|
2858
|
-
* means "authorized", the group everything used before the setting existed.
|
|
2859
|
-
*/
|
|
2860
|
-
accessGroup?: 'public' | 'authorized' | 'private';
|
|
2861
|
-
};
|
|
2862
|
-
/**
|
|
2863
|
-
* Content parsed CLIENT-SIDE by an attachment-parser plugin (e.g. an .hwp
|
|
2864
|
-
* parser). When set, it is inlined into the indexing message verbatim and
|
|
2865
|
-
* takes precedence over server-side office extraction / web_fetch.
|
|
2866
|
-
*/
|
|
2867
|
-
parsedContent?: string;
|
|
2868
|
-
/**
|
|
2869
|
-
* True for a RESUME pass: a previous indexing pass could not finish this (large)
|
|
2870
|
-
* file, so continue it - always via readFileContent paging, with a "continue"
|
|
2871
|
-
* message telling the agent to resume from where the saved records leave off.
|
|
2872
|
-
*/
|
|
2873
|
-
continueIndexing?: boolean;
|
|
2874
|
-
/**
|
|
2875
|
-
* For an image-vision file (PDF), the 0-based PAGE the render window should start at.
|
|
2876
|
-
* The worker renders [renderFrom, renderFrom+RENDER_PAGES_PER_WINDOW) and injects them
|
|
2877
|
-
* as image blocks; the resume loop advances this by a window each pass.
|
|
2878
|
-
*/
|
|
2879
|
-
renderFrom?: number;
|
|
2880
|
-
};
|
|
2881
|
-
declare function notifyAgentSaveAttachment(info: AttachmentSaveInfo): Promise<any>;
|
|
2882
|
-
declare function extractClaudeText(response: any): any;
|
|
2883
|
-
declare function extractOpenAIText(response: any): any;
|
|
2884
|
-
declare function listClaudeModels(service: string, owner: string): Promise<any>;
|
|
2885
|
-
declare function listOpenAIModels(service: string, owner: string): Promise<any>;
|
|
2886
|
-
declare const BG_INDEXING_QUEUE_SUFFIX = "-bg";
|
|
2887
|
-
/**
|
|
2888
|
-
* unique_id of the durable "indexing finished" marker record for a stored file.
|
|
2889
|
-
*
|
|
2890
|
-
* Written by the BACKEND (the polling worker calls the MCP server's
|
|
2891
|
-
* /internal/index-complete at the end of an auto_continue chain whose final
|
|
2892
|
-
* window reported no more content) and, for completions a client knows
|
|
2893
|
-
* deterministically (single-pass settle, client-chain completion token), by the
|
|
2894
|
-
* consumer's mintIndexDoneMarker hook — never by the model.
|
|
2895
|
-
* The marker record carries `reference: "src::<path>"`, so the reindex flow's
|
|
2896
|
-
* delete of the src:: record cascades to it and a re-run starts unmarked.
|
|
2897
|
-
*
|
|
2898
|
-
* Existence semantics: present = the whole file was read to the end. Absent =
|
|
2899
|
-
* unknown (still running, failed partway, indexed before this marker existed,
|
|
2900
|
-
* or a single-pass run minted before the client hook existed) - callers must
|
|
2901
|
-
* fall back to the live-queue probe (fetchLiveIndexingKeys) before reading
|
|
2902
|
-
* absence as anything.
|
|
2903
|
-
*/
|
|
2904
|
-
/** What the MCP's /internal/index-reset answered. */
|
|
2905
|
-
type IndexResetResult = {
|
|
2906
|
-
path: string;
|
|
2907
|
-
/** The access group the old file record had, or null when there was none. */
|
|
2908
|
-
access_group: string | number | null;
|
|
2909
|
-
removed: number;
|
|
2910
|
-
missing: number;
|
|
2911
|
-
failed: number;
|
|
2912
|
-
decorations: number;
|
|
2913
|
-
ambiguous: number;
|
|
2914
|
-
ms?: number;
|
|
2915
|
-
};
|
|
2916
|
-
/**
|
|
2917
|
-
* Clear a file's index on the SERVER before a Reindex or an Overwrite (owner,
|
|
2918
|
-
* 2026-11-20): the MCP's /internal/index-reset removes the file record (and, through its
|
|
2919
|
-
* cascade, everything referencing it), the agent's decorated per-window ids and the
|
|
2920
|
-
* done::/run:: markers, in parallel, as the signed-in user. Reached through the host's
|
|
2921
|
-
* forwardRequest with "$ACCESS_TOKEN", which skapi fills in with the caller's own token,
|
|
2922
|
-
* so no client code ever holds it.
|
|
2923
|
-
*
|
|
2924
|
-
* Resolves to the server's answer, or null when the call could not be made or answered
|
|
2925
|
-
* something else (an older MCP without the route, a timeout): the caller then clears
|
|
2926
|
-
* the index itself, as it always did. Never rejects.
|
|
2927
|
-
*/
|
|
2928
|
-
declare function resetFileIndexOnServer(args: {
|
|
2929
|
-
service: string;
|
|
2930
|
-
owner?: string;
|
|
2931
|
-
storagePath: string;
|
|
2932
|
-
}): Promise<IndexResetResult | null>;
|
|
2933
|
-
declare function indexDoneUniqueId(storagePath: string): string;
|
|
2934
|
-
/**
|
|
2935
|
-
* unique_id of the per-file indexing RUN record.
|
|
2936
|
-
*
|
|
2937
|
-
* One record per storage path, newest run wins (a reindex's delete-then-repost
|
|
2938
|
-
* of src:: cascade-deletes the old record first, exactly like done::). Minted
|
|
2939
|
-
* status='working' by the client the moment it enqueues a run's FIRST pass, and
|
|
2940
|
-
* closed (done/error/cancelled) by whichever side observes the ending: the
|
|
2941
|
-
* worker via the MCP internal routes for worker-driven chains, the client for
|
|
2942
|
-
* deterministic settles, cancels, and dispatch failures. It exists so chat rows
|
|
2943
|
-
* and files-page badges can answer "which runs exist and how did they end"
|
|
2944
|
-
* from ONE records query instead of scanning bg history.
|
|
2945
|
-
*
|
|
2946
|
-
* A 'working' record is a claim, not proof: a chain that dies without reaching
|
|
2947
|
-
* any error path leaves it dangling, so readers must treat a stale 'working'
|
|
2948
|
-
* (old `started`, no live-queue confirmation) as unknown, never as live.
|
|
2949
|
-
*/
|
|
2950
|
-
declare function runIndexUniqueId(storagePath: string): string;
|
|
2951
|
-
type IndexRunStatus = 'working' | 'done' | 'error' | 'cancelled';
|
|
2952
|
-
type IndexRunPatch = {
|
|
2953
|
-
status: IndexRunStatus;
|
|
2954
|
-
filename?: string;
|
|
2955
|
-
started?: number;
|
|
2956
|
-
finished?: number;
|
|
2957
|
-
error?: string;
|
|
2958
|
-
queue?: string;
|
|
2959
|
-
/** Chat that owns this run. A run:: record is keyed by storage path alone,
|
|
2960
|
-
* but a chat is per (project, platform) — without this the Claude chat's
|
|
2961
|
-
* runs surfaced as rows in the same project's ChatGPT chat, where their
|
|
2962
|
-
* passes can never load and the queue probe can never see them. */
|
|
2963
|
-
platform?: 'claude' | 'openai';
|
|
2964
|
-
};
|
|
2965
|
-
/**
|
|
2966
|
-
* Fire-and-forget wrapper over the consumer's upsertIndexRunRecord hook.
|
|
2967
|
-
* Safe everywhere: missing hook, unconfigured engine, and consumer throws all
|
|
2968
|
-
* reduce to a no-op — a run record must never be able to break the run itself.
|
|
2969
|
-
*/
|
|
2970
|
-
declare function upsertIndexRunRecordSafe(service: string, storagePath: string, patch: IndexRunPatch): void;
|
|
2971
|
-
/**
|
|
2972
|
-
* The one place the background-indexing queue name is spelled out. The backend
|
|
2973
|
-
* serialises requests sharing a queue name and runs different names in PARALLEL,
|
|
2974
|
-
* so every indexing pass AND the chat turn that must wait behind them have to
|
|
2975
|
-
* resolve to the identical string — see AttachmentSaveInfo.userId for what
|
|
2976
|
-
* happens when they do not.
|
|
2977
|
-
*/
|
|
2978
|
-
declare function bgIndexingQueueName(userId?: string, service?: string): string;
|
|
2979
|
-
/**
|
|
2980
|
-
* True when a request belongs to the background-indexing queue.
|
|
2981
|
-
*
|
|
2982
|
-
* Accepts BOTH shapes this value arrives in: the bare queue name the client sends
|
|
2983
|
-
* ("<userId>-bg"), and the server qid that comes back on history/poll responses
|
|
2984
|
-
* ("<service>:<queue>|<seq>"). Testing the tail of the raw value only works for the
|
|
2985
|
-
* first: a qid ends in "|<seq>", so `endsWith('-bg')` is always false for it — which
|
|
2986
|
-
* silently meant history items were NEVER recognised as background tasks.
|
|
2987
|
-
*/
|
|
2988
|
-
declare function isBgIndexingQueue(queueName?: string): boolean;
|
|
2989
|
-
type BgTaskEntry = {
|
|
2990
|
-
projectId: string;
|
|
2991
|
-
platform: 'claude' | 'openai';
|
|
2992
|
-
id: string;
|
|
2993
|
-
filename: string;
|
|
2994
|
-
storagePath?: string;
|
|
2995
|
-
isReindex?: boolean;
|
|
2996
|
-
mime?: string;
|
|
2997
|
-
size?: number;
|
|
2998
|
-
status: 'running' | 'pending';
|
|
2999
|
-
poll: ((opts: {
|
|
3000
|
-
latency: number;
|
|
3001
|
-
notify?: boolean;
|
|
3002
|
-
onResponse?: (res: any, meta?: {
|
|
3003
|
-
executed?: number;
|
|
3004
|
-
}) => void;
|
|
3005
|
-
}) => Promise<any>) | undefined;
|
|
3006
|
-
/** How many CONTINUE passes have already run for this file (resume-across-passes). */
|
|
3007
|
-
resumePass?: number;
|
|
3008
|
-
/** The STAGED chat turn these files were attached to (ChatSession.stageOutgoingMessage).
|
|
3009
|
-
* drainBgTaskQueue inserts this pass's bubble directly ABOVE that turn's bubble, so the
|
|
3010
|
-
* collapsed row sits where the reader expects it — right before the message the files
|
|
3011
|
-
* came with — from the moment it appears, instead of the turn being moved down past it
|
|
3012
|
-
* once everything finishes. Absent for work with no chat turn behind it (the dbfile
|
|
3013
|
-
* page, an attachment-only send, a worker-adopted pass), which appends as before. */
|
|
3014
|
-
stageId?: string;
|
|
3015
|
-
/** Settled from the 10-second queue check instead of its own poll (owner, 2026-11-20).
|
|
3016
|
-
* Set by drainBgTaskQueue on every pass when the host has csrHistoryItemLookup, and on
|
|
3017
|
-
* adoption for the worker's lanes. Polls on one queue run one at a time in skapi-js, so
|
|
3018
|
-
* a pass that finished waited behind every pass ahead of it; see
|
|
3019
|
-
* ChatSession._settleByListing. */
|
|
3020
|
-
byListing?: boolean;
|
|
3021
|
-
/** When this client first tracked the pass (ms). A pass missing from a listing taken
|
|
3022
|
-
* BEFORE that proves nothing about it. */
|
|
3023
|
-
adoptedAt?: number;
|
|
3024
|
-
};
|
|
3025
|
-
declare const INDEXING_COMPLETE_MARKER = "INDEXING_COMPLETE";
|
|
3026
|
-
declare const EMPTY_INDEXING_REPLY = "Finished reading this file.";
|
|
3027
|
-
/**
|
|
3028
|
-
* `queue` narrows the fetch to one processing chain; `status` narrows it to items
|
|
3029
|
-
* in one state. Passing both is how the client asks "is there still unresolved
|
|
3030
|
-
* work on the background-indexing queue?" without pulling a page of chat history
|
|
3031
|
-
* (see ChatSession._adoptWorkerIndexingPasses) — the server answers that from a
|
|
3032
|
-
* status-keyed index, so the reply carries only the live items, not the bodies of
|
|
3033
|
-
* everything already finished.
|
|
3034
|
-
*/
|
|
3035
|
-
declare function getChatHistory(params: {
|
|
3036
|
-
service?: string;
|
|
3037
|
-
owner?: string;
|
|
3038
|
-
platform: 'claude' | 'openai';
|
|
3039
|
-
queue?: string;
|
|
3040
|
-
status?: 'pending' | 'running' | 'resolved' | 'failed';
|
|
3041
|
-
/** Exact-queue listing: without it the qid range is a PREFIX match, so
|
|
3042
|
-
* queue "u1" also returns "u1-bg" rows. Requires the updated polling
|
|
3043
|
-
* lambda; older backends ignore it (harmless, wider results). */
|
|
3044
|
-
queue_exact?: boolean;
|
|
3045
|
-
/** Label/marker STUBS instead of full bodies (see the polling lambda).
|
|
3046
|
-
* Older backends ignore it and return full items. */
|
|
3047
|
-
compact?: boolean;
|
|
3048
|
-
/** Drop one queue's rows from an id-prefix listing — how the surface
|
|
3049
|
-
* chat is fetched WITHOUT the bg-indexing queue while legacy items on
|
|
3050
|
-
* odd queue names survive. Older backends ignore it. */
|
|
3051
|
-
queue_exclude?: string;
|
|
3052
|
-
}, fetchOptions: Record<string, any>): Promise<any>;
|
|
3053
|
-
/** Full server-side id of one history item, for a csr-poll POINT LOOKUP (the
|
|
3054
|
-
* single-item path returns the item WITH bodies — how an expanded row fetches
|
|
3055
|
-
* the passes a compact listing stubbed out). Mirrors the id the SDK builds:
|
|
3056
|
-
* `[METHOD]url#service:` + the item's own `stamp:entropy` id. */
|
|
3057
|
-
declare function buildHistoryItemFullId(platform: 'claude' | 'openai', service: string, itemId: string): string;
|
|
3058
|
-
|
|
3059
|
-
/**
|
|
3060
|
-
* ChatSession host adapter + state types.
|
|
2824
|
+
* ChatSession host adapter + state types.
|
|
3061
2825
|
*
|
|
3062
2826
|
* ChatSession is DOM-free and Vue-free; the consumer (bunnyquery widget or the
|
|
3063
2827
|
* agent.vue chatbox) implements `ChatHost` to bridge identity, rendering, scroll,
|
|
@@ -3197,10 +2961,10 @@ interface ChatMessage {
|
|
|
3197
2961
|
/** PROTOCOL + PRESENTATIONAL: this bubble is being painted from a LIVE stream.
|
|
3198
2962
|
*
|
|
3199
2963
|
* It sits alongside `isPending`, never instead of it. The bubble is still the
|
|
3200
|
-
* turn's "Thinking..." placeholder as far as every
|
|
3201
|
-
*
|
|
3202
|
-
*
|
|
3203
|
-
*
|
|
2964
|
+
* turn's "Thinking..." placeholder as far as every settle is concerned (the apply
|
|
2965
|
+
* funnel, ChatSession.applyTerminal, finds a turn's waiting bubble by its server id
|
|
2966
|
+
* AND isPending), and clearing that flag to mean "it has text now" would make the
|
|
2967
|
+
* turn read as already answered, so its real answer would be refused.
|
|
3204
2968
|
* What this adds is the one thing those mechanisms do not care about and the VIEW
|
|
3205
2969
|
* does: `content` is already worth rendering, so draw the text instead of the
|
|
3206
2970
|
* spinner.
|
|
@@ -3300,6 +3064,16 @@ interface ChatMessage {
|
|
|
3300
3064
|
* never carries it, so neither view needs a second test. */
|
|
3301
3065
|
_tsStart?: number;
|
|
3302
3066
|
_ownerKey?: string;
|
|
3067
|
+
/** The client reference the turn was sent with (reconciler plan, section 3 item 9). On
|
|
3068
|
+
* the user bubble of a send; a send whose ack was lost is matched to its row by it. */
|
|
3069
|
+
_cref?: string;
|
|
3070
|
+
/** A send whose POST got no answer while the reconciler looks for its row by `_cref`:
|
|
3071
|
+
* kept through history merges until its row is found or it is "Not sent". */
|
|
3072
|
+
_unconfirmed?: boolean;
|
|
3073
|
+
/** A send whose POST got no answer and whose row the server never showed: the reply
|
|
3074
|
+
* bubble says "Not sent. Retry?" and ChatSession.retryNotSent(msg) sends it again.
|
|
3075
|
+
* Never retried on its own. */
|
|
3076
|
+
_notSent?: boolean;
|
|
3303
3077
|
}
|
|
3304
3078
|
interface ChatState {
|
|
3305
3079
|
messages: ChatMessage[];
|
|
@@ -3377,6 +3151,31 @@ interface ChatState {
|
|
|
3377
3151
|
stoppedIndexIds: {
|
|
3378
3152
|
[serverItemId: string]: boolean;
|
|
3379
3153
|
};
|
|
3154
|
+
/** The reconciler's last look failed on the way (network, timeout, 429, 5xx) and it is
|
|
3155
|
+
* trying again with backoff. Nothing on screen was changed by the failure; a view may
|
|
3156
|
+
* show a small "Reconnecting..." note while this is true. */
|
|
3157
|
+
reconnecting?: boolean;
|
|
3158
|
+
/** The reconciler's reads are refused for want of a sign-in. Looks resume on the next
|
|
3159
|
+
* sign-in (ChatSession.noteSignedIn); a view may say "Sign in to see the latest
|
|
3160
|
+
* answers" while this is true. */
|
|
3161
|
+
signInNeeded?: boolean;
|
|
3162
|
+
/** The background indexing queue of a project as the reconciler last read it, for a
|
|
3163
|
+
* page that shows indexing state with or without a chat view (the dashboard's files
|
|
3164
|
+
* page), by project id. Filled while someone watches it (ChatSession.watchIndexQueue).
|
|
3165
|
+
* `keys` holds the storage paths and file names with a pass waiting or running;
|
|
3166
|
+
* `checked` is false when the read came back cut off (absence then proves nothing);
|
|
3167
|
+
* `at` is when the read ran (a re-served read keeps its time, so two different `at`
|
|
3168
|
+
* values are two independent looks). */
|
|
3169
|
+
indexQueues?: {
|
|
3170
|
+
[projectId: string]: IndexQueueSnapshot;
|
|
3171
|
+
};
|
|
3172
|
+
}
|
|
3173
|
+
interface IndexQueueSnapshot {
|
|
3174
|
+
keys: {
|
|
3175
|
+
[fileKey: string]: true;
|
|
3176
|
+
};
|
|
3177
|
+
checked: boolean;
|
|
3178
|
+
at: number;
|
|
3380
3179
|
}
|
|
3381
3180
|
interface ChatHost {
|
|
3382
3181
|
/** Read live (platform/model/name can change between sends). */
|
|
@@ -3426,6 +3225,21 @@ interface ChatHost {
|
|
|
3426
3225
|
formatIndexingLabel(name: string, mime?: string, size?: number | null, storagePath?: string, reindex?: boolean, continued?: boolean): string;
|
|
3427
3226
|
/** drainBgTaskQueue is a no-op until the chat view is mounted. */
|
|
3428
3227
|
isViewMounted(): boolean;
|
|
3228
|
+
/**
|
|
3229
|
+
* Optional. Read the run:: records of these files again (reconciler plan, section 3
|
|
3230
|
+
* item 1). The engine follows a file whose record says 'working' (syncFileRuns) until
|
|
3231
|
+
* the record says it ended or a complete look at the queue finds no pass of it, and
|
|
3232
|
+
* asks for this every 30 seconds meanwhile, while the file is not seen live. The host
|
|
3233
|
+
* re-reads its records and hands the 'working' paths back through syncFileRuns.
|
|
3234
|
+
*/
|
|
3235
|
+
recheckFileRuns?(projectId: string, storagePaths: string[]): void;
|
|
3236
|
+
/**
|
|
3237
|
+
* Optional. A provider answer (or a provider error) just settled a request of this
|
|
3238
|
+
* project, whichever path read it (a poll, a look, a stream). The host may judge the
|
|
3239
|
+
* project's API key from it (web-bunnyquery's "Your API key is invalid"). Called once
|
|
3240
|
+
* per request, after the bubble is written.
|
|
3241
|
+
*/
|
|
3242
|
+
onProviderAnswer?(projectId: string, platform: 'claude' | 'openai', result: any): void;
|
|
3429
3243
|
/** Clear-horizon timestamp (localStorage, per service#platform) — view-owned. */
|
|
3430
3244
|
getClearedAt(): number;
|
|
3431
3245
|
uploadFile(args: {
|
|
@@ -3493,26 +3307,454 @@ interface ChatHost {
|
|
|
3493
3307
|
* the chip says so. Null, a rejection or a missing hook all mean "upload as
|
|
3494
3308
|
* usual"; the engine's findDuplicateUpload is the ready-made implementation.
|
|
3495
3309
|
*/
|
|
3496
|
-
findDuplicateUpload?(file: {
|
|
3497
|
-
name: string;
|
|
3498
|
-
size: number;
|
|
3499
|
-
}): Promise<{
|
|
3500
|
-
storagePath: string;
|
|
3501
|
-
} | null> | {
|
|
3502
|
-
storagePath: string;
|
|
3503
|
-
} | null;
|
|
3504
|
-
/** Map a relative path to the consumer's db storage key (e.g. uid-prefixed). */
|
|
3505
|
-
storagePathFor(relPath: string): string;
|
|
3506
|
-
getMimeType(name: string): string | null;
|
|
3507
|
-
/** Non-dismissible "file exists" prompt → skip, keep+reindex, or overwrite. */
|
|
3508
|
-
promptOverwrite(filename: string): Promise<'overwrite' | 'reindex' | 'skip'>;
|
|
3509
|
-
/** Clear the "apply to all" overwrite choice at the start of a batch. */
|
|
3510
|
-
resetOverwriteBatch(): void;
|
|
3511
|
-
/** Re-render the attachment chip row (progress / status). */
|
|
3512
|
-
renderAttachmentChips(): void;
|
|
3513
|
-
/** Enable/disable composer controls during an upload batch. */
|
|
3514
|
-
updateComposerControls(): void;
|
|
3515
|
-
}
|
|
3310
|
+
findDuplicateUpload?(file: {
|
|
3311
|
+
name: string;
|
|
3312
|
+
size: number;
|
|
3313
|
+
}): Promise<{
|
|
3314
|
+
storagePath: string;
|
|
3315
|
+
} | null> | {
|
|
3316
|
+
storagePath: string;
|
|
3317
|
+
} | null;
|
|
3318
|
+
/** Map a relative path to the consumer's db storage key (e.g. uid-prefixed). */
|
|
3319
|
+
storagePathFor(relPath: string): string;
|
|
3320
|
+
getMimeType(name: string): string | null;
|
|
3321
|
+
/** Non-dismissible "file exists" prompt → skip, keep+reindex, or overwrite. */
|
|
3322
|
+
promptOverwrite(filename: string): Promise<'overwrite' | 'reindex' | 'skip'>;
|
|
3323
|
+
/** Clear the "apply to all" overwrite choice at the start of a batch. */
|
|
3324
|
+
resetOverwriteBatch(): void;
|
|
3325
|
+
/** Re-render the attachment chip row (progress / status). */
|
|
3326
|
+
renderAttachmentChips(): void;
|
|
3327
|
+
/** Enable/disable composer controls during an upload batch. */
|
|
3328
|
+
updateComposerControls(): void;
|
|
3329
|
+
}
|
|
3330
|
+
|
|
3331
|
+
declare const MCP_NAME = "BunnyQuery";
|
|
3332
|
+
declare const DEFAULT_CLAUDE_MODEL = "claude-haiku-5-5";
|
|
3333
|
+
declare const DEFAULT_OPENAI_MODEL = "gpt-6-luna";
|
|
3334
|
+
/**
|
|
3335
|
+
* THE two `stream` flags of a streamed chat turn, produced together or not at all.
|
|
3336
|
+
*
|
|
3337
|
+
* There are two of them and they are NOT the same flag:
|
|
3338
|
+
*
|
|
3339
|
+
* * `transport.stream` is SKAPI's. It tells the polling worker to read the
|
|
3340
|
+
* destination's response incrementally and append the raw bytes to the chunk
|
|
3341
|
+
* table, and it is never sent on to the destination.
|
|
3342
|
+
* * `body.stream` is the DESTINATION's own field, and BunnyQuery is the party
|
|
3343
|
+
* that may set it: skapi relays bytes and knows no vendor, so it cannot know
|
|
3344
|
+
* that Anthropic Messages and OpenAI Responses both happen to spell it
|
|
3345
|
+
* `stream` at the top level of the body.
|
|
3346
|
+
*
|
|
3347
|
+
* Setting one without the other fails QUIETLY, which is why they are produced by
|
|
3348
|
+
* one function from one boolean and returned as one object:
|
|
3349
|
+
*
|
|
3350
|
+
* * body streams, skapi buffers -> the row stores an SSE TRANSCRIPT where
|
|
3351
|
+
* extractClaudeText / extractOpenAIText expect a parsed document, so the turn
|
|
3352
|
+
* reads back as an empty answer with nothing in the logs to say why.
|
|
3353
|
+
* * skapi streams, the body never asked -> the destination sends one plain
|
|
3354
|
+
* document, the relay chops it into chunks, the frame parser finds no framing
|
|
3355
|
+
* at all, and the row settles with a status and no body.
|
|
3356
|
+
*
|
|
3357
|
+
* Two frozen constants rather than a fresh object per call: the pair is a
|
|
3358
|
+
* CONSTANT, and an object literal built at each call site is exactly the shape
|
|
3359
|
+
* that drifts when someone edits one arm.
|
|
3360
|
+
*/
|
|
3361
|
+
type ChatStreamWiring = {
|
|
3362
|
+
/** Spread into the forwardRequest OPTIONS (skapi's relay switch). `realtime`
|
|
3363
|
+
* belongs here and never in `body`: it is skapi's, not the destination's. */
|
|
3364
|
+
transport: {
|
|
3365
|
+
stream?: true;
|
|
3366
|
+
realtime?: true;
|
|
3367
|
+
};
|
|
3368
|
+
/** Spread into `data` (the destination's own switch). */
|
|
3369
|
+
body: {
|
|
3370
|
+
stream?: true;
|
|
3371
|
+
};
|
|
3372
|
+
};
|
|
3373
|
+
declare function chatStreamWiring(queue?: string): ChatStreamWiring;
|
|
3374
|
+
/**
|
|
3375
|
+
* The body fields a CHAT turn's answer mode adds, for the one provider and model the turn
|
|
3376
|
+
* runs on. An empty object, i.e. nothing at all, for 'standard' (the default) and for any
|
|
3377
|
+
* model not known to accept the field, so a project that never set a mode sends the exact
|
|
3378
|
+
* request it sent before the setting existed. OpenAI takes `reasoning: {effort}`, Claude
|
|
3379
|
+
* takes `output_config: {effort}`. Never used by an indexing pass.
|
|
3380
|
+
*/
|
|
3381
|
+
declare function chatEffortFields(platform: 'claude' | 'openai', model: string | undefined, mode: AnswerMode | undefined): Record<string, any>;
|
|
3382
|
+
/** How a given model should be shown a rendered document. */
|
|
3383
|
+
type VisionProfile = {
|
|
3384
|
+
/** Per-image `detail` (OpenAI only). */
|
|
3385
|
+
detail: string;
|
|
3386
|
+
/** Pages the worker renders into one window. */
|
|
3387
|
+
pagesPerWindow: number;
|
|
3388
|
+
/** Horizontal bands per page; 1 renders the whole page as one image. */
|
|
3389
|
+
tile: number;
|
|
3390
|
+
};
|
|
3391
|
+
/**
|
|
3392
|
+
* Resolve the render profile for a model.
|
|
3393
|
+
*
|
|
3394
|
+
* Three tiers, and they fail for different reasons, which is why one set of knobs cannot
|
|
3395
|
+
* serve all of them:
|
|
3396
|
+
* - full: everything ABOVE gpt-5.4-nano - the base models, mini, and every gpt-5.6
|
|
3397
|
+
* including 5.6-nano. These already transcribe dense scans correctly, so they get
|
|
3398
|
+
* 'original' detail and are otherwise untouched.
|
|
3399
|
+
* - gpt-5.4-nano: also gets 'original', so it sees exactly the SAME pixels as the full
|
|
3400
|
+
* tier. Its gap therefore is not resolution, and tiling would do nothing for it. What
|
|
3401
|
+
* it lacks is room: a smaller window leaves the same output budget divided between
|
|
3402
|
+
* fewer pages.
|
|
3403
|
+
* - downsampled (below the 'original' floor: gpt-5.3-nano, gpt-5-nano, gpt-4.1-nano):
|
|
3404
|
+
* capped at 'high', which resamples the page onto a 512px grid no matter what DPI it
|
|
3405
|
+
* was rendered at. Render resolution is wasted on these entirely; the only way to give
|
|
3406
|
+
* them readable text is to make each image cover less of the page, which is `tile`.
|
|
3407
|
+
*/
|
|
3408
|
+
declare function getVisionProfile(model?: string): VisionProfile;
|
|
3409
|
+
type ClaudeRole = 'user' | 'assistant';
|
|
3410
|
+
type ClaudeMessage = {
|
|
3411
|
+
role: ClaudeRole;
|
|
3412
|
+
content: string;
|
|
3413
|
+
};
|
|
3414
|
+
type OpenAIMessage = {
|
|
3415
|
+
role: ClaudeRole;
|
|
3416
|
+
content: string;
|
|
3417
|
+
};
|
|
3418
|
+
type ClaudeMcpToolConfig = {
|
|
3419
|
+
enabled?: boolean;
|
|
3420
|
+
defer_loading?: boolean;
|
|
3421
|
+
};
|
|
3422
|
+
type ClaudeMcpServerRequest = {
|
|
3423
|
+
name: string;
|
|
3424
|
+
url: string;
|
|
3425
|
+
authorizationToken?: string;
|
|
3426
|
+
defaultConfig?: ClaudeMcpToolConfig;
|
|
3427
|
+
configs?: Record<string, ClaudeMcpToolConfig>;
|
|
3428
|
+
};
|
|
3429
|
+
declare function transformContentWithImages(content: string): string | Array<Record<string, any>>;
|
|
3430
|
+
declare function transformContentWithOpenAIImages(content: string, detail?: string): string | Array<Record<string, any>>;
|
|
3431
|
+
type CallClaudeWithMcpParams = {
|
|
3432
|
+
prompt: string;
|
|
3433
|
+
messages?: ClaudeMessage[];
|
|
3434
|
+
service: string;
|
|
3435
|
+
owner: string;
|
|
3436
|
+
userId?: string;
|
|
3437
|
+
model?: string;
|
|
3438
|
+
maxTokens?: number;
|
|
3439
|
+
system?: string;
|
|
3440
|
+
mcpServer: ClaudeMcpServerRequest;
|
|
3441
|
+
extractContent?: ExtractDirective[];
|
|
3442
|
+
fileUrls?: FileUrlDirective[];
|
|
3443
|
+
onResponse?: (res: any) => void;
|
|
3444
|
+
onError?: (err: any) => void;
|
|
3445
|
+
/**
|
|
3446
|
+
* Attach Claude's `web_fetch` to this turn. A per-call host value under the
|
|
3447
|
+
* same ceiling rule as the config option: the project's `web_access` setting
|
|
3448
|
+
* is the most a turn can have, and `false` here (or in the config) takes it
|
|
3449
|
+
* off. Omitted follows the config option and the project. See config.ts
|
|
3450
|
+
* resolveWebAccess.
|
|
3451
|
+
*/
|
|
3452
|
+
webAccess?: boolean;
|
|
3453
|
+
/** The send's client reference (ChatTurnContext.cref), passed to forwardRequest. */
|
|
3454
|
+
cref?: string;
|
|
3455
|
+
};
|
|
3456
|
+
declare const POLL_INTERVAL = 3000;
|
|
3457
|
+
declare const STREAM_POLL_INTERVAL = 1000;
|
|
3458
|
+
declare const MAX_CONCURRENT_BG_POLLS = 6;
|
|
3459
|
+
/**
|
|
3460
|
+
* What a chat turn hands the OpenAI request builder about itself, and what the builder
|
|
3461
|
+
* writes back. Created per turn by ChatSession; a host that calls the builder directly
|
|
3462
|
+
* and passes nothing gets exactly the request it always got.
|
|
3463
|
+
*/
|
|
3464
|
+
type ChatTurnContext = {
|
|
3465
|
+
/**
|
|
3466
|
+
* Reuse the MCP tool listing OpenAI returned on an earlier chat turn (OpenAI only).
|
|
3467
|
+
* Every OpenAI turn otherwise starts with OpenAI asking our MCP server for its tools,
|
|
3468
|
+
* four sequential requests (server/discover, initialize, notifications/initialized,
|
|
3469
|
+
* tools/list), about 0.6 s before the model starts. OpenAI's docs: "As long as the
|
|
3470
|
+
* mcp_list_tools item is present in the context of an API request, the API will not
|
|
3471
|
+
* fetch a list of tools from the MCP server again at each turn."
|
|
3472
|
+
*/
|
|
3473
|
+
reuseMcpToolList?: boolean;
|
|
3474
|
+
/** Who the turn runs as. Part of the listing key: a different user can see a different list. */
|
|
3475
|
+
userId?: string;
|
|
3476
|
+
/** Written by the builder: the key this turn's listing is stored under. */
|
|
3477
|
+
mcpToolsKey?: string;
|
|
3478
|
+
/** Written by the builder: true when a stored listing rode in this turn's input. */
|
|
3479
|
+
mcpToolsInjected?: boolean;
|
|
3480
|
+
/** Written by the builder: the project the listing belongs to (for the per-project off verdict). */
|
|
3481
|
+
mcpToolsService?: string;
|
|
3482
|
+
/** Written by the builder: the id of the listing that rode in this turn's input. */
|
|
3483
|
+
mcpToolsItemId?: string;
|
|
3484
|
+
/** Set by ChatSession once the turn's outcome was applied, so a later handler cannot apply it twice. */
|
|
3485
|
+
settled?: boolean;
|
|
3486
|
+
/** The client reference of this send (reconciler plan, section 3 item 9): sent as
|
|
3487
|
+
* forwardRequest's `cref`, so a send whose ack was lost is found by it and never sent
|
|
3488
|
+
* twice. Set by ChatSession only when the host's skapi-js carries it (crefSupported). */
|
|
3489
|
+
cref?: string;
|
|
3490
|
+
};
|
|
3491
|
+
declare function callClaudeWithMcp({ prompt, messages, service, owner, userId, model, maxTokens, system, mcpServer, extractContent, fileUrls, webAccess, cref, }: CallClaudeWithMcpParams): Promise<any>;
|
|
3492
|
+
declare function callClaudeWithPublicMcp(prompt: string, service: string, owner: string, messages?: ClaudeMessage[], system?: string, model?: string, userId?: string, extractContent?: ExtractDirective[], fileUrls?: FileUrlDirective[], onResponse?: (res: any) => void, onError?: (err: any) => void, mcpScope?: {
|
|
3493
|
+
anonymous?: boolean;
|
|
3494
|
+
publicProjectId?: string;
|
|
3495
|
+
}, turn?: ChatTurnContext): Promise<any>;
|
|
3496
|
+
declare function callOpenAIWithPublicMcp(prompt: string, service: string, owner: string, messages?: OpenAIMessage[], system?: string, model?: string, userId?: string, extractContent?: ExtractDirective[], fileUrls?: FileUrlDirective[], onResponse?: (res: any) => void, onError?: (err: any) => void, mcpScope?: {
|
|
3497
|
+
anonymous?: boolean;
|
|
3498
|
+
publicProjectId?: string;
|
|
3499
|
+
}, turn?: ChatTurnContext): Promise<any>;
|
|
3500
|
+
type AttachmentSaveInfo = {
|
|
3501
|
+
platform: 'claude' | 'openai';
|
|
3502
|
+
model?: string;
|
|
3503
|
+
service: string;
|
|
3504
|
+
/** The PUBLIC project ID (formatted token, skapi.project_id). Shown to the model; falls back to `service`. */
|
|
3505
|
+
publicProjectId?: string;
|
|
3506
|
+
owner: string;
|
|
3507
|
+
/**
|
|
3508
|
+
* Queue base for this indexing pass: "<userId>-bg". REQUIRED, and it must be
|
|
3509
|
+
* the SAME value the chat turn uses (ChatSession.dispatchComposedMessage's
|
|
3510
|
+
* `id.userId || id.projectId`) — the backend serialises requests that share a
|
|
3511
|
+
* queue name and runs different ones IN PARALLEL, so a pass enqueued under a
|
|
3512
|
+
* different base does not hold the chat back at all. It was optional once,
|
|
3513
|
+
* defaulting to `service`; the chatbox omitted it, and its files were indexed
|
|
3514
|
+
* on "<projectId>-bg" while its question ran on "<userId>-bg" — the question
|
|
3515
|
+
* was answered from a file nothing had read yet. Pass `userId || projectId`.
|
|
3516
|
+
*/
|
|
3517
|
+
userId: string;
|
|
3518
|
+
serviceName?: string;
|
|
3519
|
+
serviceDescription?: string;
|
|
3520
|
+
attachment: {
|
|
3521
|
+
name: string;
|
|
3522
|
+
storagePath: string;
|
|
3523
|
+
mime?: string;
|
|
3524
|
+
size?: number;
|
|
3525
|
+
url: string;
|
|
3526
|
+
/**
|
|
3527
|
+
* Access group this file's records are written at (the uploader's choice,
|
|
3528
|
+
* already applied to the "src::" record). Threaded into the indexing
|
|
3529
|
+
* prompts so the agent's own records land in the same group; omitted
|
|
3530
|
+
* means "authorized", the group everything used before the setting existed.
|
|
3531
|
+
*/
|
|
3532
|
+
accessGroup?: 'public' | 'authorized' | 'private';
|
|
3533
|
+
};
|
|
3534
|
+
/**
|
|
3535
|
+
* Content parsed CLIENT-SIDE by an attachment-parser plugin (e.g. an .hwp
|
|
3536
|
+
* parser). When set, it is inlined into the indexing message verbatim and
|
|
3537
|
+
* takes precedence over server-side office extraction / web_fetch.
|
|
3538
|
+
*/
|
|
3539
|
+
parsedContent?: string;
|
|
3540
|
+
/**
|
|
3541
|
+
* True for a RESUME pass: a previous indexing pass could not finish this (large)
|
|
3542
|
+
* file, so continue it - always via readFileContent paging, with a "continue"
|
|
3543
|
+
* message telling the agent to resume from where the saved records leave off.
|
|
3544
|
+
*/
|
|
3545
|
+
continueIndexing?: boolean;
|
|
3546
|
+
/** The pass's client reference, passed to forwardRequest's `cref`: a pass whose ack was
|
|
3547
|
+
* lost on the way is found by it in the queue listing and never sent twice. */
|
|
3548
|
+
cref?: string;
|
|
3549
|
+
/**
|
|
3550
|
+
* For an image-vision file (PDF), the 0-based PAGE the render window should start at.
|
|
3551
|
+
* The worker renders [renderFrom, renderFrom+RENDER_PAGES_PER_WINDOW) and injects them
|
|
3552
|
+
* as image blocks; the resume loop advances this by a window each pass.
|
|
3553
|
+
*/
|
|
3554
|
+
renderFrom?: number;
|
|
3555
|
+
};
|
|
3556
|
+
declare function notifyAgentSaveAttachment(info: AttachmentSaveInfo): Promise<any>;
|
|
3557
|
+
declare function extractClaudeText(response: any): any;
|
|
3558
|
+
declare function extractOpenAIText(response: any): any;
|
|
3559
|
+
declare function listClaudeModels(service: string, owner: string): Promise<any>;
|
|
3560
|
+
declare function listOpenAIModels(service: string, owner: string): Promise<any>;
|
|
3561
|
+
declare const BG_INDEXING_QUEUE_SUFFIX = "-bg";
|
|
3562
|
+
/**
|
|
3563
|
+
* unique_id of the durable "indexing finished" marker record for a stored file.
|
|
3564
|
+
*
|
|
3565
|
+
* Written by the BACKEND (the polling worker calls the MCP server's
|
|
3566
|
+
* /internal/index-complete at the end of an auto_continue chain whose final
|
|
3567
|
+
* window reported no more content) and, for completions a client knows
|
|
3568
|
+
* deterministically (single-pass settle, client-chain completion token), by the
|
|
3569
|
+
* consumer's mintIndexDoneMarker hook — never by the model.
|
|
3570
|
+
* The marker record carries `reference: "src::<path>"`, so the reindex flow's
|
|
3571
|
+
* delete of the src:: record cascades to it and a re-run starts unmarked.
|
|
3572
|
+
*
|
|
3573
|
+
* Existence semantics: present = the whole file was read to the end. Absent =
|
|
3574
|
+
* unknown (still running, failed partway, indexed before this marker existed,
|
|
3575
|
+
* or a single-pass run minted before the client hook existed) - callers must
|
|
3576
|
+
* fall back to the live-queue probe (fetchLiveIndexingKeys) before reading
|
|
3577
|
+
* absence as anything.
|
|
3578
|
+
*/
|
|
3579
|
+
/** What the MCP's /internal/index-reset answered. */
|
|
3580
|
+
type IndexResetResult = {
|
|
3581
|
+
path: string;
|
|
3582
|
+
/** The access group the old file record had, or null when there was none. */
|
|
3583
|
+
access_group: string | number | null;
|
|
3584
|
+
removed: number;
|
|
3585
|
+
missing: number;
|
|
3586
|
+
failed: number;
|
|
3587
|
+
decorations: number;
|
|
3588
|
+
ambiguous: number;
|
|
3589
|
+
ms?: number;
|
|
3590
|
+
};
|
|
3591
|
+
/**
|
|
3592
|
+
* Clear a file's index on the SERVER before a Reindex or an Overwrite (owner,
|
|
3593
|
+
* 2026-11-20): the MCP's /internal/index-reset removes the file record (and, through its
|
|
3594
|
+
* cascade, everything referencing it), the agent's decorated per-window ids and the
|
|
3595
|
+
* done::/run:: markers, in parallel, as the signed-in user. Reached through the host's
|
|
3596
|
+
* forwardRequest with "$ACCESS_TOKEN", which skapi fills in with the caller's own token,
|
|
3597
|
+
* so no client code ever holds it.
|
|
3598
|
+
*
|
|
3599
|
+
* Resolves to the server's answer, or null when the call could not be made or answered
|
|
3600
|
+
* something else (an older MCP without the route, a timeout): the caller then clears
|
|
3601
|
+
* the index itself, as it always did. Never rejects.
|
|
3602
|
+
*/
|
|
3603
|
+
declare function resetFileIndexOnServer(args: {
|
|
3604
|
+
service: string;
|
|
3605
|
+
owner?: string;
|
|
3606
|
+
storagePath: string;
|
|
3607
|
+
}): Promise<IndexResetResult | null>;
|
|
3608
|
+
declare function indexDoneUniqueId(storagePath: string): string;
|
|
3609
|
+
/**
|
|
3610
|
+
* unique_id of the per-file indexing RUN record.
|
|
3611
|
+
*
|
|
3612
|
+
* One record per storage path, newest run wins (a reindex's delete-then-repost
|
|
3613
|
+
* of src:: cascade-deletes the old record first, exactly like done::). Minted
|
|
3614
|
+
* status='working' by the client the moment it enqueues a run's FIRST pass, and
|
|
3615
|
+
* closed (done/error/cancelled) by whichever side observes the ending: the
|
|
3616
|
+
* worker via the MCP internal routes for worker-driven chains, the client for
|
|
3617
|
+
* deterministic settles, cancels, and dispatch failures. It exists so chat rows
|
|
3618
|
+
* and files-page badges can answer "which runs exist and how did they end"
|
|
3619
|
+
* from ONE records query instead of scanning bg history.
|
|
3620
|
+
*
|
|
3621
|
+
* A 'working' record is a claim, not proof: a chain that dies without reaching
|
|
3622
|
+
* any error path leaves it dangling, so readers must treat a stale 'working'
|
|
3623
|
+
* (old `started`, no live-queue confirmation) as unknown, never as live.
|
|
3624
|
+
*/
|
|
3625
|
+
declare function runIndexUniqueId(storagePath: string): string;
|
|
3626
|
+
type IndexRunStatus = 'working' | 'done' | 'error' | 'cancelled';
|
|
3627
|
+
type IndexRunPatch = {
|
|
3628
|
+
status: IndexRunStatus;
|
|
3629
|
+
filename?: string;
|
|
3630
|
+
started?: number;
|
|
3631
|
+
finished?: number;
|
|
3632
|
+
error?: string;
|
|
3633
|
+
queue?: string;
|
|
3634
|
+
/** Chat that owns this run. A run:: record is keyed by storage path alone,
|
|
3635
|
+
* but a chat is per (project, platform) — without this the Claude chat's
|
|
3636
|
+
* runs surfaced as rows in the same project's ChatGPT chat, where their
|
|
3637
|
+
* passes can never load and the queue probe can never see them. */
|
|
3638
|
+
platform?: 'claude' | 'openai';
|
|
3639
|
+
};
|
|
3640
|
+
/**
|
|
3641
|
+
* Wrapper over the consumer's upsertIndexRunRecord hook. Never throws: a run record
|
|
3642
|
+
* must never be able to break the run itself. A missing hook or an unconfigured engine
|
|
3643
|
+
* is a no-op.
|
|
3644
|
+
*
|
|
3645
|
+
* The promise: with `report`, it rejects when the write failed (the hook threw or its
|
|
3646
|
+
* promise rejected), so a caller that retries (the settle lock) can see it; without
|
|
3647
|
+
* `report` it always resolves (fire and forget).
|
|
3648
|
+
*/
|
|
3649
|
+
declare function upsertIndexRunRecordSafe(service: string, storagePath: string, patch: IndexRunPatch, opts?: {
|
|
3650
|
+
report?: boolean;
|
|
3651
|
+
}): Promise<void>;
|
|
3652
|
+
/**
|
|
3653
|
+
* The one place the background-indexing queue name is spelled out. The backend
|
|
3654
|
+
* serialises requests sharing a queue name and runs different names in PARALLEL,
|
|
3655
|
+
* so every indexing pass AND the chat turn that must wait behind them have to
|
|
3656
|
+
* resolve to the identical string — see AttachmentSaveInfo.userId for what
|
|
3657
|
+
* happens when they do not.
|
|
3658
|
+
*/
|
|
3659
|
+
declare function bgIndexingQueueName(userId?: string, service?: string): string;
|
|
3660
|
+
/**
|
|
3661
|
+
* True when a request belongs to the background-indexing queue.
|
|
3662
|
+
*
|
|
3663
|
+
* Accepts BOTH shapes this value arrives in: the bare queue name the client sends
|
|
3664
|
+
* ("<userId>-bg"), and the server qid that comes back on history/poll responses
|
|
3665
|
+
* ("<service>:<queue>|<seq>"). Testing the tail of the raw value only works for the
|
|
3666
|
+
* first: a qid ends in "|<seq>", so `endsWith('-bg')` is always false for it — which
|
|
3667
|
+
* silently meant history items were NEVER recognised as background tasks.
|
|
3668
|
+
*/
|
|
3669
|
+
declare function isBgIndexingQueue(queueName?: string): boolean;
|
|
3670
|
+
type BgTaskEntry = {
|
|
3671
|
+
projectId: string;
|
|
3672
|
+
platform: 'claude' | 'openai';
|
|
3673
|
+
id: string;
|
|
3674
|
+
filename: string;
|
|
3675
|
+
storagePath?: string;
|
|
3676
|
+
isReindex?: boolean;
|
|
3677
|
+
mime?: string;
|
|
3678
|
+
size?: number;
|
|
3679
|
+
status: 'running' | 'pending';
|
|
3680
|
+
poll: ((opts: {
|
|
3681
|
+
latency: number;
|
|
3682
|
+
notify?: boolean;
|
|
3683
|
+
onResponse?: (res: any, meta?: {
|
|
3684
|
+
executed?: number;
|
|
3685
|
+
}) => void;
|
|
3686
|
+
}) => Promise<any>) | undefined;
|
|
3687
|
+
/** How many CONTINUE passes have already run for this file (resume-across-passes). */
|
|
3688
|
+
resumePass?: number;
|
|
3689
|
+
/** The STAGED chat turn these files were attached to (ChatSession.stageOutgoingMessage).
|
|
3690
|
+
* drainBgTaskQueue inserts this pass's bubble directly ABOVE that turn's bubble, so the
|
|
3691
|
+
* collapsed row sits where the reader expects it — right before the message the files
|
|
3692
|
+
* came with — from the moment it appears, instead of the turn being moved down past it
|
|
3693
|
+
* once everything finishes. Absent for work with no chat turn behind it (the dbfile
|
|
3694
|
+
* page, an attachment-only send, a worker-adopted pass), which appends as before. */
|
|
3695
|
+
stageId?: string;
|
|
3696
|
+
/** Settled from the 10-second queue check instead of its own poll (owner, 2026-11-20).
|
|
3697
|
+
* Set by drainBgTaskQueue on every pass when the host has csrHistoryItemLookup, and on
|
|
3698
|
+
* adoption for the worker's lanes. Polls on one queue run one at a time in skapi-js, so
|
|
3699
|
+
* a pass that finished waited behind every pass ahead of it; see
|
|
3700
|
+
* ChatSession._settleByListing. */
|
|
3701
|
+
byListing?: boolean;
|
|
3702
|
+
/** When this client first tracked the pass (ms). A pass missing from a listing taken
|
|
3703
|
+
* BEFORE that proves nothing about it. */
|
|
3704
|
+
adoptedAt?: number;
|
|
3705
|
+
/** The identity this pass was dispatched or adopted under, pinned at that moment
|
|
3706
|
+
* (reconciler plan, section 3 item 1). Its settle, its by-id reads and the next
|
|
3707
|
+
* CONTINUE pass of a client-driven file use this, never the identity live at the
|
|
3708
|
+
* time, which a project or platform switch has moved on. Filled by the engine the
|
|
3709
|
+
* first time it sees the entry when a host pushed it without one. */
|
|
3710
|
+
identity?: ChatIdentity;
|
|
3711
|
+
/** The project owner, pinned with the identity (by-id reads are scoped by it). */
|
|
3712
|
+
owner?: string;
|
|
3713
|
+
/** History cache key of the chat this pass belongs to, pinned with the identity. */
|
|
3714
|
+
ownerKey?: string;
|
|
3715
|
+
};
|
|
3716
|
+
declare const INDEXING_COMPLETE_MARKER = "INDEXING_COMPLETE";
|
|
3717
|
+
declare const EMPTY_INDEXING_REPLY = "Finished reading this file.";
|
|
3718
|
+
/**
|
|
3719
|
+
* `queue` narrows the fetch to one processing chain; `status` narrows it to items
|
|
3720
|
+
* in one state. Passing both is how the client asks "is there still unresolved
|
|
3721
|
+
* work on the background-indexing queue?" without pulling a page of chat history
|
|
3722
|
+
* (see ChatSession._adoptWorkerIndexingPasses) — the server answers that from a
|
|
3723
|
+
* status-keyed index, so the reply carries only the live items, not the bodies of
|
|
3724
|
+
* everything already finished.
|
|
3725
|
+
*/
|
|
3726
|
+
declare function getChatHistory(params: {
|
|
3727
|
+
service?: string;
|
|
3728
|
+
owner?: string;
|
|
3729
|
+
platform: 'claude' | 'openai';
|
|
3730
|
+
queue?: string;
|
|
3731
|
+
status?: 'pending' | 'running' | 'resolved' | 'failed';
|
|
3732
|
+
/** Exact-queue listing: without it the qid range is a PREFIX match, so
|
|
3733
|
+
* queue "u1" also returns "u1-bg" rows. Requires the updated polling
|
|
3734
|
+
* lambda; older backends ignore it (harmless, wider results). */
|
|
3735
|
+
queue_exact?: boolean;
|
|
3736
|
+
/** Label/marker STUBS instead of full bodies (see the polling lambda).
|
|
3737
|
+
* Older backends ignore it and return full items. */
|
|
3738
|
+
compact?: boolean;
|
|
3739
|
+
/** Drop one queue's rows from an id-prefix listing — how the surface
|
|
3740
|
+
* chat is fetched WITHOUT the bg-indexing queue while legacy items on
|
|
3741
|
+
* odd queue names survive. Older backends ignore it. */
|
|
3742
|
+
queue_exclude?: string;
|
|
3743
|
+
/** "ids": the light listing (id, status, times, queue, cref; no bodies). skapi-js 2.7.0. */
|
|
3744
|
+
fields?: 'ids';
|
|
3745
|
+
/** Only rows newer than this request id. skapi-js 2.7.0. */
|
|
3746
|
+
after?: string;
|
|
3747
|
+
/** Transport options for a reconciler read (skapi-js 2.7.0): its deadline, an
|
|
3748
|
+
* abort signal, and `fresh` (never join an identical listing in flight). */
|
|
3749
|
+
deadline?: number;
|
|
3750
|
+
signal?: any;
|
|
3751
|
+
fresh?: boolean;
|
|
3752
|
+
}, fetchOptions: Record<string, any>): Promise<any>;
|
|
3753
|
+
/** Full server-side id of one history item, for a csr-poll POINT LOOKUP (the
|
|
3754
|
+
* single-item path returns the item WITH bodies — how an expanded row fetches
|
|
3755
|
+
* the passes a compact listing stubbed out). Mirrors the id the SDK builds:
|
|
3756
|
+
* `[METHOD]url#service:` + the item's own `stamp:entropy` id. */
|
|
3757
|
+
declare function buildHistoryItemFullId(platform: 'claude' | 'openai', service: string, itemId: string): string;
|
|
3516
3758
|
|
|
3517
3759
|
/**
|
|
3518
3760
|
* History mapping (pure). Moved verbatim from the chatbox. The clear-horizon
|
|
@@ -3524,6 +3766,10 @@ interface ChatHost {
|
|
|
3524
3766
|
declare function filterListByClearHorizon(list: any[], clearedAt: number): any[];
|
|
3525
3767
|
declare function normalizeTextContent(content: any): string;
|
|
3526
3768
|
declare function extractLastUserTextFromRequest(requestBody: any): string;
|
|
3769
|
+
/** The last user text of a listed row: the compact stub's `request_text` when the
|
|
3770
|
+
* listing was compact (the body never left the server), else read from the full
|
|
3771
|
+
* request echo (a backend without compact stubs). */
|
|
3772
|
+
declare function listedRequestText(item: any): string;
|
|
3527
3773
|
/** The two openings an indexing prompt can have. A bg-queue item that starts with
|
|
3528
3774
|
* neither is an ordinary chat that happened to be routed onto that queue. */
|
|
3529
3775
|
declare function isIndexingRequestText(userText: any): boolean;
|
|
@@ -3568,6 +3814,9 @@ declare function fetchLiveIndexingKeys(params: {
|
|
|
3568
3814
|
platform: 'claude' | 'openai';
|
|
3569
3815
|
/** Same value the dispatch used - see bgIndexingQueueName. */
|
|
3570
3816
|
userId?: string;
|
|
3817
|
+
}, opts?: {
|
|
3818
|
+
/** Reuse a shared answer up to this old (default BG_PROBE_TTL_MS); 0 always asks. */
|
|
3819
|
+
maxAgeMs?: number;
|
|
3571
3820
|
}): Promise<{
|
|
3572
3821
|
keys: Set<string>;
|
|
3573
3822
|
checked: boolean;
|
|
@@ -3691,6 +3940,20 @@ declare function mapHistoryListToMessages(list: any[], platform: 'claude' | 'ope
|
|
|
3691
3940
|
* the settle would drop the real answer on the floor.
|
|
3692
3941
|
*/
|
|
3693
3942
|
declare function adoptLocalAnswerIntoPage(incoming: ChatMessage, local: ChatMessage): boolean;
|
|
3943
|
+
/**
|
|
3944
|
+
* Keep the LIVE TEXT of a turn the page still shows as running. Mutates `incoming`;
|
|
3945
|
+
* true when it took anything.
|
|
3946
|
+
*
|
|
3947
|
+
* A running row maps to an empty "Thinking..." placeholder (the row has no body
|
|
3948
|
+
* yet), so a first-page refetch landing while an answer streams replaced the bubble
|
|
3949
|
+
* the reader was watching with an empty one. The painter only paints when the text
|
|
3950
|
+
* GROWS past what it already painted, so the bubble then sat on "Thinking..." until
|
|
3951
|
+
* a larger chunk arrived and jumped back, or, with every chunk already delivered,
|
|
3952
|
+
* stayed blank until the settle retyped the whole answer. The local copy is the same
|
|
3953
|
+
* turn (same server id), so its text and its live state come across; the settle
|
|
3954
|
+
* still replaces the text with the authoritative answer.
|
|
3955
|
+
*/
|
|
3956
|
+
declare function adoptLiveTextIntoRunningRow(incoming: ChatMessage, local: ChatMessage): boolean;
|
|
3694
3957
|
interface RescueDecisionContext {
|
|
3695
3958
|
/** Is this `_serverItemId` in the page that was just fetched? */
|
|
3696
3959
|
hasServerId: (id: string) => boolean;
|
|
@@ -4352,6 +4615,130 @@ type PollHandle = {
|
|
|
4352
4615
|
/** Absent on an older skapi-js that cannot stop an attached poll. */
|
|
4353
4616
|
stop?: () => void;
|
|
4354
4617
|
};
|
|
4618
|
+
/** Where an item stands, by the server's account. Only ever moves forward. */
|
|
4619
|
+
type OpenItemState = 'queued' | 'running' | 'terminal';
|
|
4620
|
+
/**
|
|
4621
|
+
* An item this page follows (a chat turn or an indexing pass), with the identity it
|
|
4622
|
+
* belongs to PINNED at the moment it was added: the dispatch ack, a history page that
|
|
4623
|
+
* showed it running or waiting, or a background entry the drain adopted. Every settle,
|
|
4624
|
+
* read and follow-up of the item uses this identity, never the one live at the time,
|
|
4625
|
+
* which a project, platform or account switch has moved on.
|
|
4626
|
+
*/
|
|
4627
|
+
type OpenItem = {
|
|
4628
|
+
/** History cache key (chatCacheKey) of the chat the item belongs to. */
|
|
4629
|
+
ownerKey: string;
|
|
4630
|
+
projectId: string;
|
|
4631
|
+
owner: string;
|
|
4632
|
+
platform: 'claude' | 'openai';
|
|
4633
|
+
/** The server queue it runs on, when known. */
|
|
4634
|
+
queue?: string;
|
|
4635
|
+
kind: 'chat' | 'indexing';
|
|
4636
|
+
state: OpenItemState;
|
|
4637
|
+
/** Wall clock when this page started following it: "did the reader watch it live". */
|
|
4638
|
+
addedAt: number;
|
|
4639
|
+
/** The send's client reference, when known (reconciler plan, section 3 item 9). */
|
|
4640
|
+
cref?: string;
|
|
4641
|
+
/** An anonymous visitor's item: its row is keyed by the network it was sent from, so
|
|
4642
|
+
* "missing" reads as "no longer reachable from this network". */
|
|
4643
|
+
anonymous?: boolean;
|
|
4644
|
+
/** performance.now() of the last look that read this item's status. 0 = never. */
|
|
4645
|
+
lastConfirmed: number;
|
|
4646
|
+
/** The status the last read gave (pending, running, resolved, ...). */
|
|
4647
|
+
lastStatus?: string;
|
|
4648
|
+
/** The row streams its answer (batch status `stream`). */
|
|
4649
|
+
stream?: boolean;
|
|
4650
|
+
/** When the worker began executing it (a running read's `executed`): the start of the
|
|
4651
|
+
* pass's duration when an older skapi-js's look, not a poll, settles it. */
|
|
4652
|
+
executedAt?: number;
|
|
4653
|
+
/** A look saw it terminal while a live poll or stream still held it: the next look
|
|
4654
|
+
* reads it itself if that reader has not settled it by then. */
|
|
4655
|
+
terminalSeen?: boolean;
|
|
4656
|
+
/** The user id of the identity it was sent under (ChatIdentity.userId), pinned when it
|
|
4657
|
+
* was added. A row is readable only by the caller who made it, so while another
|
|
4658
|
+
* identity is signed in (signed out, another account) the item is left alone: not
|
|
4659
|
+
* read, not settled, never marked "no longer available" (see _recReadable). */
|
|
4660
|
+
uid?: string;
|
|
4661
|
+
/** Envelope reads that answered body_unavailable (stored, not loadable now), and when
|
|
4662
|
+
* the last one was. See _recBodyUnavailable. */
|
|
4663
|
+
unavail?: number;
|
|
4664
|
+
unavailAt?: number;
|
|
4665
|
+
/** A worker-driven indexing pass read as failed without the worker's `retried` mark:
|
|
4666
|
+
* when that was (performance.now()). Read once more before the failure is shown, as
|
|
4667
|
+
* the worker writes the mark only after it queued the window again (plan 3.8). */
|
|
4668
|
+
failedPending?: number;
|
|
4669
|
+
/** That second read is due (a complete queue look came, or the wait ran out). */
|
|
4670
|
+
failedRecheck?: boolean;
|
|
4671
|
+
/** A chat turn sent by this page (dispatchAgentRequest): sends it once more when the
|
|
4672
|
+
* answer a look reads is an expired sign-in (the dispatch poll's one resend). Used once. */
|
|
4673
|
+
resend?: (body: any) => void;
|
|
4674
|
+
/** The send's turn context (dispatchAgentRequest), settled when a look applies its answer. */
|
|
4675
|
+
turn?: ChatTurnContext;
|
|
4676
|
+
};
|
|
4677
|
+
/** What trackOpenItem takes: the identity, plus the state the caller saw. */
|
|
4678
|
+
type OpenItemInit = {
|
|
4679
|
+
ownerKey?: string;
|
|
4680
|
+
projectId?: string;
|
|
4681
|
+
owner?: string;
|
|
4682
|
+
platform?: string;
|
|
4683
|
+
queue?: string;
|
|
4684
|
+
kind?: 'chat' | 'indexing';
|
|
4685
|
+
state?: 'queued' | 'running';
|
|
4686
|
+
cref?: string;
|
|
4687
|
+
anonymous?: boolean;
|
|
4688
|
+
/** The identity's user id it was sent under; the live identity's when left out. */
|
|
4689
|
+
uid?: string;
|
|
4690
|
+
};
|
|
4691
|
+
/** What a caller of applyTerminal / onPollFailure knows about the item. Every field
|
|
4692
|
+
* is optional: the pinned identity of an open item fills the gaps, the live identity
|
|
4693
|
+
* only after that. */
|
|
4694
|
+
type TerminalContext = {
|
|
4695
|
+
ownerKey?: string;
|
|
4696
|
+
projectId?: string;
|
|
4697
|
+
platform?: string;
|
|
4698
|
+
owner?: string;
|
|
4699
|
+
queue?: string;
|
|
4700
|
+
/** Write the text at once, never typed out. */
|
|
4701
|
+
instant?: boolean;
|
|
4702
|
+
/** A corrected answer for a turn already settled (a stream read back in full after
|
|
4703
|
+
* an incomplete live parse): replaces the settled text instead of being refused. */
|
|
4704
|
+
correction?: boolean;
|
|
4705
|
+
};
|
|
4706
|
+
/** Who a page watches the background indexing queue of (see ChatSession.watchIndexQueue). */
|
|
4707
|
+
type IndexQueueIdentity = {
|
|
4708
|
+
projectId: string;
|
|
4709
|
+
owner: string;
|
|
4710
|
+
platform: 'claude' | 'openai';
|
|
4711
|
+
/** The user the queue is named after (the same value the dispatch used). */
|
|
4712
|
+
userId?: string;
|
|
4713
|
+
};
|
|
4714
|
+
/** A page that shows indexing state from the queue (the dashboard's files page). */
|
|
4715
|
+
type IndexQueueWatchOptions = {
|
|
4716
|
+
/** Read live on every look: null while the page cannot ask (no platform, no key). */
|
|
4717
|
+
identity: () => IndexQueueIdentity | null;
|
|
4718
|
+
/** The page needs a second look soon (a green waiting for its confirmation). */
|
|
4719
|
+
wantsConfirm?: () => boolean;
|
|
4720
|
+
/** The page follows runs of its own that the queue cannot show (run:: 'working'
|
|
4721
|
+
* records of other users): recheckRuns is called every FILE_RUN_RECHECK_MS while
|
|
4722
|
+
* this says so and the tab is visible. */
|
|
4723
|
+
runsOpen?: () => boolean;
|
|
4724
|
+
recheckRuns?: () => void;
|
|
4725
|
+
};
|
|
4726
|
+
/** What watchIndexQueue hands back. */
|
|
4727
|
+
type IndexQueueWatchHandle = {
|
|
4728
|
+
/** Stop watching (the page unmounts). */
|
|
4729
|
+
stop(): void;
|
|
4730
|
+
/** A fresh read unless the last one is younger than `maxAgeMs` (default 0). Resolves
|
|
4731
|
+
* once the look that reads it is over (the snapshot is then in state.indexQueues). */
|
|
4732
|
+
refresh(maxAgeMs?: number): Promise<void>;
|
|
4733
|
+
/** Something the page waits on changed (wantsConfirm, runsOpen): the chain runs. */
|
|
4734
|
+
ensure(): void;
|
|
4735
|
+
};
|
|
4736
|
+
/** What a send whose row the server never showed says. */
|
|
4737
|
+
declare var NOT_SENT_TEXT: string;
|
|
4738
|
+
/** What a chat turn whose row is gone says ("missing" on a strongly consistent read). */
|
|
4739
|
+
declare var REQUEST_GONE_TEXT: string;
|
|
4740
|
+
/** The same for an anonymous visitor, whose rows are keyed by the network they were sent from. */
|
|
4741
|
+
declare var REQUEST_UNREACHABLE_TEXT: string;
|
|
4355
4742
|
/**
|
|
4356
4743
|
* The prefix of a still-arriving answer that is safe to render as markdown.
|
|
4357
4744
|
*
|
|
@@ -5199,8 +5586,8 @@ declare class ChatSession {
|
|
|
5199
5586
|
* history fetch issued in that window returns the turn ALREADY SETTLED, with no
|
|
5200
5587
|
* pending assistant in it. The rescue then re-appends the local pair below the
|
|
5201
5588
|
* server's copy (the question, twice), and when the poll finally resolves,
|
|
5202
|
-
*
|
|
5203
|
-
*
|
|
5589
|
+
* the old positional settle wrote the answer into the rescued placeholder because
|
|
5590
|
+
* it was the only pending assistant left (the answer, twice). updateHistoryCache
|
|
5204
5591
|
* persists the result, so it survives every later visit.
|
|
5205
5592
|
*
|
|
5206
5593
|
* Navigating away while waiting and coming back is what lands a fetch in that
|
|
@@ -5215,15 +5602,101 @@ declare class ChatSession {
|
|
|
5215
5602
|
* above these bubbles while the request is in flight.
|
|
5216
5603
|
*/
|
|
5217
5604
|
private _stampTurnWithItemId;
|
|
5218
|
-
/**
|
|
5219
|
-
*
|
|
5220
|
-
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
|
|
5226
|
-
|
|
5605
|
+
/** Pinned identity of every item this page follows, by server id. Lazy, like the
|
|
5606
|
+
* stream-recovery bookkeeping, so a session built with Object.create works. */
|
|
5607
|
+
private _openItems?;
|
|
5608
|
+
/** Items whose result was applied (or that were cancelled), for the life of the page. */
|
|
5609
|
+
private _terminalIds?;
|
|
5610
|
+
/** Wall clock of the last time the tab was hidden; 0 = never in this page life. */
|
|
5611
|
+
private _hiddenAt?;
|
|
5612
|
+
private _visibilityWatched?;
|
|
5613
|
+
/** The by-id "is the next queued turn running yet" look (see _checkQueuedRunning). */
|
|
5614
|
+
private _queuedCheckTimer?;
|
|
5615
|
+
private _openMap;
|
|
5616
|
+
private _tomb;
|
|
5617
|
+
/** Remember when the tab was last hidden, for the "watched live" test. */
|
|
5618
|
+
private _watchVisibility;
|
|
5619
|
+
/**
|
|
5620
|
+
* Follow an item, with its identity pinned NOW (the ack, a page showing it running
|
|
5621
|
+
* or waiting, a background entry being adopted). Adding an id already followed
|
|
5622
|
+
* changes nothing but its state, and only forward; a terminal id is never reopened.
|
|
5623
|
+
*/
|
|
5624
|
+
trackOpenItem(itemId: string, init: OpenItemInit): void;
|
|
5625
|
+
/** The pinned identity of an item this page follows, or null. */
|
|
5626
|
+
getOpenItem(itemId: string): OpenItem | null;
|
|
5627
|
+
/** True once an item's result was applied (or it was cancelled) in this page. */
|
|
5628
|
+
isItemSettled(itemId: string): boolean;
|
|
5629
|
+
private _closeItem;
|
|
5630
|
+
/** Did the reader watch this turn arrive? Live text was painted into it, or the tab
|
|
5631
|
+
* has stayed visible (with this chat on screen) since the page started following it. */
|
|
5632
|
+
private _watchedLive;
|
|
5633
|
+
/** The identity a settle uses: the caller's, then the pinned one, then the live one. */
|
|
5634
|
+
private _settleIdentity;
|
|
5635
|
+
/**
|
|
5636
|
+
* Apply how an item ended. The ONLY writer of a settled result; see the section note.
|
|
5637
|
+
* `result` is what the server gave back: a provider body, an error body, a cancelled
|
|
5638
|
+
* envelope, or a status envelope (which is not a result and is routed instead).
|
|
5639
|
+
* True when a bubble was written.
|
|
5640
|
+
*/
|
|
5641
|
+
applyTerminal(itemId: string, result: any, ctx?: TerminalContext): boolean;
|
|
5642
|
+
/** Hand a settled provider answer to the host (ChatHost.onProviderAnswer), whichever
|
|
5643
|
+
* path read it. Optional, and never in the way of the settle. */
|
|
5644
|
+
private _noteProviderAnswer;
|
|
5645
|
+
/** A bubble of this item that still reads as waiting (a stale page can put one back). */
|
|
5646
|
+
private _hasWaitingBubble;
|
|
5647
|
+
/** The settled copy of a request bubble: its pending and sending flags come off,
|
|
5648
|
+
* everything that places it (file row, queue, chat, time, render key) stays. */
|
|
5649
|
+
private _settledUserCopy;
|
|
5650
|
+
/**
|
|
5651
|
+
* The shared core: settle the item with id `itemId` inside `list`, by id only.
|
|
5652
|
+
* Returns what happened and, for a reply to type out, where and from what.
|
|
5653
|
+
*/
|
|
5654
|
+
private _settleInList;
|
|
5655
|
+
private _applyTerminalOnScreen;
|
|
5656
|
+
/** Put the whole text of a reply (found by local id) into a chat's cache copy. */
|
|
5657
|
+
private _patchCachedText;
|
|
5658
|
+
/** The same settle for a chat that is not on screen: made in its history cache,
|
|
5659
|
+
* which is what the next visit renders. Never typed. */
|
|
5660
|
+
private _applyTerminalToCache;
|
|
5661
|
+
/**
|
|
5662
|
+
* A read of an item failed (its poll, or a by-id read). Only the server's own answer
|
|
5663
|
+
* changes the screen: NOT_EXISTS settles the item as cancelled; a failure on the way
|
|
5664
|
+
* (network, timeout, 429, 5xx) or of the sign-in leaves everything as it is, and the
|
|
5665
|
+
* next look settles it; any other refusal is shown on the item, by id.
|
|
5666
|
+
*/
|
|
5667
|
+
onPollFailure(itemId: string, err: any, ctx?: TerminalContext): 'cancelled' | 'kept' | 'failed';
|
|
5668
|
+
/**
|
|
5669
|
+
* A streamed turn's row settled 'resolved' with no body: its answer is in the chunk
|
|
5670
|
+
* store. A live stream that is still being fed settles it itself; otherwise the
|
|
5671
|
+
* chunks are read back by id, and the read's apply goes through the funnel.
|
|
5672
|
+
*/
|
|
5673
|
+
private _readBackSettledStream;
|
|
5674
|
+
/** The server says the item is running (or waiting): move it forward, never back. */
|
|
5675
|
+
private _noteServerState;
|
|
5676
|
+
/**
|
|
5677
|
+
* Show a queued chat turn as RUNNING, found by its server id, because the server said
|
|
5678
|
+
* so. This replaces the guess that "the next waiting bubble on screen" was the one
|
|
5679
|
+
* the server took next. False when that turn is not waiting on screen.
|
|
5680
|
+
*/
|
|
5681
|
+
private _promoteChatItemToRunning;
|
|
5682
|
+
/**
|
|
5683
|
+
* After a chat turn ends, ask the SERVER whether the next queued turn of this chat
|
|
5684
|
+
* runs now, by id: the oldest waiting main-queue turn with a server id is read once
|
|
5685
|
+
* (csrHistoryItemLookup) a few times over a few seconds, and promoted when the row
|
|
5686
|
+
* says running. Bounded and single: a new call restarts the ladder. A host without
|
|
5687
|
+
* the by-id read gets no promotion; the turn shows as answered when its poll settles.
|
|
5688
|
+
*/
|
|
5689
|
+
/** The chat `key` is on screen and none of its main-queue turns shows as running
|
|
5690
|
+
* (no "Thinking..." of an ordinary turn): the next settle will not come to ask. */
|
|
5691
|
+
private _noRunningChatTurnOnScreen;
|
|
5692
|
+
private _checkQueuedRunning;
|
|
5693
|
+
/**
|
|
5694
|
+
* Settle a send that has NO server id: its POST failed, or the POST answered with a
|
|
5695
|
+
* body directly. Found by the bubbles' own local ids, never by position.
|
|
5696
|
+
*/
|
|
5697
|
+
private _settleLocalTurn;
|
|
5698
|
+
/** A provider body (or error) read as the reply it renders as. */
|
|
5699
|
+
private _replyFromBody;
|
|
5227
5700
|
/**
|
|
5228
5701
|
* projectId/owner are passed explicitly by every caller: a request can be
|
|
5229
5702
|
* dispatched after the user moved to another project, and re-reading the live
|
|
@@ -5247,6 +5720,31 @@ declare class ChatSession {
|
|
|
5247
5720
|
* handler on the same chain is not a provider failure.
|
|
5248
5721
|
*/
|
|
5249
5722
|
private _settleChatTurnTools;
|
|
5723
|
+
/**
|
|
5724
|
+
* Send one chat turn and follow it to its end. Two phases (reconciler plan, section 3
|
|
5725
|
+
* item 6):
|
|
5726
|
+
*
|
|
5727
|
+
* ACK. The POST that puts the turn on the server's queue. Only a 401 on THIS request
|
|
5728
|
+
* may refresh the session and send again, once. When it comes back with the server
|
|
5729
|
+
* id the turn is stamped (params.onItemId, matched by local id), pinned as an open
|
|
5730
|
+
* item, and the sending state clears: pendingAgentRequests[key] (an immediate send's
|
|
5731
|
+
* marker) is the ack and nothing longer.
|
|
5732
|
+
*
|
|
5733
|
+
* FOLLOW. The poll on that id. Whatever it ends with goes through applyTerminal or
|
|
5734
|
+
* onPollFailure. A failed READ never sends the turn again: a 401 on a poll tick used
|
|
5735
|
+
* to resend the whole prompt as a new request while the first one kept running.
|
|
5736
|
+
* The one resend left is the server's own FINAL answer saying the turn's
|
|
5737
|
+
* credentials expired (the MCP bearer the turn carried went stale): that turn is
|
|
5738
|
+
* over and failed, so one fresh turn is sent in its place.
|
|
5739
|
+
*
|
|
5740
|
+
* params: key, projectId, owner, aiPlatform, aiModel, systemPrompt, text,
|
|
5741
|
+
* boundedMessages, userId (the queue), extractContent, fileUrls, plus
|
|
5742
|
+
* userLid / placeholderLid the local ids of the turn's bubbles (a send with no
|
|
5743
|
+
* server id is settled through these);
|
|
5744
|
+
* onItemId(itemId) the ack, every time an id is learned;
|
|
5745
|
+
* onAck(itemId?) once, when the POST is over either way;
|
|
5746
|
+
* immediate an immediate send: marks pendingAgentRequests[key].
|
|
5747
|
+
*/
|
|
5250
5748
|
dispatchAgentRequest(params: any): Promise<any>;
|
|
5251
5749
|
/**
|
|
5252
5750
|
* Put a turn on screen the INSTANT the user hits Send, before its attachments
|
|
@@ -5257,9 +5755,9 @@ declare class ChatSession {
|
|
|
5257
5755
|
*
|
|
5258
5756
|
* Staged bubbles carry _useBgQueue because that is where a turn with
|
|
5259
5757
|
* attachments ultimately dispatches (behind its own indexing tasks). That flag
|
|
5260
|
-
* is also what keeps
|
|
5261
|
-
*
|
|
5262
|
-
*
|
|
5758
|
+
* is also what keeps the queued-turn promotion (_checkQueuedRunning) off them:
|
|
5759
|
+
* it follows the SERVER queue, and a staged turn has no server request behind
|
|
5760
|
+
* it yet.
|
|
5263
5761
|
*
|
|
5264
5762
|
* Returns the id to hand back as PinnedDispatchContext.stageId at dispatch.
|
|
5265
5763
|
*/
|
|
@@ -5352,42 +5850,24 @@ declare class ChatSession {
|
|
|
5352
5850
|
*/
|
|
5353
5851
|
private scrollForDispatch;
|
|
5354
5852
|
promoteNextBgQueuedToRunning(): void;
|
|
5853
|
+
/**
|
|
5854
|
+
* The next queued chat turn shows "Thinking..." once the SERVER says it runs.
|
|
5855
|
+
*
|
|
5856
|
+
* This used to promote "the first waiting bubble on screen" the moment any turn
|
|
5857
|
+
* ended, which was a guess about the server's queue, and wrong whenever the screen
|
|
5858
|
+
* and the queue disagreed: a turn still running on the server after a failed read,
|
|
5859
|
+
* a cancel in flight, a send whose ack had not come back. Now it asks: the oldest
|
|
5860
|
+
* waiting turn is read by id and promoted when its row says running (see
|
|
5861
|
+
* _checkQueuedRunning). Kept public under its old name for hosts that call it.
|
|
5862
|
+
*/
|
|
5355
5863
|
promoteNextQueuedToRunning(): void;
|
|
5356
5864
|
/**
|
|
5357
|
-
*
|
|
5358
|
-
*
|
|
5359
|
-
*
|
|
5360
|
-
|
|
5361
|
-
* so ownership is adjacency — modulo background bubbles, which get spliced in
|
|
5362
|
-
* around them. Taking the first pending assistant ANYWHERE below instead was a
|
|
5363
|
-
* hijack: a turn sent with attachments never gets a placeholder of its own
|
|
5364
|
-
* (promoteNextQueuedToRunning skips _useBgQueue turns) and now keeps the position
|
|
5365
|
-
* it was sent in, so an ordinary turn sent while its files indexed sits BELOW it
|
|
5366
|
-
* with a placeholder of its own — and the attachment turn's answer was rendered
|
|
5367
|
-
* as the answer to that unrelated question.
|
|
5368
|
-
*/
|
|
5369
|
-
private _ownThinkingIndex;
|
|
5370
|
-
resolveQueuedUserBubble(serverId?: string): number | undefined;
|
|
5371
|
-
insertAtTarget(msg: ChatMessage, targetIdx: number): void;
|
|
5372
|
-
/**
|
|
5373
|
-
* The server's OWN copy of this turn is already on screen.
|
|
5374
|
-
*
|
|
5375
|
-
* A first-page fetch can land between the server settling the item and this
|
|
5376
|
-
* poll's tick, and now that the local bubbles carry the item id
|
|
5377
|
-
* (_stampTurnWithItemId) the rescue correctly drops them and renders the
|
|
5378
|
-
* server's settled pair instead. There is then nothing left to resolve: the
|
|
5379
|
-
* -1 fallback would push the answer in a SECOND time at the bottom of the list,
|
|
5380
|
-
* and the positional fallbacks would hijack some other turn's bubble.
|
|
5381
|
-
*
|
|
5382
|
-
* The USER bubble counts, not just a settled assistant: an item whose answer is
|
|
5383
|
-
* empty produces no assistant bubble at all in the mapper, and that variant
|
|
5384
|
-
* would otherwise still bottom-push "No text response received...". While a turn
|
|
5385
|
-
* is genuinely live its user bubble is always pending (the queued branch sets
|
|
5386
|
-
* isPendingQueued, promoteNextQueuedToRunning sets isPendingInProcess), so this
|
|
5387
|
-
* cannot fire early.
|
|
5388
|
-
*/
|
|
5389
|
-
private _turnAlreadyRendered;
|
|
5865
|
+
* A queued send's answer, routed through the funnel by its server id. Kept for hosts
|
|
5866
|
+
* that call it; the engine's own queued path settles through dispatchAgentRequest.
|
|
5867
|
+
* Without a server id there is nothing to settle by, and nothing is written.
|
|
5868
|
+
*/
|
|
5390
5869
|
onQueuedSendResponse(_composed: string, response: any, platform: string, serverId?: string, ownerKey?: string): void;
|
|
5870
|
+
/** A queued send's failed read, routed through onPollFailure by its server id. */
|
|
5391
5871
|
onQueuedSendError(_composed: string, err: any, serverId?: string, ownerKey?: string): void;
|
|
5392
5872
|
cancelQueuedMessage(msg: ChatMessage, idx: number): void;
|
|
5393
5873
|
/** The button's label and the message it sends, read off the session so the
|
|
@@ -5432,12 +5912,12 @@ declare class ChatSession {
|
|
|
5432
5912
|
* 2. the poll on it is stopped, which settles whichever chain was awaiting it
|
|
5433
5913
|
* with a stopped result: dispatchAgentRequest's for an immediate send, the
|
|
5434
5914
|
* queued chain for a promoted turn, the history poll after a reload. Each
|
|
5435
|
-
* reads a stopped
|
|
5436
|
-
*
|
|
5437
|
-
* what lets the next send go out immediately instead of queueing;
|
|
5915
|
+
* reads a stopped result as "no reply" and releases its poll registration
|
|
5916
|
+
* (state.sending and pendingAgentRequests were already released at the ack);
|
|
5438
5917
|
* 3. the bubbles settle at once, without waiting for that chain: the user
|
|
5439
|
-
* bubble takes its cancelled form, the placeholder goes,
|
|
5440
|
-
*
|
|
5918
|
+
* bubble takes its cancelled form, the placeholder goes, the id is
|
|
5919
|
+
* tombstoned, and the server is asked whether the next queued turn runs now,
|
|
5920
|
+
* so its own "Thinking" appears when it does.
|
|
5441
5921
|
*
|
|
5442
5922
|
* What it does NOT do: the provider call already in flight on the worker runs
|
|
5443
5923
|
* to its end (a streamed one stops within about a second). A message sent
|
|
@@ -5466,17 +5946,16 @@ declare class ChatSession {
|
|
|
5466
5946
|
*
|
|
5467
5947
|
* Idempotent on purpose: a cancel this client made settles the bubbles at once,
|
|
5468
5948
|
* and the chain that was awaiting the poll settles again a moment later when the
|
|
5469
|
-
* stop resolves it. The second pass finds nothing to do.
|
|
5470
|
-
* _removeStrayPendingAssistants: by then the placeholder on screen is the freshly
|
|
5471
|
-
* promoted turn's, whose user bubble is pending, and the sweep would take it.
|
|
5949
|
+
* stop resolves it. The second pass finds nothing to do.
|
|
5472
5950
|
*/
|
|
5473
5951
|
private _settleCancelledTurn;
|
|
5474
5952
|
/**
|
|
5475
5953
|
* _settleCancelledTurn for a chat that is not on screen: the same edit, made in
|
|
5476
|
-
* its history cache
|
|
5477
|
-
* off-chat send
|
|
5478
|
-
*
|
|
5479
|
-
*
|
|
5954
|
+
* its history cache, by id only. Every bubble of a turn that can be cancelled
|
|
5955
|
+
* carries its id: an off-chat send's pair is stamped at the ack like any other
|
|
5956
|
+
* (dispatchComposedMessage), and a cancel needs the id to be sent at all. (The
|
|
5957
|
+
* positional fallback this had, "the trailing pending placeholder", could take
|
|
5958
|
+
* another turn's.)
|
|
5480
5959
|
*/
|
|
5481
5960
|
private _applyCancelToCache;
|
|
5482
5961
|
/**
|
|
@@ -5504,23 +5983,316 @@ declare class ChatSession {
|
|
|
5504
5983
|
typewriteIntoIndex(idx: number, fullText: string, localId?: string, paintedText?: string): Promise<void>;
|
|
5505
5984
|
private typewriterQueue;
|
|
5506
5985
|
enqueueTypewrite(idx: number, fullText: string, localId?: string, paintedText?: string): Promise<any>;
|
|
5507
|
-
typewriteLatestReply(key: string): Promise<any>;
|
|
5508
|
-
_removeStrayPendingAssistants(): void;
|
|
5509
|
-
/** Index of the USER bubble the message at `idx` belongs to — the nearest one
|
|
5510
|
-
* above it, stepping over background bubbles (a file's indexing rows are
|
|
5511
|
-
* inserted between turns). -1 when the nearest thing above is not a user turn,
|
|
5512
|
-
* which for a placeholder means it is an orphan. */
|
|
5513
|
-
private _owningUserIndex;
|
|
5514
|
-
/** The bubble at `idx` is the "Thinking…" of a DIFFERENT turn that is still
|
|
5515
|
-
* waiting for its answer, so the sweep above must leave it alone. */
|
|
5516
|
-
private _isLiveImmediatePlaceholder;
|
|
5517
|
-
/** A pending assistant at `idx` is the placeholder OF the turn above it, so a
|
|
5518
|
-
* reply may take its slot. Every path that makes one copies the parent's
|
|
5519
|
-
* _serverItemId (or neither has one yet), so a mismatch means the slot belongs to
|
|
5520
|
-
* some other request and the reply must be spliced in beside it, not on top. */
|
|
5521
|
-
private _isOwnPlaceholderOf;
|
|
5522
5986
|
_clearPendingUserBubble(itemId: string): void;
|
|
5523
|
-
resumePendingRequest(
|
|
5987
|
+
resumePendingRequest(_token: number): Promise<void>;
|
|
5988
|
+
private _sched?;
|
|
5989
|
+
/** The last counters seen, per "<projectId>|<queue>". */
|
|
5990
|
+
private _recCounters?;
|
|
5991
|
+
/** performance.now() of the last look that read every open item's status. */
|
|
5992
|
+
private _recFullReadAt;
|
|
5993
|
+
/** performance.now() of the last return look's start (see resumePolling). */
|
|
5994
|
+
private _recReturnAt;
|
|
5995
|
+
/** Open items a status frame named since the last look: read by the next one. */
|
|
5996
|
+
private _recFrameIds?;
|
|
5997
|
+
/** Looks that still read statuses after a counter moved: a queued turn starts a moment
|
|
5998
|
+
* after the one ahead of it finishes, and starting moves no counter. */
|
|
5999
|
+
private _recFollowUps;
|
|
6000
|
+
/** The backend refused the counters read (too old): statuses are read every look. */
|
|
6001
|
+
private _recCountersOff;
|
|
6002
|
+
/** The backend refused the batch status read (too old): today's polls instead. */
|
|
6003
|
+
private _recReadsOff;
|
|
6004
|
+
/** Chunks of a terminal streamed turn read so far, by id (a long answer can take more
|
|
6005
|
+
* than one read, and more than one look). */
|
|
6006
|
+
private _recChunks?;
|
|
6007
|
+
/** Sends whose POST got no answer, by cref. */
|
|
6008
|
+
private _recPending?;
|
|
6009
|
+
/** "Not sent. Retry?" replies, by their local id. */
|
|
6010
|
+
private _notSent?;
|
|
6011
|
+
/** Chat turns shown as "could not be loaded", tried again later (_recRetryUnloadable). */
|
|
6012
|
+
private _recUnloadable?;
|
|
6013
|
+
/** A first-page read a look could not run yet (a load in flight, polling paused). */
|
|
6014
|
+
private _recFirstPageOwed;
|
|
6015
|
+
/** performance.now() of the last first-page read a look started. */
|
|
6016
|
+
private _recFirstPageAt;
|
|
6017
|
+
/** gateRefreshToken of the last first-page load started (see loadHistory). */
|
|
6018
|
+
private _recFirstPageToken;
|
|
6019
|
+
/** performance.now() when the last first-page load landed (see loadHistory). */
|
|
6020
|
+
private _recFirstPageDoneAt;
|
|
6021
|
+
/** performance.now() of the last indexing queue check a look ran. */
|
|
6022
|
+
private _recAdoptAt;
|
|
6023
|
+
/** Indexing runs whose run:: record says 'working', by "<projectId>|<path>". */
|
|
6024
|
+
private _fileRuns?;
|
|
6025
|
+
/** Runs a complete queue look found no pass for: not re-opened by the same records. */
|
|
6026
|
+
private _fileRunsIdle?;
|
|
6027
|
+
private _fileRunCheckAt;
|
|
6028
|
+
private _recSyncing;
|
|
6029
|
+
/** Pages watching a project's background indexing queue (watchIndexQueue). */
|
|
6030
|
+
private _iqWatches;
|
|
6031
|
+
private _recNewMode;
|
|
6032
|
+
private _recSched;
|
|
6033
|
+
/** Keep the chain running at its cadence while there is anything to follow. */
|
|
6034
|
+
private _recEnsure;
|
|
6035
|
+
/** A view host may be absent (the dashboard's files page): nothing here may throw then. */
|
|
6036
|
+
private _viewMounted;
|
|
6037
|
+
private _viewNotify;
|
|
6038
|
+
/**
|
|
6039
|
+
* Look at the server now. `trigger` says why (default 'return': the user is back, so
|
|
6040
|
+
* readers restart and the first page is read). Resolves when that look ends. Any
|
|
6041
|
+
* number of calls at once run one look, plus exactly one more for calls that arrive
|
|
6042
|
+
* while it runs.
|
|
6043
|
+
*/
|
|
6044
|
+
reconcileNow(trigger?: string): Promise<void>;
|
|
6045
|
+
/** The sign-in is back: looks resume at once (state.signInNeeded clears on success). */
|
|
6046
|
+
noteSignedIn(): void;
|
|
6047
|
+
/** A chat view was (re)opened: a return look (readers, discovery, first page). */
|
|
6048
|
+
noteViewOpened(): void;
|
|
6049
|
+
/** The host changed bgTaskQueue (the files page pushes passes with no chat view):
|
|
6050
|
+
* the new entries join the open set and the chain runs. */
|
|
6051
|
+
noteBgQueueChanged(): void;
|
|
6052
|
+
/**
|
|
6053
|
+
* True when this page's reconciler follows every bgTaskQueue entry itself, with or
|
|
6054
|
+
* without a chat view (the host's skapi-js has the batch reads). A host's own poller of
|
|
6055
|
+
* that queue (web-bunnyquery main.vue's fallback poller) then stands down: two
|
|
6056
|
+
* followers of one pass race to settle it, and the poller's settle skips the next pass
|
|
6057
|
+
* of a file this client drives and its run:: record.
|
|
6058
|
+
*/
|
|
6059
|
+
followsBackgroundQueue(): boolean;
|
|
6060
|
+
/** Stop the reconciler's timer (tests, teardown). Any trigger starts it again. */
|
|
6061
|
+
stopReconciler(): void;
|
|
6062
|
+
/** Diagnostics: the open set's size, looks run, timers armed, pending sends. */
|
|
6063
|
+
reconcilerStats(): {
|
|
6064
|
+
open: number;
|
|
6065
|
+
looks: number;
|
|
6066
|
+
timers: number;
|
|
6067
|
+
generation: number;
|
|
6068
|
+
pendingSends: number;
|
|
6069
|
+
fileRuns: number;
|
|
6070
|
+
reconnecting: boolean;
|
|
6071
|
+
signInNeeded: boolean;
|
|
6072
|
+
running: boolean;
|
|
6073
|
+
};
|
|
6074
|
+
/** The bg entry of a pass, by id. */
|
|
6075
|
+
private _bgEntry;
|
|
6076
|
+
/** The queue an indexing pass runs on. */
|
|
6077
|
+
private _bgQueueOf;
|
|
6078
|
+
/**
|
|
6079
|
+
* Every bgTaskQueue entry is an open item, whoever pushed it (the engine, the files
|
|
6080
|
+
* page with no chat view, a host's own code). Its identity is pinned here when the
|
|
6081
|
+
* host pushed it without one, from the identity live now when that is the entry's
|
|
6082
|
+
* project.
|
|
6083
|
+
*/
|
|
6084
|
+
private _syncOpenFromBgQueue;
|
|
6085
|
+
private _chains?;
|
|
6086
|
+
/** Passes whose chain ended (see _forgetChain): never kept again. */
|
|
6087
|
+
private _chainEnded?;
|
|
6088
|
+
private _chainsRestored;
|
|
6089
|
+
private _chainStorage;
|
|
6090
|
+
private _chainKey;
|
|
6091
|
+
/** Keep every client-driven pass in bgTaskQueue (the newest pass per file wins). */
|
|
6092
|
+
private _persistChains;
|
|
6093
|
+
/** The chain of this file ended: forget it (only when the kept pass is not newer than
|
|
6094
|
+
* `upToId`, a later run of the same file being newer; without it, whatever is kept). */
|
|
6095
|
+
private _forgetChain;
|
|
6096
|
+
/** Is a chain of this file kept (this page or another tab of this browser)? */
|
|
6097
|
+
private _chainKept;
|
|
6098
|
+
/** Once per page, at its first look: the kept chains go back into bgTaskQueue. */
|
|
6099
|
+
private _restoreChains;
|
|
6100
|
+
/** An open indexing pass whose file this client drives (it sends the next pass). */
|
|
6101
|
+
private _isClientDrivenOpen;
|
|
6102
|
+
/** What the chain has to follow: anything at all (visible cadence), and what is worth
|
|
6103
|
+
* a look once a minute while the tab is hidden (a client-driven chain: without the
|
|
6104
|
+
* browser its next pass is never sent). Never reads the network. */
|
|
6105
|
+
private _recWork;
|
|
6106
|
+
/** How a failed read is taken: 'auth' (the sign-in is gone), 'transient' (on the way),
|
|
6107
|
+
* 'refused' (the server's own no). */
|
|
6108
|
+
private _recErrKind;
|
|
6109
|
+
/** The user id signed in now (ChatIdentity.userId), or null when the host cannot say. */
|
|
6110
|
+
private _recLiveUid;
|
|
6111
|
+
/**
|
|
6112
|
+
* Can the caller signed in now read an item sent under `uid`? A row answers only the
|
|
6113
|
+
* identity that made it: after a sign-out (or with another account) every read of it
|
|
6114
|
+
* would come back "missing" and settle a turn that is fine as "no longer available".
|
|
6115
|
+
* Such an item is left exactly as it is (not read, not counted as work) until its user
|
|
6116
|
+
* is back. An item pinned before the user was known (uid = the project id, the hosts'
|
|
6117
|
+
* fallback) is always read.
|
|
6118
|
+
*/
|
|
6119
|
+
private _recReadable;
|
|
6120
|
+
/** The newest server id of a chat known here (on screen, in its cache, or open). */
|
|
6121
|
+
private _recNewestKnownId;
|
|
6122
|
+
/** Put a send's cref on its bubbles (on screen and in the chat's cache). */
|
|
6123
|
+
private _stampCref;
|
|
6124
|
+
/** A send whose POST got no answer: its row is looked for by cref (see dispatchAgentRequest). */
|
|
6125
|
+
private _recAddPendingSend;
|
|
6126
|
+
/** Patch the bubbles of a local turn (by local id), on screen and in its chat's cache. */
|
|
6127
|
+
private _markLocalTurn;
|
|
6128
|
+
/**
|
|
6129
|
+
* Send again a turn that said "Not sent. Retry?". Only ever on the user's click: the
|
|
6130
|
+
* reply bubble goes back to waiting and the same send goes out with a new cref. False
|
|
6131
|
+
* when `msg` is not such a reply (or was retried already).
|
|
6132
|
+
*/
|
|
6133
|
+
retryNotSent(msg: ChatMessage): boolean;
|
|
6134
|
+
/** Is a send of this chat in flight right now (see retryNotSent)? */
|
|
6135
|
+
private _chatBusy;
|
|
6136
|
+
/** True for a "Not sent. Retry?" reply that retryNotSent can still send. */
|
|
6137
|
+
canRetryNotSent(msg: ChatMessage): boolean;
|
|
6138
|
+
/**
|
|
6139
|
+
* Follow an indexing run from its run:: 'working' record (reconciler plan, section 3
|
|
6140
|
+
* item 1): the host passes the project's paths whose record says working, after every
|
|
6141
|
+
* read of those records. A run stays open until its record says done/error/cancelled
|
|
6142
|
+
* (it leaves the list), or a complete look at the queue finds no pass of it. While one
|
|
6143
|
+
* is open and not seen live, a look asks the host to read the records again
|
|
6144
|
+
* (host.recheckFileRuns) every FILE_RUN_RECHECK_MS: no fixed number of rounds.
|
|
6145
|
+
*/
|
|
6146
|
+
syncFileRuns(projectId: string, workingPaths: string[], info?: {
|
|
6147
|
+
[path: string]: {
|
|
6148
|
+
owner?: string;
|
|
6149
|
+
filename?: string;
|
|
6150
|
+
};
|
|
6151
|
+
}): void;
|
|
6152
|
+
/** The runs of a project this page follows, by storage path. */
|
|
6153
|
+
openFileRuns(projectId: string): string[];
|
|
6154
|
+
/**
|
|
6155
|
+
* Watch a project's background indexing queue, with or without a chat view (the
|
|
6156
|
+
* dashboard's files page draws its "Indexing" and "Indexed" badges from it). The
|
|
6157
|
+
* reconciler's one timer chain reads it (no timer or poll of the page's own):
|
|
6158
|
+
* - at once when the watch starts, on every return (tab shown, wake, online,
|
|
6159
|
+
* reconnect) and when a status frame names the indexing queue;
|
|
6160
|
+
* - every 8 s while the queue holds work or the last read came back cut off (once a
|
|
6161
|
+
* minute while status frames arrive);
|
|
6162
|
+
* - every 2.5 s while the page waits for a second, independent look (wantsConfirm);
|
|
6163
|
+
* - never while the tab is hidden (a refresh() still reads).
|
|
6164
|
+
* The answer lands in state.indexQueues[projectId] (IndexQueueSnapshot). Runs the page
|
|
6165
|
+
* follows itself (runsOpen) get recheckRuns every FILE_RUN_RECHECK_MS from the same
|
|
6166
|
+
* chain. A failed read keeps the last snapshot.
|
|
6167
|
+
*/
|
|
6168
|
+
watchIndexQueue(opts: IndexQueueWatchOptions): IndexQueueWatchHandle;
|
|
6169
|
+
/** The last read of a project's indexing queue (see watchIndexQueue), or null. */
|
|
6170
|
+
indexQueueSnapshot(projectId: string): IndexQueueSnapshot | null;
|
|
6171
|
+
private _iqIdentity;
|
|
6172
|
+
/** What the watches give the chain to do (see _recWork). */
|
|
6173
|
+
private _iqWork;
|
|
6174
|
+
/** The watched queues' part of a look: read the ones that are due (see watchIndexQueue). */
|
|
6175
|
+
private _iqLook;
|
|
6176
|
+
/**
|
|
6177
|
+
* A run closed idle (a complete queue look found no pass of it) whose record still says
|
|
6178
|
+
* 'working': when it is THIS user's run of a client-driven file and no browser tab here
|
|
6179
|
+
* keeps its chain (a reload, a discarded tab, or a browser without localStorage lost
|
|
6180
|
+
* it), nothing will ever send its next pass, so run:: says CHAIN_LOST_TEXT. Never for a
|
|
6181
|
+
* worker-driven file (the worker writes its endings), another user's run (their chain is
|
|
6182
|
+
* in their browser), or a run whose next pass is being looked for.
|
|
6183
|
+
*/
|
|
6184
|
+
private _flipIfChainLost;
|
|
6185
|
+
/** A file run the queue says is live, or that this page has a pass queued for. */
|
|
6186
|
+
private _fileRunLive;
|
|
6187
|
+
/** Ask the host to read the records of open runs that are not seen live. */
|
|
6188
|
+
private _recCheckFileRuns;
|
|
6189
|
+
/** A COMPLETE look at the queue (both listings shorter than their limit) found no pass
|
|
6190
|
+
* for these runs: they are over. The host reads their records one last time. */
|
|
6191
|
+
private _closeIdleFileRuns;
|
|
6192
|
+
/**
|
|
6193
|
+
* Rule 3 of 4b: on every return each live stream reader is stopped (and its in-flight
|
|
6194
|
+
* read aborted) before the look decides anything; a fresh one starts after the look if
|
|
6195
|
+
* the turn still streams. A reader whose poll cannot be stopped (an older skapi-js) is
|
|
6196
|
+
* left alone, and none is added beside it.
|
|
6197
|
+
*/
|
|
6198
|
+
private _recStopLiveReaders;
|
|
6199
|
+
/** Start the one reader of a running streamed turn on screen that has none. */
|
|
6200
|
+
private _recStartReaders;
|
|
6201
|
+
private _recAttachReader;
|
|
6202
|
+
/** One look. See the section note. Never throws; never changes the screen on a failure. */
|
|
6203
|
+
private _reconcileLook;
|
|
6204
|
+
private _reconcileChatLook;
|
|
6205
|
+
/**
|
|
6206
|
+
* The look of a host whose skapi-js has no batch reads: today's polls stay, and the
|
|
6207
|
+
* look re-attaches what a failed poll let go of (onPollFailure 'kept', a bg entry whose
|
|
6208
|
+
* read failed): one by-id read each through csrHistoryItemLookup, a few per look.
|
|
6209
|
+
*/
|
|
6210
|
+
private _reconcileLookLegacy;
|
|
6211
|
+
/**
|
|
6212
|
+
* The discovery listing: rows of a chat's queue newer than what the page knows, ids and
|
|
6213
|
+
* status only. On a return (the chat on screen), and while a send waits for its row
|
|
6214
|
+
* (its chat). A row carrying a waiting send's cref IS that send: its bubbles get the id
|
|
6215
|
+
* and it is followed like any acked turn. A waiting send no complete listing has shown
|
|
6216
|
+
* twice says "Not sent. Retry?". A live row nothing here knows makes the look read the
|
|
6217
|
+
* first page.
|
|
6218
|
+
*/
|
|
6219
|
+
private _recDiscover;
|
|
6220
|
+
private _recApplyDiscovery;
|
|
6221
|
+
/** A waiting send's row was found by its cref: the send was received after all. */
|
|
6222
|
+
private _recMatchPending;
|
|
6223
|
+
/** Two complete listings never showed the send: it did not reach the server. Shown as
|
|
6224
|
+
* "Not sent. Retry?" and never sent again unless the user asks (retryNotSent). */
|
|
6225
|
+
private _recNotSent;
|
|
6226
|
+
/** The first history page, merged (loadHistory's own merge), on a return or when a live
|
|
6227
|
+
* row nothing here knows was seen. Not awaited: the look's own reads decide its outcome,
|
|
6228
|
+
* and the merge applies itself. Owed (run by a later look) while a load is in flight or
|
|
6229
|
+
* polling is paused. */
|
|
6230
|
+
private _recFirstPage;
|
|
6231
|
+
/** The indexing queue check (adoption, page progress, file runs), at its own cadence
|
|
6232
|
+
* inside the one chain. Needs the chat view: what it adopts are rows of that chat. */
|
|
6233
|
+
private _recIndexingCheck;
|
|
6234
|
+
/**
|
|
6235
|
+
* Read the queue counters and, when needed, the status of the open items.
|
|
6236
|
+
*
|
|
6237
|
+
* WHICH ITEMS. A row read costs as much as the conversation it carries, so a look reads
|
|
6238
|
+
* every open item only on a return and at the stale watch (once a minute). Otherwise it
|
|
6239
|
+
* reads only the items whose status can have changed: the ones never confirmed or seen
|
|
6240
|
+
* terminal, the ones a status frame named, and, when a counter moved or something
|
|
6241
|
+
* nudged the look (a settle asking for the next turn, a send), the running items plus
|
|
6242
|
+
* the head of each queue's line (a queue runs its requests in order, so only the first
|
|
6243
|
+
* few waiting ones can have started). A bulk upload's hundreds of waiting passes are
|
|
6244
|
+
* then read once a minute, not on every finish.
|
|
6245
|
+
*/
|
|
6246
|
+
private _recReadStatuses;
|
|
6247
|
+
private _recReadGroup;
|
|
6248
|
+
private _recApplyStatuses;
|
|
6249
|
+
/** A pass the server says runs now: its waiting bubble becomes the running one, by id
|
|
6250
|
+
* (replaces promoteNextBgQueuedToRunning's guess). True when a bubble changed. */
|
|
6251
|
+
private _recPromoteBg;
|
|
6252
|
+
/** One item the batch read says is over: let a live reader settle it if it is still
|
|
6253
|
+
* being fed (one look's grace), else read it once and apply it. */
|
|
6254
|
+
private _recSettleTerminal;
|
|
6255
|
+
private _recChunkState;
|
|
6256
|
+
/**
|
|
6257
|
+
* The envelope read of one terminal item. A streamed turn with no stored answer is read
|
|
6258
|
+
* from its cursor (`since`), as many reads as it takes within the look, and is final
|
|
6259
|
+
* only when the cursor reaches `final_seq` (without one, when `more` is false); what is
|
|
6260
|
+
* read so far is kept for the next look when the deadline comes first.
|
|
6261
|
+
*/
|
|
6262
|
+
private _recReadEnvelope;
|
|
6263
|
+
/**
|
|
6264
|
+
* An envelope read answered body_unavailable: the answer is stored but could not be
|
|
6265
|
+
* loaded now (an S3 read that failed on the server). Read again at every look for the
|
|
6266
|
+
* first BODY_UNAVAILABLE_BACKOFF_AFTER tries, then only at the stale watch or a return
|
|
6267
|
+
* (_recSettleTerminal). After BODY_UNAVAILABLE_GIVE_UP the turn stops saying
|
|
6268
|
+
* "Thinking..." and shows ANSWER_UNLOADABLE_TEXT; a later read that loads the answer
|
|
6269
|
+
* replaces that text (_recRetryUnloadable). An indexing pass ends with that error.
|
|
6270
|
+
*/
|
|
6271
|
+
private _recBodyUnavailable;
|
|
6272
|
+
/**
|
|
6273
|
+
* Chat turns shown as ANSWER_UNLOADABLE_TEXT: one envelope read each at a return or
|
|
6274
|
+
* the stale watch, at most UNLOADABLE_RETRIES times. An answer that loads replaces the
|
|
6275
|
+
* text (a correction); a row that is gone or failed leaves the text as it is.
|
|
6276
|
+
*/
|
|
6277
|
+
private _recRetryUnloadable;
|
|
6278
|
+
/** A streamed turn read whole (or given up on): shown at once, finalized only when
|
|
6279
|
+
* whole and keepable, with if_absent so a complete answer another tab stored wins. */
|
|
6280
|
+
private _recApplyStreamed;
|
|
6281
|
+
/** Apply one terminal value (a provider body, a failed or cancelled envelope). */
|
|
6282
|
+
private _recApplyValue;
|
|
6283
|
+
/** An item the server no longer has ("missing" on a strongly consistent read). */
|
|
6284
|
+
private _recApplyMissing;
|
|
6285
|
+
/** After a terminal apply: an item whose bubble is nowhere (no chat view, no cache of
|
|
6286
|
+
* its chat) is closed all the same; the next history load shows the server's state. */
|
|
6287
|
+
private _recAfterApply;
|
|
6288
|
+
/**
|
|
6289
|
+
* Store a streamed answer as the version history keeps (csr-finalize) with if_absent,
|
|
6290
|
+
* in the tab that holds the settle lock. When another tab stored one first ("exists"),
|
|
6291
|
+
* the stored one is read back and shown instead.
|
|
6292
|
+
*/
|
|
6293
|
+
private _finalizeAnswer;
|
|
6294
|
+
/** Another tab stored this turn's answer first: show the stored one. */
|
|
6295
|
+
private _readStoredAnswer;
|
|
5524
6296
|
/** Record how long a background indexing pass took, on the bubble that just
|
|
5525
6297
|
* settled, so the duration shows immediately instead of waiting for whatever
|
|
5526
6298
|
* next refetches history.
|
|
@@ -5536,18 +6308,10 @@ declare class ChatSession {
|
|
|
5536
6308
|
* Indexing passes only: an ordinary turn has no duration to show, and
|
|
5537
6309
|
* `_tsStart`'s presence is what both views read to decide. */
|
|
5538
6310
|
private _stampPassDuration;
|
|
5539
|
-
handleHistoryItemResolution(itemId: string, response: any, platform: string, executedAt?: number): void;
|
|
6311
|
+
handleHistoryItemResolution(itemId: string, response: any, platform: string, executedAt?: number, ctx?: TerminalContext): void;
|
|
5540
6312
|
/** The file an already-rendered background pass is about, off its request
|
|
5541
6313
|
* bubble. Null for an ordinary turn, which is most of them. */
|
|
5542
6314
|
private _indexRefOfItem;
|
|
5543
|
-
/**
|
|
5544
|
-
* Settle a turn the server reports as cancelled: the request bubble goes to its
|
|
5545
|
-
* cancelled form and the "Thinking..." placeholder goes away. The same shape
|
|
5546
|
-
* cancelQueuedMessage produces locally, so a cancel this client made and one it
|
|
5547
|
-
* merely found out about render identically — and an indexing pass keeps the
|
|
5548
|
-
* markers that hold it in its file's collapsed row.
|
|
5549
|
-
*/
|
|
5550
|
-
private _settleCancelledItem;
|
|
5551
6315
|
/**
|
|
5552
6316
|
* A poll that came back saying the request was CANCELLED, rather than with an
|
|
5553
6317
|
* answer.
|
|
@@ -5563,7 +6327,13 @@ declare class ChatSession {
|
|
|
5563
6327
|
* another device, or the row being cancelled server-side by the file's own stop.
|
|
5564
6328
|
*/
|
|
5565
6329
|
private _isCancelledPollResult;
|
|
5566
|
-
|
|
6330
|
+
/**
|
|
6331
|
+
* A history-attached poll (the engine's, agent.vue's, the files page's) settled.
|
|
6332
|
+
* Routed through the one funnel, by id: see applyTerminal. `ctx` is the identity the
|
|
6333
|
+
* caller pinned when it attached the poll; the open item's pinned identity fills
|
|
6334
|
+
* whatever it leaves out.
|
|
6335
|
+
*/
|
|
6336
|
+
applyHistoryItemResolution(itemId: string, response: any, platform: string, ctx?: TerminalContext): void;
|
|
5567
6337
|
/** How a bg task maps onto a collapsed row: the row's own key (storage path
|
|
5568
6338
|
* when known, else the filename), scoped to the chat it belongs to. A storage
|
|
5569
6339
|
* path is project-relative ("report.xlsx"), and ONE ChatSession serves every
|
|
@@ -5644,35 +6414,23 @@ declare class ChatSession {
|
|
|
5644
6414
|
* work, so a tab return no longer re-asks for ten minutes after every run. Memory only:
|
|
5645
6415
|
* a reload starts without it and asks once, as before. */
|
|
5646
6416
|
private _idleVerdictAt;
|
|
5647
|
-
private _adoptTickTimer;
|
|
5648
6417
|
/** Newest wall-clock `_ts` of any indexing pass on screen, or 0. */
|
|
5649
6418
|
private _newestIndexPassTs;
|
|
5650
6419
|
/** Live indexing work THIS page is tracking for the project: a queued or adopted pass,
|
|
5651
6420
|
* an attached bg poll, or a live key a look recorded. No recency guess. */
|
|
5652
6421
|
private _hasLocalLiveIndexWork;
|
|
5653
|
-
/** Start the ADOPT_TICK_MS follow-up if this page is tracking live indexing work and
|
|
5654
|
-
* is visible. Idempotent; each tick re-checks and stops when the work is gone, the tab
|
|
5655
|
-
* is hidden (resume restarts it through refreshLiveIndexState) or the view closed. */
|
|
5656
|
-
private _catchUpAt;
|
|
5657
|
-
private _catchUpTimer;
|
|
5658
|
-
private _returnWatchTimer;
|
|
5659
|
-
private _returnWatchAt;
|
|
5660
|
-
private _returnListeners;
|
|
5661
6422
|
private _statusUnsub;
|
|
5662
|
-
private _statusNudgeTimer;
|
|
5663
|
-
private _statusNudgeAt;
|
|
5664
6423
|
private _statusSeenConnect;
|
|
5665
6424
|
/**
|
|
5666
|
-
* Re-read the chat from the server now (see the rule above).
|
|
5667
|
-
*
|
|
5668
|
-
*
|
|
5669
|
-
*
|
|
5670
|
-
* hidden: showing it calls this again).
|
|
6425
|
+
* Re-read the chat from the server now (see the rule above). A thin wrapper over the
|
|
6426
|
+
* reconciler's return look: safe to call from any number of triggers at once, runs
|
|
6427
|
+
* with no chat view too (the first page is read only when one is mounted, and owed
|
|
6428
|
+
* while polling is paused), and resolves when that look ends.
|
|
5671
6429
|
*/
|
|
5672
6430
|
catchUpHistory(): Promise<void>;
|
|
5673
6431
|
/**
|
|
5674
6432
|
* Watch for the moments the user comes back without the tab being hidden first: the
|
|
5675
|
-
* computer waking from sleep (the timer finds a gap far longer than
|
|
6433
|
+
* computer waking from sleep (the reconciler's timer finds a gap far longer than asked),
|
|
5676
6434
|
* the network coming back, a page restored from the back-forward cache. Also starts
|
|
5677
6435
|
* the status push listener. Runs while a chat view is mounted and stops itself when
|
|
5678
6436
|
* none is.
|
|
@@ -5689,8 +6447,8 @@ declare class ChatSession {
|
|
|
5689
6447
|
* was already woken by skapi-js itself. Chat turns are left to their own polls.
|
|
5690
6448
|
*/
|
|
5691
6449
|
private _onRequestStatus;
|
|
5692
|
-
/** Run the queue check (adopt, settle by listing, page progress) now,
|
|
5693
|
-
*
|
|
6450
|
+
/** Run the queue check (adopt, settle by listing, page progress) now, through the
|
|
6451
|
+
* reconciler's one chain. */
|
|
5694
6452
|
private _nudgeQueueCheck;
|
|
5695
6453
|
private _ensureAdoptTick;
|
|
5696
6454
|
/** The last COMPLETE running+pending look at this user's bg queue: which pass ids were
|
|
@@ -5720,14 +6478,6 @@ declare class ChatSession {
|
|
|
5720
6478
|
* the running one, with a "Thinking..." placeholder under it. False when that pass has
|
|
5721
6479
|
* no waiting bubble (already running, settled, or not on screen). */
|
|
5722
6480
|
private _promoteBgItemToRunning;
|
|
5723
|
-
/** Turns whose findings were already looked at (a turn can settle by more than one path). */
|
|
5724
|
-
private _findingsDone;
|
|
5725
|
-
/**
|
|
5726
|
-
* Save where a hard search found its answer (findings.ts), through the host's
|
|
5727
|
-
* saveSearchFinding hook. Never for an indexing pass, never twice for one turn, never
|
|
5728
|
-
* throws, never waited on.
|
|
5729
|
-
*/
|
|
5730
|
-
private _saveFindings;
|
|
5731
6481
|
/**
|
|
5732
6482
|
* Chats-only history (owner, 2026-11-21): on when the host can list a file's passes
|
|
5733
6483
|
* (listIndexPasses) and read one by id (csrHistoryItemLookup). The history fetch then
|
|
@@ -5838,6 +6588,15 @@ declare class ChatSession {
|
|
|
5838
6588
|
* repeats and races harmless. */
|
|
5839
6589
|
_flipRunRecord(entry: BgTaskEntry, status: IndexRunStatus, error?: string): void;
|
|
5840
6590
|
maybeResumeIndexing(entry: BgTaskEntry, response: any, platform: string): void;
|
|
6591
|
+
/**
|
|
6592
|
+
* Send the next pass of a client-driven file (maybeResumeIndexing) and follow it. A POST
|
|
6593
|
+
* that failed on the way may still have been queued, so with a cref it becomes a pending
|
|
6594
|
+
* send the discovery listing looks for on the bg queue: found, it is followed like any
|
|
6595
|
+
* pass; not found by two complete listings, it is sent once more with a new cref. A
|
|
6596
|
+
* refusal, a second miss, or no way to look for it (no cref, no batch reads) ends the
|
|
6597
|
+
* chain: run:: says NEXT_PASS_NOT_SENT_TEXT.
|
|
6598
|
+
*/
|
|
6599
|
+
private _sendNextIndexingPass;
|
|
5841
6600
|
loadHistory(fetchMore?: boolean, token?: number): Promise<void>;
|
|
5842
6601
|
uploadSingleAttachment(att: any, stageId?: string): Promise<Array<{
|
|
5843
6602
|
name: string;
|
|
@@ -5853,4 +6612,4 @@ declare class ChatSession {
|
|
|
5853
6612
|
bumpGate(): void;
|
|
5854
6613
|
}
|
|
5855
6614
|
|
|
5856
|
-
export { ANSWER_MODES, ANSWER_MODE_HINTS, ANSWER_MODE_LABELS, ANSWER_MODE_OPTIONS, ANSWER_MODE_SETTING_LABEL, type AiAgentPlatform, type AnchorBoxEl, type AnchorRowEl, type AnswerMode, type AttachmentFailureGroup, type AttachmentParser, type AttachmentSaveInfo, BG_INDEXING_QUEUE_SUFFIX, BOM, BOM_EXTS, type BgTaskEntry, type BoundedChatOptions, type BuildDisplayListOptions, type BuildIndexingUserMessageOptions, CHAT_GREETING_MAX_LENGTH, CLAUDE_INPUT_CAP_RATIO, CLAUDE_PER_REQUEST_INPUT_CAP, CONTEXT_WINDOW_BY_MODEL, CONTEXT_WINDOW_DEFAULT, type CallClaudeWithMcpParams, type ChatEngineConfig, type ChatGreetingParams, type ChatGreetingParts, type ChatHost, type ChatIdentity, type ChatMessage, ChatSession, type ChatState, type ChatStreamWiring, type ChatSystemPromptParams, type ChatTurnContext, type Citation, type CitationLinkPart, type ClaudeMcpServerRequest, type ClaudeMcpToolConfig, type ClaudeMessage, type ClaudeRole, type ComposedUserMessage, DATA_TOOL_NAMES, DEFAULT_ANSWER_MODE, DEFAULT_CLAUDE_MODEL, DEFAULT_CONTEXT_WINDOW, DEFAULT_OPENAI_MODEL, DEFAULT_SKIP_DUPLICATE_FILES, DEFAULT_UPLOAD_ACCESS_GROUP, DEFAULT_WEB_ACCESS, DUPLICATE_LOOKUP_LIMIT, DUPLICATE_LOOKUP_MAX_CANDIDATES, DUPLICATE_LOOKUP_TIMEOUT_MS, type DisplayEntry, type DuplicateUploadFile, type DuplicateUploadMatch, EMPTY_INDEXING_REPLY, EXPIRED_ATTACHMENT_URL_HOST, EXPIRED_ATTACHMENT_URL_ORIGIN, EXPIRED_LINK_REFRESH_EXPIRES_SECONDS, EXT_CONTENT_TYPES, type EncodingClass, type ExtractDirective,
|
|
6615
|
+
export { ANSWER_MODES, ANSWER_MODE_HINTS, ANSWER_MODE_LABELS, ANSWER_MODE_OPTIONS, ANSWER_MODE_SETTING_LABEL, type AiAgentPlatform, type AnchorBoxEl, type AnchorRowEl, type AnswerMode, type AttachmentFailureGroup, type AttachmentParser, type AttachmentSaveInfo, BG_INDEXING_QUEUE_SUFFIX, BOM, BOM_EXTS, type BgTaskEntry, type BoundedChatOptions, type BuildDisplayListOptions, type BuildIndexingUserMessageOptions, CHAT_GREETING_MAX_LENGTH, CLAUDE_INPUT_CAP_RATIO, CLAUDE_PER_REQUEST_INPUT_CAP, CONTEXT_WINDOW_BY_MODEL, CONTEXT_WINDOW_DEFAULT, type CallClaudeWithMcpParams, type ChatEngineConfig, type ChatGreetingParams, type ChatGreetingParts, type ChatHost, type ChatIdentity, type ChatMessage, ChatSession, type ChatState, type ChatStreamWiring, type ChatSystemPromptParams, type ChatTurnContext, type Citation, type CitationLinkPart, type ClaudeMcpServerRequest, type ClaudeMcpToolConfig, type ClaudeMessage, type ClaudeRole, type ComposedUserMessage, DATA_TOOL_NAMES, DEFAULT_ANSWER_MODE, DEFAULT_CLAUDE_MODEL, DEFAULT_CONTEXT_WINDOW, DEFAULT_OPENAI_MODEL, DEFAULT_SKIP_DUPLICATE_FILES, DEFAULT_UPLOAD_ACCESS_GROUP, DEFAULT_WEB_ACCESS, DUPLICATE_LOOKUP_LIMIT, DUPLICATE_LOOKUP_MAX_CANDIDATES, DUPLICATE_LOOKUP_TIMEOUT_MS, type DisplayEntry, type DuplicateUploadFile, type DuplicateUploadMatch, EMPTY_INDEXING_REPLY, EXPIRED_ATTACHMENT_URL_HOST, EXPIRED_ATTACHMENT_URL_ORIGIN, EXPIRED_LINK_REFRESH_EXPIRES_SECONDS, EXT_CONTENT_TYPES, type EncodingClass, type ExtractDirective, type FillHistoryViewportOptions, HISTORY_BUDGET_RATIO, HISTORY_FILL_SLACK_PX, HISTORY_TOKEN_BUDGET, HTML_EXTS, HTML_HEAD_WINDOW, IMAGE_PREVIEWS_PER_MESSAGE, INDEXING_COMPLETE_MARKER, INDEXING_MAX_OUTPUT_TOKENS, INLINE_LINK_GLYPH, INLINE_LINK_UNAVAILABLE_GLYPH, INLINE_LINK_UNAVAILABLE_SUFFIX, INPUT_CAP_RATIO, type ImagePreviewContext, type IndexQueueIdentity, type IndexQueueSnapshot, type IndexQueueWatchHandle, type IndexQueueWatchOptions, type IndexResetResult, type IndexRunPatch, type IndexRunStatus, type IndexingAttachmentInfo, type IndexingFileRef, type IndexingGroup, type IndexingGroupStatus, type IndexingRequestRef, type IndexingSystemPromptParams, type InlineLinkContext, type InlineLinkMarkupOptions, type InlineLinkPart, LINK_LABEL_MAX_DISPLAY_CHARS, LINK_REFRESH_WINDOW_MS, LOOK_DEADLINE_MS, LOOK_FAST_MS, LOOK_SLOW_MS, LOOK_STALE_MS, type LiveStreamUpdate, type LookOutcome, type LookRequest, LookScheduler, type LookTrigger, MAX_CONCURRENT_BG_POLLS, MAX_HISTORY_FILL_PAGES, MAX_HISTORY_MESSAGES, MAX_OUTPUT_BY_MODEL, MAX_OUTPUT_TOKENS, MAX_PARSED_CONTENT_CHARS, MCP_NAME, MINT_CACHE_GENERATION, MIN_INPUT_TOKEN_BUDGET, MIN_PER_REQUEST_INPUT_CAP, type MapHistoryOptions, NOT_SENT_TEXT, NO_DATA_TOOL_MARK, OUTPUT_TOKEN_RESERVE, type OpenAIMessage, type OpenItem, type OpenItemInit, PAGE_TEXT_TABLE, POLL_INTERVAL, PRESIGN_SAFETY_MARGIN_MS, PREVIEWABLE_IMAGE_CONTENT_TYPES, PREVIEW_BROWSER_CACHE_SECONDS, PREVIEW_LAYOUT_BOX_SELECTOR, PREVIEW_URL_EXPIRES_SECONDS, PROJECT_SETTINGS_ACCESS_GROUP, PROJECT_SETTINGS_TABLE, PROJECT_SETTINGS_UNIQUE_ID, type ParsedAiAgent, type PinnedDispatchContext, type PreviewImageEl, type ProjectAccessSetting, type ProjectSettingsData, type ProjectSettingsReader, RENDER_FROM_TOKEN, REQUEST_GONE_TEXT, REQUEST_UNREACHABLE_TEXT, RETRIEVAL_NOTES_MAX, RETRIEVAL_NOTES_TOKEN_BUDGET, RETRIEVAL_NOTE_MAX_CHARS, RETRIEVAL_NOTE_MAX_ITEMS, RETRIEVAL_NOTE_PREFIX, RTF_EXTS, RUN_RECORD_WORKING_STALE_MS, type RenderableInlineLink, type RescueDecisionContext, type RetrievalHit, type RetrievalNote, type RowAnchor, type RunStubInfo, STREAM_POLL_INTERVAL, type ScrollAnchor, type ScrollAnchorOptions, type SseChunk, type SseParser, type SseProvider, type SseSnapshot, type SseToolCall, type StoredCopyIndexing, type StreamDispatchContext, TOOL_AND_RESPONSE_BUFFER, type TerminalContext, UPLOAD_ACCESS_GROUPS, UPLOAD_ACCESS_HINTS, UPLOAD_ACCESS_LABELS, UPLOAD_ACCESS_OPTIONS, type UploadAccessGroup, type VisionProfile, XML_EXTS, __resetSplitHistoryState, accessSettingFrom, adoptLiveTextIntoRunningRow, adoptLocalAnswerIntoPage, answerModeFrom, answerUsedNoDataTool, applyEncodingDeclaration, applyRetrievalNotes, asksUploadAccessFrom, bgIndexingQueueName, buildAiAgentValue, buildBoundedChatMessages, buildChatDisplayList, buildChatGreeting, buildChatSystemPrompt, buildDisplayExpiredAttachmentHref, buildHistoryItemFullId, buildIndexingContinueMessage, buildIndexingRenderContinueTemplate, buildIndexingRenderMessage, buildIndexingSystemPrompt, buildIndexingUserMessage, buildIndexingWindowMessage, cachedProjectSettings, callClaudeWithMcp, callClaudeWithPublicMcp, callOpenAIWithPublicMcp, canonicalizePathForm, chatCacheKey, chatEffortFields, chatEngineConfig, chatGreetingFrom, chatStreamWiring, citationFileName, citationLinkPart, citationsFor, classifyInlineLink, clearAttachmentParsers, clearImagePreviewCache, clearProjectSettings, composeUserMessage, configureChatEngine, configureProjectSettings, contentTypeForExt, createHistoryFiller, createInlineLinkRegex, createScrollAnchor, createSseParser, crefSupported, csrEnvelopeError, encodePathSegments, encodingClassForExt, ensureHtmlCharset, ensureXmlEncoding, escapeInlineHtml, escapeRtfNonAscii, estimateMessageTokens, estimateTextTokens, extOf, extractClaudeText, extractLastUserTextFromRequest, extractOpenAIText, extractRemotePathFromAttachmentHref, extractRetrievalNote, fetchLiveIndexingKeys, fillHistoryViewport, filterListByClearHorizon, findAttachmentParser, findDuplicateUpload, formatChatTimestamp, formatDuration, formatRetrievalNote, getAttachmentParsers, getChatHistory, getContextWindow, getErrorMessage, getExpiredAttachmentVisiblePath, getInputTokenBudget, getMaxOutputTokens, getModelContextWindow, getProjectContextWindow, getSplitChatHistory, getVisionProfile, groupAttachmentFailures, hasBom, hydrateImagePreviews, indexDoneUniqueId, indexScopeKey, indexingAccessGroup, isAuthExpiredError, isBgIndexingQueue, isCsrStatusEnvelope, isDataToolName, isDuplicateCandidateId, isErrorResponseBody, isHttpUrlLike, isImageVisionFile, isIndexingRequestText, isLinkUnavailable, isNonRetryableRequestError, isNotExistsError, isOfficeFile, isPagedReadFile, isPreviewableImagePath, isProviderApiKeyError, isRetriedFailure, isRetrievalNote, isReturnTrigger, isServerExtractable, isServiceDbAttachmentHref, isTransportFailure, isWindowedReadFile, linkUnavailableKeyForHref, linkUnavailableKeyForPath, linkUnavailableKeysForPath, listClaudeModels, listOpenAIModels, listedRequestText, liveSafePrefix, loadProjectSettings, looksLikeRtf, makeExtractPlaceholder, mapHistoryListToMessages, markImagePreviewStale, mayKeepStreamedAnswer, mintCacheBustStamp, needsBomForExt, newClientRef, normalizeAnswerMode, normalizeAttachmentPathCandidate, normalizeChatGreeting, normalizeExt, normalizeProjectAccessSetting, normalizeSkipDuplicateFiles, normalizeStoredPathTarget, normalizeTextContent, normalizeTrailingInlineToken, normalizeUploadAccessGroup, normalizeWebAccess, notifyAgentSaveAttachment, parseAiAgentValue, parseAttachmentContent, parseIndexingLabel, parseIndexingRequestText, patchProjectSettings, peekImagePreviewUrl, prepareDownloadText, presignExpiryEpochMs, previewImageContentType, previewLayoutBox, previewMintCacheToken, previewableExtOf, primeProjectSettings, projectAccessSetting, projectAnswerMode, projectAsksUploadAccess, projectChatGreeting, projectSettingsSettled, projectSkipDuplicateFiles, projectUploadAccessGroup, projectWebAccess, providerBodyWasRead, readExpiredAttachmentHref, readyProjectSettings, reconcilerReadsEnabled, registerAttachmentParser, registerModelContextWindows, renderInlineLinkHtml, repairUrlEntities, repairUrlWhitespace, resetFileIndexOnServer, resolveAnswerMode, resolveImagePreviewUrl, resolveSkipDuplicateFiles, resolveWebAccess, retrievalNoteFromText, retrievalNoteOfAnswer, runIndexUniqueId, runSettleSideEffect, safeDecodeURIComponent, sanitizeAttachmentLinksForHistory, setProjectContextWindow, setProjectSettings, shouldRescueInFlightMessage, sideEffectDone, skapiSupportsStreaming, skipDuplicateFilesEnabled, skipDuplicateFilesFrom, statusPushEnabled, statusPushLive, streamRecoveryEnabled, streamRecoveryLabels, streamRecoveryPhase, stripFileBlocksFromHistory, transformContentWithImages, transformContentWithOpenAIImages, truncateLabelForDisplay, typewriterResumeIndex, uploadAccessGroupFrom, upsertIndexRunRecordSafe, wallClockNow, webAccessEnabled, webAccessFrom };
|