bunnyquery 1.8.8 → 1.8.9
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/bunnyquery.js +70 -10
- package/dist/engine.cjs +53 -2
- package/dist/engine.cjs.map +1 -1
- package/dist/engine.d.mts +103 -7
- package/dist/engine.d.ts +103 -7
- package/dist/engine.mjs +47 -3
- package/dist/engine.mjs.map +1 -1
- package/package.json +1 -1
- package/src/engine/image_preview.ts +0 -0
- package/src/engine/links.ts +143 -6
package/dist/engine.d.mts
CHANGED
|
@@ -589,6 +589,23 @@ declare var LINK_LABEL_MAX_DISPLAY_CHARS: number;
|
|
|
589
589
|
* not, which is precisely the kind of divergence a shared constant exists to stop.
|
|
590
590
|
*/
|
|
591
591
|
declare var EXPIRED_LINK_REFRESH_EXPIRES_SECONDS: number;
|
|
592
|
+
/**
|
|
593
|
+
* Lifetime of the url minted for an inline image PREVIEW.
|
|
594
|
+
*
|
|
595
|
+
* Longer than the click url above, and for a different reason. A click hands the
|
|
596
|
+
* user a url they may keep, so it stays short. A preview url is consumed by the
|
|
597
|
+
* page itself and never leaves it, and it is the ONE lever on how long the
|
|
598
|
+
* downloaded picture stays reusable: get_signed_url will not cache a mint for
|
|
599
|
+
* longer than the credential inside it survives, so `browser_cache` cannot buy
|
|
600
|
+
* local availability that `expires` has not paid for. Twenty minutes meant every
|
|
601
|
+
* image re-downloaded three times an hour of ordinary reading.
|
|
602
|
+
*
|
|
603
|
+
* An hour, giving 55 minutes of cache once the server's five minute headroom is
|
|
604
|
+
* taken off. Short enough that a leaked preview url is not a standing grant, long
|
|
605
|
+
* enough that a conversation does not re-fetch its own pictures while the user is
|
|
606
|
+
* still reading it.
|
|
607
|
+
*/
|
|
608
|
+
declare var PREVIEW_URL_EXPIRES_SECONDS: number;
|
|
592
609
|
/**
|
|
593
610
|
* Seconds the browser may reuse a minted preview url (`browser_cache`).
|
|
594
611
|
*
|
|
@@ -598,12 +615,17 @@ declare var EXPIRED_LINK_REFRESH_EXPIRES_SECONDS: number;
|
|
|
598
615
|
* url comes back out of the browser cache, so the body already on disk stays
|
|
599
616
|
* addressable.
|
|
600
617
|
*
|
|
601
|
-
*
|
|
602
|
-
*
|
|
603
|
-
*
|
|
604
|
-
*
|
|
605
|
-
*
|
|
606
|
-
*
|
|
618
|
+
* A CEILING, not a promise. get_signed_url caps what it grants at the lifetime of
|
|
619
|
+
* the url inside the response (expires minus headroom, so 15 minutes for the
|
|
620
|
+
* platform's 20 minute url), because a mint cached for longer than its own
|
|
621
|
+
* credential is a guaranteed 403 that the browser keeps serving from its own
|
|
622
|
+
* store. Asking for the week is still right: it says what this client would
|
|
623
|
+
* reuse if the url were stable by construction, and the server decides.
|
|
624
|
+
*
|
|
625
|
+
* What keeps an image painting is the cached BODY, not a live url. Once the
|
|
626
|
+
* browser evicts that body it refetches with a url that has since expired, gets a
|
|
627
|
+
* 403, and the error path re-mints with `refresh` and mintCacheBustStamp. That
|
|
628
|
+
* path is load-bearing, not a rare fallback.
|
|
607
629
|
*
|
|
608
630
|
* A week is the platform default for reading a private file, not a number chosen
|
|
609
631
|
* here: skapi-js reads every private record file with
|
|
@@ -626,6 +648,69 @@ declare var PREVIEW_BROWSER_CACHE_SECONDS: number;
|
|
|
626
648
|
* dead url with no way to notice; deriving it makes that unrepresentable.
|
|
627
649
|
*/
|
|
628
650
|
declare var LINK_REFRESH_WINDOW_MS: number;
|
|
651
|
+
/**
|
|
652
|
+
* Cache generation for the mint request url. BUMP THIS to abandon every mint
|
|
653
|
+
* response browsers are currently holding.
|
|
654
|
+
*
|
|
655
|
+
* Generation 2 retires the entries written before 2026-08-11. Those were stored
|
|
656
|
+
* with `max-age=604800` around a presign that dies in twenty minutes, so from
|
|
657
|
+
* minute 21 each one is a guaranteed 403 that the browser keeps serving from its
|
|
658
|
+
* own store for the rest of the week. The server no longer grants a lifetime a
|
|
659
|
+
* url cannot back (get_signed_url resolve_browser_cache), but that fixes what is
|
|
660
|
+
* written from now on and cannot reach what is already stored on a user's
|
|
661
|
+
* device. Changing the url is the only thing that can: an entry nobody requests
|
|
662
|
+
* again is an entry that cannot answer again.
|
|
663
|
+
*/
|
|
664
|
+
declare var MINT_CACHE_GENERATION: number;
|
|
665
|
+
/**
|
|
666
|
+
* Window stamp for a REFRESH mint.
|
|
667
|
+
*
|
|
668
|
+
* WINDOWED, not Date.now(): a per-call stamp is a new cache key per image per
|
|
669
|
+
* retry, which is what made the original `nocache` parameter worse than the
|
|
670
|
+
* disease. One stamp per refresh window means every repair inside those minutes
|
|
671
|
+
* shares a single entry, and it rotates before the url it carries can die.
|
|
672
|
+
*/
|
|
673
|
+
declare function mintCacheBustStamp(now?: number): number;
|
|
674
|
+
/**
|
|
675
|
+
* The `nocache` value for a preview mint: the generation, plus a window stamp
|
|
676
|
+
* when this mint is a repair.
|
|
677
|
+
*
|
|
678
|
+
* A repair MUST reach the origin, and the request header the clients used to
|
|
679
|
+
* rely on cannot do it. `Cache-Control: no-cache` is not a CORS-safelisted
|
|
680
|
+
* request header, and the record gateway's preflight answers
|
|
681
|
+
* `Access-Control-Allow-Headers` WITHOUT it (verified against the live api on
|
|
682
|
+
* 2026-08-11), so a mint carrying that header is rejected by the browser before
|
|
683
|
+
* it is ever sent. Every repair therefore failed, in every browser, and the chip
|
|
684
|
+
* went straight to "(unavailable)". Only a phone noticed, because only a phone
|
|
685
|
+
* drops image bodies often enough to need the repair at all.
|
|
686
|
+
*
|
|
687
|
+
* A query parameter has no such problem: it is part of the url, so it needs no
|
|
688
|
+
* preflight and no cooperation from the cache.
|
|
689
|
+
*/
|
|
690
|
+
declare function previewMintCacheToken(refresh?: boolean): string;
|
|
691
|
+
/**
|
|
692
|
+
* How long before a presign dies we stop handing it out.
|
|
693
|
+
*
|
|
694
|
+
* A url served with one second left is a 403 with extra steps: the request still
|
|
695
|
+
* has to reach S3, and an image body still has to start arriving.
|
|
696
|
+
*/
|
|
697
|
+
declare var PRESIGN_SAFETY_MARGIN_MS: number;
|
|
698
|
+
/**
|
|
699
|
+
* When the url in hand actually dies, read out of the url itself, or null if it
|
|
700
|
+
* carries no expiry we recognise.
|
|
701
|
+
*
|
|
702
|
+
* Every client-side cache here ages a url from the moment it ARRIVED, which is
|
|
703
|
+
* only the same thing as its lifetime when the mint went to the network. Once
|
|
704
|
+
* mint responses are cacheable that assumption breaks: a mint answered from the
|
|
705
|
+
* browser's store can be nearly as old as its own max-age, and the client then
|
|
706
|
+
* adds its own reuse window on top, so a 20 minute credential can be handed to an
|
|
707
|
+
* <img> half an hour after it was signed. Asking the url when it dies removes the
|
|
708
|
+
* stacking instead of trying to budget for it.
|
|
709
|
+
*
|
|
710
|
+
* Both signature versions, because the platform mints SigV2 through the host
|
|
711
|
+
* bucket and SigV4 elsewhere.
|
|
712
|
+
*/
|
|
713
|
+
declare function presignExpiryEpochMs(url: string): number | null;
|
|
629
714
|
declare function createInlineLinkRegex(): RegExp;
|
|
630
715
|
declare function safeDecodeURIComponent(v: string): string;
|
|
631
716
|
declare function encodePathSegments(path: string): string;
|
|
@@ -782,6 +867,17 @@ declare function classifyInlineLink(full: string, groups: Array<string | undefin
|
|
|
782
867
|
*/
|
|
783
868
|
declare function linkUnavailableKeyForPath(remotePath: string): string;
|
|
784
869
|
declare function linkUnavailableKeyForHref(href: string): string;
|
|
870
|
+
/**
|
|
871
|
+
* Every key a stored file can be marked under, given only its path.
|
|
872
|
+
*
|
|
873
|
+
* Marking writes ONE key (whichever identifier the failing call had) and the
|
|
874
|
+
* lookup ORs all of them, which is fine in one direction and wrong in the other:
|
|
875
|
+
* a view that later learns the file is reachable knows only the path, and
|
|
876
|
+
* clearing `path:` alone leaves a chip greyed by a failed CLICK (which marks
|
|
877
|
+
* `href:` too) exactly as dead as before. The placeholder href is derived from
|
|
878
|
+
* the path, so both keys can be rebuilt from it.
|
|
879
|
+
*/
|
|
880
|
+
declare function linkUnavailableKeysForPath(remotePath: string): string[];
|
|
785
881
|
declare function isLinkUnavailable(link: {
|
|
786
882
|
href?: string;
|
|
787
883
|
expiredHref?: string;
|
|
@@ -2644,4 +2740,4 @@ declare class ChatSession {
|
|
|
2644
2740
|
bumpGate(): void;
|
|
2645
2741
|
}
|
|
2646
2742
|
|
|
2647
|
-
export { type AiAgentPlatform, type AttachmentFailureGroup, type AttachmentParser, type AttachmentSaveInfo, BG_INDEXING_QUEUE_SUFFIX, BOM, BOM_EXTS, type BgTaskEntry, type BoundedChatOptions, type BuildDisplayListOptions, type BuildIndexingUserMessageOptions, CLAUDE_INPUT_CAP_RATIO, CLAUDE_PER_REQUEST_INPUT_CAP, CONTEXT_WINDOW_BY_MODEL, CONTEXT_WINDOW_DEFAULT, type CallClaudeWithMcpParams, type ChatEngineConfig, type ChatHost, type ChatIdentity, type ChatMessage, ChatSession, type ChatState, type ChatSystemPromptParams, type ClaudeMcpServerRequest, type ClaudeMcpToolConfig, type ClaudeMessage, type ClaudeRole, type ComposedUserMessage, DEFAULT_CLAUDE_MODEL, DEFAULT_CONTEXT_WINDOW, DEFAULT_OPENAI_MODEL, type DisplayEntry, 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, INLINE_LINK_GLYPH, INLINE_LINK_UNAVAILABLE_GLYPH, INLINE_LINK_UNAVAILABLE_SUFFIX, INPUT_CAP_RATIO, type ImagePreviewContext, 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, MAX_CONCURRENT_BG_POLLS, MAX_HISTORY_FILL_PAGES, MAX_HISTORY_MESSAGES, MAX_OUTPUT_BY_MODEL, MAX_OUTPUT_TOKENS, MAX_PARSED_CONTENT_CHARS, MCP_NAME, MIN_INPUT_TOKEN_BUDGET, MIN_PER_REQUEST_INPUT_CAP, type MapHistoryOptions, OUTPUT_TOKEN_RESERVE, type OpenAIMessage, POLL_INTERVAL, PREVIEWABLE_IMAGE_CONTENT_TYPES, PREVIEW_BROWSER_CACHE_SECONDS, type ParsedAiAgent, type PinnedDispatchContext, type PreviewImageEl, RENDER_FROM_TOKEN, RTF_EXTS, RUN_RECORD_WORKING_STALE_MS, type RenderableInlineLink, type RunStubInfo, TOOL_AND_RESPONSE_BUFFER, type VisionProfile, XML_EXTS, __resetSplitHistoryState, applyEncodingDeclaration, bgIndexingQueueName, buildAiAgentValue, buildBoundedChatMessages, buildChatDisplayList, buildChatSystemPrompt, buildDisplayExpiredAttachmentHref, buildHistoryItemFullId, buildIndexingContinueMessage, buildIndexingRenderContinueTemplate, buildIndexingRenderMessage, buildIndexingSystemPrompt, buildIndexingUserMessage, buildIndexingWindowMessage, callClaudeWithMcp, callClaudeWithPublicMcp, callOpenAIWithPublicMcp, chatEngineConfig, classifyInlineLink, clearAttachmentParsers, clearImagePreviewCache, composeUserMessage, configureChatEngine, contentTypeForExt, createHistoryFiller, createInlineLinkRegex, encodePathSegments, encodingClassForExt, ensureHtmlCharset, ensureXmlEncoding, escapeInlineHtml, escapeRtfNonAscii, estimateMessageTokens, estimateTextTokens, extOf, extractClaudeText, extractLastUserTextFromRequest, extractOpenAIText, extractRemotePathFromAttachmentHref, fetchLiveIndexingKeys, fillHistoryViewport, filterListByClearHorizon, findAttachmentParser, formatChatTimestamp, getAttachmentParsers, getChatHistory, getContextWindow, getErrorMessage, getExpiredAttachmentVisiblePath, getInputTokenBudget, getMaxOutputTokens, getModelContextWindow, getProjectContextWindow, getSplitChatHistory, getVisionProfile, groupAttachmentFailures, hasBom, hydrateImagePreviews, indexDoneUniqueId, isAuthExpiredError, isBgIndexingQueue, isErrorResponseBody, isHttpUrlLike, isIndexingRequestText, isLinkUnavailable, isNonRetryableRequestError, isOfficeFile, isPreviewableImagePath, isProviderApiKeyError, isServerExtractable, isServiceDbAttachmentHref, linkUnavailableKeyForHref, linkUnavailableKeyForPath, listClaudeModels, listOpenAIModels, looksLikeRtf, makeExtractPlaceholder, mapHistoryListToMessages, markImagePreviewStale, needsBomForExt, normalizeAttachmentPathCandidate, normalizeExt, normalizeTextContent, normalizeTrailingInlineToken, notifyAgentSaveAttachment, parseAiAgentValue, parseAttachmentContent, parseIndexingLabel, parseIndexingRequestText, peekImagePreviewUrl, prepareDownloadText, previewImageContentType, previewableExtOf, readExpiredAttachmentHref, registerAttachmentParser, registerModelContextWindows, renderInlineLinkHtml, repairUrlEntities, repairUrlWhitespace, resolveImagePreviewUrl, runIndexUniqueId, safeDecodeURIComponent, sanitizeAttachmentLinksForHistory, setProjectContextWindow, stripFileBlocksFromHistory, transformContentWithImages, transformContentWithOpenAIImages, truncateLabelForDisplay, upsertIndexRunRecordSafe, wallClockNow };
|
|
2743
|
+
export { type AiAgentPlatform, type AttachmentFailureGroup, type AttachmentParser, type AttachmentSaveInfo, BG_INDEXING_QUEUE_SUFFIX, BOM, BOM_EXTS, type BgTaskEntry, type BoundedChatOptions, type BuildDisplayListOptions, type BuildIndexingUserMessageOptions, CLAUDE_INPUT_CAP_RATIO, CLAUDE_PER_REQUEST_INPUT_CAP, CONTEXT_WINDOW_BY_MODEL, CONTEXT_WINDOW_DEFAULT, type CallClaudeWithMcpParams, type ChatEngineConfig, type ChatHost, type ChatIdentity, type ChatMessage, ChatSession, type ChatState, type ChatSystemPromptParams, type ClaudeMcpServerRequest, type ClaudeMcpToolConfig, type ClaudeMessage, type ClaudeRole, type ComposedUserMessage, DEFAULT_CLAUDE_MODEL, DEFAULT_CONTEXT_WINDOW, DEFAULT_OPENAI_MODEL, type DisplayEntry, 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, INLINE_LINK_GLYPH, INLINE_LINK_UNAVAILABLE_GLYPH, INLINE_LINK_UNAVAILABLE_SUFFIX, INPUT_CAP_RATIO, type ImagePreviewContext, 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, 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, OUTPUT_TOKEN_RESERVE, type OpenAIMessage, POLL_INTERVAL, PRESIGN_SAFETY_MARGIN_MS, PREVIEWABLE_IMAGE_CONTENT_TYPES, PREVIEW_BROWSER_CACHE_SECONDS, PREVIEW_URL_EXPIRES_SECONDS, type ParsedAiAgent, type PinnedDispatchContext, type PreviewImageEl, RENDER_FROM_TOKEN, RTF_EXTS, RUN_RECORD_WORKING_STALE_MS, type RenderableInlineLink, type RunStubInfo, TOOL_AND_RESPONSE_BUFFER, type VisionProfile, XML_EXTS, __resetSplitHistoryState, applyEncodingDeclaration, bgIndexingQueueName, buildAiAgentValue, buildBoundedChatMessages, buildChatDisplayList, buildChatSystemPrompt, buildDisplayExpiredAttachmentHref, buildHistoryItemFullId, buildIndexingContinueMessage, buildIndexingRenderContinueTemplate, buildIndexingRenderMessage, buildIndexingSystemPrompt, buildIndexingUserMessage, buildIndexingWindowMessage, callClaudeWithMcp, callClaudeWithPublicMcp, callOpenAIWithPublicMcp, chatEngineConfig, classifyInlineLink, clearAttachmentParsers, clearImagePreviewCache, composeUserMessage, configureChatEngine, contentTypeForExt, createHistoryFiller, createInlineLinkRegex, encodePathSegments, encodingClassForExt, ensureHtmlCharset, ensureXmlEncoding, escapeInlineHtml, escapeRtfNonAscii, estimateMessageTokens, estimateTextTokens, extOf, extractClaudeText, extractLastUserTextFromRequest, extractOpenAIText, extractRemotePathFromAttachmentHref, fetchLiveIndexingKeys, fillHistoryViewport, filterListByClearHorizon, findAttachmentParser, formatChatTimestamp, getAttachmentParsers, getChatHistory, getContextWindow, getErrorMessage, getExpiredAttachmentVisiblePath, getInputTokenBudget, getMaxOutputTokens, getModelContextWindow, getProjectContextWindow, getSplitChatHistory, getVisionProfile, groupAttachmentFailures, hasBom, hydrateImagePreviews, indexDoneUniqueId, isAuthExpiredError, isBgIndexingQueue, isErrorResponseBody, isHttpUrlLike, isIndexingRequestText, isLinkUnavailable, isNonRetryableRequestError, isOfficeFile, isPreviewableImagePath, isProviderApiKeyError, isServerExtractable, isServiceDbAttachmentHref, linkUnavailableKeyForHref, linkUnavailableKeyForPath, linkUnavailableKeysForPath, listClaudeModels, listOpenAIModels, looksLikeRtf, makeExtractPlaceholder, mapHistoryListToMessages, markImagePreviewStale, mintCacheBustStamp, needsBomForExt, normalizeAttachmentPathCandidate, normalizeExt, normalizeTextContent, normalizeTrailingInlineToken, notifyAgentSaveAttachment, parseAiAgentValue, parseAttachmentContent, parseIndexingLabel, parseIndexingRequestText, peekImagePreviewUrl, prepareDownloadText, presignExpiryEpochMs, previewImageContentType, previewMintCacheToken, previewableExtOf, readExpiredAttachmentHref, registerAttachmentParser, registerModelContextWindows, renderInlineLinkHtml, repairUrlEntities, repairUrlWhitespace, resolveImagePreviewUrl, runIndexUniqueId, safeDecodeURIComponent, sanitizeAttachmentLinksForHistory, setProjectContextWindow, stripFileBlocksFromHistory, transformContentWithImages, transformContentWithOpenAIImages, truncateLabelForDisplay, upsertIndexRunRecordSafe, wallClockNow };
|
package/dist/engine.d.ts
CHANGED
|
@@ -589,6 +589,23 @@ declare var LINK_LABEL_MAX_DISPLAY_CHARS: number;
|
|
|
589
589
|
* not, which is precisely the kind of divergence a shared constant exists to stop.
|
|
590
590
|
*/
|
|
591
591
|
declare var EXPIRED_LINK_REFRESH_EXPIRES_SECONDS: number;
|
|
592
|
+
/**
|
|
593
|
+
* Lifetime of the url minted for an inline image PREVIEW.
|
|
594
|
+
*
|
|
595
|
+
* Longer than the click url above, and for a different reason. A click hands the
|
|
596
|
+
* user a url they may keep, so it stays short. A preview url is consumed by the
|
|
597
|
+
* page itself and never leaves it, and it is the ONE lever on how long the
|
|
598
|
+
* downloaded picture stays reusable: get_signed_url will not cache a mint for
|
|
599
|
+
* longer than the credential inside it survives, so `browser_cache` cannot buy
|
|
600
|
+
* local availability that `expires` has not paid for. Twenty minutes meant every
|
|
601
|
+
* image re-downloaded three times an hour of ordinary reading.
|
|
602
|
+
*
|
|
603
|
+
* An hour, giving 55 minutes of cache once the server's five minute headroom is
|
|
604
|
+
* taken off. Short enough that a leaked preview url is not a standing grant, long
|
|
605
|
+
* enough that a conversation does not re-fetch its own pictures while the user is
|
|
606
|
+
* still reading it.
|
|
607
|
+
*/
|
|
608
|
+
declare var PREVIEW_URL_EXPIRES_SECONDS: number;
|
|
592
609
|
/**
|
|
593
610
|
* Seconds the browser may reuse a minted preview url (`browser_cache`).
|
|
594
611
|
*
|
|
@@ -598,12 +615,17 @@ declare var EXPIRED_LINK_REFRESH_EXPIRES_SECONDS: number;
|
|
|
598
615
|
* url comes back out of the browser cache, so the body already on disk stays
|
|
599
616
|
* addressable.
|
|
600
617
|
*
|
|
601
|
-
*
|
|
602
|
-
*
|
|
603
|
-
*
|
|
604
|
-
*
|
|
605
|
-
*
|
|
606
|
-
*
|
|
618
|
+
* A CEILING, not a promise. get_signed_url caps what it grants at the lifetime of
|
|
619
|
+
* the url inside the response (expires minus headroom, so 15 minutes for the
|
|
620
|
+
* platform's 20 minute url), because a mint cached for longer than its own
|
|
621
|
+
* credential is a guaranteed 403 that the browser keeps serving from its own
|
|
622
|
+
* store. Asking for the week is still right: it says what this client would
|
|
623
|
+
* reuse if the url were stable by construction, and the server decides.
|
|
624
|
+
*
|
|
625
|
+
* What keeps an image painting is the cached BODY, not a live url. Once the
|
|
626
|
+
* browser evicts that body it refetches with a url that has since expired, gets a
|
|
627
|
+
* 403, and the error path re-mints with `refresh` and mintCacheBustStamp. That
|
|
628
|
+
* path is load-bearing, not a rare fallback.
|
|
607
629
|
*
|
|
608
630
|
* A week is the platform default for reading a private file, not a number chosen
|
|
609
631
|
* here: skapi-js reads every private record file with
|
|
@@ -626,6 +648,69 @@ declare var PREVIEW_BROWSER_CACHE_SECONDS: number;
|
|
|
626
648
|
* dead url with no way to notice; deriving it makes that unrepresentable.
|
|
627
649
|
*/
|
|
628
650
|
declare var LINK_REFRESH_WINDOW_MS: number;
|
|
651
|
+
/**
|
|
652
|
+
* Cache generation for the mint request url. BUMP THIS to abandon every mint
|
|
653
|
+
* response browsers are currently holding.
|
|
654
|
+
*
|
|
655
|
+
* Generation 2 retires the entries written before 2026-08-11. Those were stored
|
|
656
|
+
* with `max-age=604800` around a presign that dies in twenty minutes, so from
|
|
657
|
+
* minute 21 each one is a guaranteed 403 that the browser keeps serving from its
|
|
658
|
+
* own store for the rest of the week. The server no longer grants a lifetime a
|
|
659
|
+
* url cannot back (get_signed_url resolve_browser_cache), but that fixes what is
|
|
660
|
+
* written from now on and cannot reach what is already stored on a user's
|
|
661
|
+
* device. Changing the url is the only thing that can: an entry nobody requests
|
|
662
|
+
* again is an entry that cannot answer again.
|
|
663
|
+
*/
|
|
664
|
+
declare var MINT_CACHE_GENERATION: number;
|
|
665
|
+
/**
|
|
666
|
+
* Window stamp for a REFRESH mint.
|
|
667
|
+
*
|
|
668
|
+
* WINDOWED, not Date.now(): a per-call stamp is a new cache key per image per
|
|
669
|
+
* retry, which is what made the original `nocache` parameter worse than the
|
|
670
|
+
* disease. One stamp per refresh window means every repair inside those minutes
|
|
671
|
+
* shares a single entry, and it rotates before the url it carries can die.
|
|
672
|
+
*/
|
|
673
|
+
declare function mintCacheBustStamp(now?: number): number;
|
|
674
|
+
/**
|
|
675
|
+
* The `nocache` value for a preview mint: the generation, plus a window stamp
|
|
676
|
+
* when this mint is a repair.
|
|
677
|
+
*
|
|
678
|
+
* A repair MUST reach the origin, and the request header the clients used to
|
|
679
|
+
* rely on cannot do it. `Cache-Control: no-cache` is not a CORS-safelisted
|
|
680
|
+
* request header, and the record gateway's preflight answers
|
|
681
|
+
* `Access-Control-Allow-Headers` WITHOUT it (verified against the live api on
|
|
682
|
+
* 2026-08-11), so a mint carrying that header is rejected by the browser before
|
|
683
|
+
* it is ever sent. Every repair therefore failed, in every browser, and the chip
|
|
684
|
+
* went straight to "(unavailable)". Only a phone noticed, because only a phone
|
|
685
|
+
* drops image bodies often enough to need the repair at all.
|
|
686
|
+
*
|
|
687
|
+
* A query parameter has no such problem: it is part of the url, so it needs no
|
|
688
|
+
* preflight and no cooperation from the cache.
|
|
689
|
+
*/
|
|
690
|
+
declare function previewMintCacheToken(refresh?: boolean): string;
|
|
691
|
+
/**
|
|
692
|
+
* How long before a presign dies we stop handing it out.
|
|
693
|
+
*
|
|
694
|
+
* A url served with one second left is a 403 with extra steps: the request still
|
|
695
|
+
* has to reach S3, and an image body still has to start arriving.
|
|
696
|
+
*/
|
|
697
|
+
declare var PRESIGN_SAFETY_MARGIN_MS: number;
|
|
698
|
+
/**
|
|
699
|
+
* When the url in hand actually dies, read out of the url itself, or null if it
|
|
700
|
+
* carries no expiry we recognise.
|
|
701
|
+
*
|
|
702
|
+
* Every client-side cache here ages a url from the moment it ARRIVED, which is
|
|
703
|
+
* only the same thing as its lifetime when the mint went to the network. Once
|
|
704
|
+
* mint responses are cacheable that assumption breaks: a mint answered from the
|
|
705
|
+
* browser's store can be nearly as old as its own max-age, and the client then
|
|
706
|
+
* adds its own reuse window on top, so a 20 minute credential can be handed to an
|
|
707
|
+
* <img> half an hour after it was signed. Asking the url when it dies removes the
|
|
708
|
+
* stacking instead of trying to budget for it.
|
|
709
|
+
*
|
|
710
|
+
* Both signature versions, because the platform mints SigV2 through the host
|
|
711
|
+
* bucket and SigV4 elsewhere.
|
|
712
|
+
*/
|
|
713
|
+
declare function presignExpiryEpochMs(url: string): number | null;
|
|
629
714
|
declare function createInlineLinkRegex(): RegExp;
|
|
630
715
|
declare function safeDecodeURIComponent(v: string): string;
|
|
631
716
|
declare function encodePathSegments(path: string): string;
|
|
@@ -782,6 +867,17 @@ declare function classifyInlineLink(full: string, groups: Array<string | undefin
|
|
|
782
867
|
*/
|
|
783
868
|
declare function linkUnavailableKeyForPath(remotePath: string): string;
|
|
784
869
|
declare function linkUnavailableKeyForHref(href: string): string;
|
|
870
|
+
/**
|
|
871
|
+
* Every key a stored file can be marked under, given only its path.
|
|
872
|
+
*
|
|
873
|
+
* Marking writes ONE key (whichever identifier the failing call had) and the
|
|
874
|
+
* lookup ORs all of them, which is fine in one direction and wrong in the other:
|
|
875
|
+
* a view that later learns the file is reachable knows only the path, and
|
|
876
|
+
* clearing `path:` alone leaves a chip greyed by a failed CLICK (which marks
|
|
877
|
+
* `href:` too) exactly as dead as before. The placeholder href is derived from
|
|
878
|
+
* the path, so both keys can be rebuilt from it.
|
|
879
|
+
*/
|
|
880
|
+
declare function linkUnavailableKeysForPath(remotePath: string): string[];
|
|
785
881
|
declare function isLinkUnavailable(link: {
|
|
786
882
|
href?: string;
|
|
787
883
|
expiredHref?: string;
|
|
@@ -2644,4 +2740,4 @@ declare class ChatSession {
|
|
|
2644
2740
|
bumpGate(): void;
|
|
2645
2741
|
}
|
|
2646
2742
|
|
|
2647
|
-
export { type AiAgentPlatform, type AttachmentFailureGroup, type AttachmentParser, type AttachmentSaveInfo, BG_INDEXING_QUEUE_SUFFIX, BOM, BOM_EXTS, type BgTaskEntry, type BoundedChatOptions, type BuildDisplayListOptions, type BuildIndexingUserMessageOptions, CLAUDE_INPUT_CAP_RATIO, CLAUDE_PER_REQUEST_INPUT_CAP, CONTEXT_WINDOW_BY_MODEL, CONTEXT_WINDOW_DEFAULT, type CallClaudeWithMcpParams, type ChatEngineConfig, type ChatHost, type ChatIdentity, type ChatMessage, ChatSession, type ChatState, type ChatSystemPromptParams, type ClaudeMcpServerRequest, type ClaudeMcpToolConfig, type ClaudeMessage, type ClaudeRole, type ComposedUserMessage, DEFAULT_CLAUDE_MODEL, DEFAULT_CONTEXT_WINDOW, DEFAULT_OPENAI_MODEL, type DisplayEntry, 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, INLINE_LINK_GLYPH, INLINE_LINK_UNAVAILABLE_GLYPH, INLINE_LINK_UNAVAILABLE_SUFFIX, INPUT_CAP_RATIO, type ImagePreviewContext, 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, MAX_CONCURRENT_BG_POLLS, MAX_HISTORY_FILL_PAGES, MAX_HISTORY_MESSAGES, MAX_OUTPUT_BY_MODEL, MAX_OUTPUT_TOKENS, MAX_PARSED_CONTENT_CHARS, MCP_NAME, MIN_INPUT_TOKEN_BUDGET, MIN_PER_REQUEST_INPUT_CAP, type MapHistoryOptions, OUTPUT_TOKEN_RESERVE, type OpenAIMessage, POLL_INTERVAL, PREVIEWABLE_IMAGE_CONTENT_TYPES, PREVIEW_BROWSER_CACHE_SECONDS, type ParsedAiAgent, type PinnedDispatchContext, type PreviewImageEl, RENDER_FROM_TOKEN, RTF_EXTS, RUN_RECORD_WORKING_STALE_MS, type RenderableInlineLink, type RunStubInfo, TOOL_AND_RESPONSE_BUFFER, type VisionProfile, XML_EXTS, __resetSplitHistoryState, applyEncodingDeclaration, bgIndexingQueueName, buildAiAgentValue, buildBoundedChatMessages, buildChatDisplayList, buildChatSystemPrompt, buildDisplayExpiredAttachmentHref, buildHistoryItemFullId, buildIndexingContinueMessage, buildIndexingRenderContinueTemplate, buildIndexingRenderMessage, buildIndexingSystemPrompt, buildIndexingUserMessage, buildIndexingWindowMessage, callClaudeWithMcp, callClaudeWithPublicMcp, callOpenAIWithPublicMcp, chatEngineConfig, classifyInlineLink, clearAttachmentParsers, clearImagePreviewCache, composeUserMessage, configureChatEngine, contentTypeForExt, createHistoryFiller, createInlineLinkRegex, encodePathSegments, encodingClassForExt, ensureHtmlCharset, ensureXmlEncoding, escapeInlineHtml, escapeRtfNonAscii, estimateMessageTokens, estimateTextTokens, extOf, extractClaudeText, extractLastUserTextFromRequest, extractOpenAIText, extractRemotePathFromAttachmentHref, fetchLiveIndexingKeys, fillHistoryViewport, filterListByClearHorizon, findAttachmentParser, formatChatTimestamp, getAttachmentParsers, getChatHistory, getContextWindow, getErrorMessage, getExpiredAttachmentVisiblePath, getInputTokenBudget, getMaxOutputTokens, getModelContextWindow, getProjectContextWindow, getSplitChatHistory, getVisionProfile, groupAttachmentFailures, hasBom, hydrateImagePreviews, indexDoneUniqueId, isAuthExpiredError, isBgIndexingQueue, isErrorResponseBody, isHttpUrlLike, isIndexingRequestText, isLinkUnavailable, isNonRetryableRequestError, isOfficeFile, isPreviewableImagePath, isProviderApiKeyError, isServerExtractable, isServiceDbAttachmentHref, linkUnavailableKeyForHref, linkUnavailableKeyForPath, listClaudeModels, listOpenAIModels, looksLikeRtf, makeExtractPlaceholder, mapHistoryListToMessages, markImagePreviewStale, needsBomForExt, normalizeAttachmentPathCandidate, normalizeExt, normalizeTextContent, normalizeTrailingInlineToken, notifyAgentSaveAttachment, parseAiAgentValue, parseAttachmentContent, parseIndexingLabel, parseIndexingRequestText, peekImagePreviewUrl, prepareDownloadText, previewImageContentType, previewableExtOf, readExpiredAttachmentHref, registerAttachmentParser, registerModelContextWindows, renderInlineLinkHtml, repairUrlEntities, repairUrlWhitespace, resolveImagePreviewUrl, runIndexUniqueId, safeDecodeURIComponent, sanitizeAttachmentLinksForHistory, setProjectContextWindow, stripFileBlocksFromHistory, transformContentWithImages, transformContentWithOpenAIImages, truncateLabelForDisplay, upsertIndexRunRecordSafe, wallClockNow };
|
|
2743
|
+
export { type AiAgentPlatform, type AttachmentFailureGroup, type AttachmentParser, type AttachmentSaveInfo, BG_INDEXING_QUEUE_SUFFIX, BOM, BOM_EXTS, type BgTaskEntry, type BoundedChatOptions, type BuildDisplayListOptions, type BuildIndexingUserMessageOptions, CLAUDE_INPUT_CAP_RATIO, CLAUDE_PER_REQUEST_INPUT_CAP, CONTEXT_WINDOW_BY_MODEL, CONTEXT_WINDOW_DEFAULT, type CallClaudeWithMcpParams, type ChatEngineConfig, type ChatHost, type ChatIdentity, type ChatMessage, ChatSession, type ChatState, type ChatSystemPromptParams, type ClaudeMcpServerRequest, type ClaudeMcpToolConfig, type ClaudeMessage, type ClaudeRole, type ComposedUserMessage, DEFAULT_CLAUDE_MODEL, DEFAULT_CONTEXT_WINDOW, DEFAULT_OPENAI_MODEL, type DisplayEntry, 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, INLINE_LINK_GLYPH, INLINE_LINK_UNAVAILABLE_GLYPH, INLINE_LINK_UNAVAILABLE_SUFFIX, INPUT_CAP_RATIO, type ImagePreviewContext, 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, 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, OUTPUT_TOKEN_RESERVE, type OpenAIMessage, POLL_INTERVAL, PRESIGN_SAFETY_MARGIN_MS, PREVIEWABLE_IMAGE_CONTENT_TYPES, PREVIEW_BROWSER_CACHE_SECONDS, PREVIEW_URL_EXPIRES_SECONDS, type ParsedAiAgent, type PinnedDispatchContext, type PreviewImageEl, RENDER_FROM_TOKEN, RTF_EXTS, RUN_RECORD_WORKING_STALE_MS, type RenderableInlineLink, type RunStubInfo, TOOL_AND_RESPONSE_BUFFER, type VisionProfile, XML_EXTS, __resetSplitHistoryState, applyEncodingDeclaration, bgIndexingQueueName, buildAiAgentValue, buildBoundedChatMessages, buildChatDisplayList, buildChatSystemPrompt, buildDisplayExpiredAttachmentHref, buildHistoryItemFullId, buildIndexingContinueMessage, buildIndexingRenderContinueTemplate, buildIndexingRenderMessage, buildIndexingSystemPrompt, buildIndexingUserMessage, buildIndexingWindowMessage, callClaudeWithMcp, callClaudeWithPublicMcp, callOpenAIWithPublicMcp, chatEngineConfig, classifyInlineLink, clearAttachmentParsers, clearImagePreviewCache, composeUserMessage, configureChatEngine, contentTypeForExt, createHistoryFiller, createInlineLinkRegex, encodePathSegments, encodingClassForExt, ensureHtmlCharset, ensureXmlEncoding, escapeInlineHtml, escapeRtfNonAscii, estimateMessageTokens, estimateTextTokens, extOf, extractClaudeText, extractLastUserTextFromRequest, extractOpenAIText, extractRemotePathFromAttachmentHref, fetchLiveIndexingKeys, fillHistoryViewport, filterListByClearHorizon, findAttachmentParser, formatChatTimestamp, getAttachmentParsers, getChatHistory, getContextWindow, getErrorMessage, getExpiredAttachmentVisiblePath, getInputTokenBudget, getMaxOutputTokens, getModelContextWindow, getProjectContextWindow, getSplitChatHistory, getVisionProfile, groupAttachmentFailures, hasBom, hydrateImagePreviews, indexDoneUniqueId, isAuthExpiredError, isBgIndexingQueue, isErrorResponseBody, isHttpUrlLike, isIndexingRequestText, isLinkUnavailable, isNonRetryableRequestError, isOfficeFile, isPreviewableImagePath, isProviderApiKeyError, isServerExtractable, isServiceDbAttachmentHref, linkUnavailableKeyForHref, linkUnavailableKeyForPath, linkUnavailableKeysForPath, listClaudeModels, listOpenAIModels, looksLikeRtf, makeExtractPlaceholder, mapHistoryListToMessages, markImagePreviewStale, mintCacheBustStamp, needsBomForExt, normalizeAttachmentPathCandidate, normalizeExt, normalizeTextContent, normalizeTrailingInlineToken, notifyAgentSaveAttachment, parseAiAgentValue, parseAttachmentContent, parseIndexingLabel, parseIndexingRequestText, peekImagePreviewUrl, prepareDownloadText, presignExpiryEpochMs, previewImageContentType, previewMintCacheToken, previewableExtOf, readExpiredAttachmentHref, registerAttachmentParser, registerModelContextWindows, renderInlineLinkHtml, repairUrlEntities, repairUrlWhitespace, resolveImagePreviewUrl, runIndexUniqueId, safeDecodeURIComponent, sanitizeAttachmentLinksForHistory, setProjectContextWindow, stripFileBlocksFromHistory, transformContentWithImages, transformContentWithOpenAIImages, truncateLabelForDisplay, upsertIndexRunRecordSafe, wallClockNow };
|
package/dist/engine.mjs
CHANGED
|
@@ -601,8 +601,41 @@ var EXPIRED_ATTACHMENT_URL_HOST = "_expired_.url";
|
|
|
601
601
|
var EXPIRED_ATTACHMENT_URL_ORIGIN = "https://" + EXPIRED_ATTACHMENT_URL_HOST;
|
|
602
602
|
var LINK_LABEL_MAX_DISPLAY_CHARS = 32;
|
|
603
603
|
var EXPIRED_LINK_REFRESH_EXPIRES_SECONDS = 20 * 60;
|
|
604
|
+
var PREVIEW_URL_EXPIRES_SECONDS = 60 * 60;
|
|
604
605
|
var PREVIEW_BROWSER_CACHE_SECONDS = 7 * 24 * 60 * 60;
|
|
605
606
|
var LINK_REFRESH_WINDOW_MS = (EXPIRED_LINK_REFRESH_EXPIRES_SECONDS - 5 * 60) * 1e3;
|
|
607
|
+
var MINT_CACHE_GENERATION = 2;
|
|
608
|
+
function mintCacheBustStamp(now) {
|
|
609
|
+
return Math.floor((now == null ? Date.now() : now) / LINK_REFRESH_WINDOW_MS);
|
|
610
|
+
}
|
|
611
|
+
function previewMintCacheToken(refresh) {
|
|
612
|
+
if (!refresh) return String(MINT_CACHE_GENERATION);
|
|
613
|
+
return MINT_CACHE_GENERATION + "." + mintCacheBustStamp();
|
|
614
|
+
}
|
|
615
|
+
var PRESIGN_SAFETY_MARGIN_MS = 60 * 1e3;
|
|
616
|
+
function presignExpiryEpochMs(url) {
|
|
617
|
+
if (!url) return null;
|
|
618
|
+
var q = url.indexOf("?");
|
|
619
|
+
if (q < 0) return null;
|
|
620
|
+
var params;
|
|
621
|
+
try {
|
|
622
|
+
params = new URLSearchParams(url.slice(q + 1));
|
|
623
|
+
} catch (e) {
|
|
624
|
+
return null;
|
|
625
|
+
}
|
|
626
|
+
var v2 = params.get("Expires");
|
|
627
|
+
if (v2 && /^\d+$/.test(v2)) return parseInt(v2, 10) * 1e3;
|
|
628
|
+
var signed = params.get("X-Amz-Date");
|
|
629
|
+
var lifetime = params.get("X-Amz-Expires");
|
|
630
|
+
if (signed && lifetime && /^\d+$/.test(lifetime)) {
|
|
631
|
+
var m = /^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})Z$/.exec(signed);
|
|
632
|
+
if (m) {
|
|
633
|
+
var at = Date.UTC(+m[1], +m[2] - 1, +m[3], +m[4], +m[5], +m[6]);
|
|
634
|
+
return at + parseInt(lifetime, 10) * 1e3;
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
return null;
|
|
638
|
+
}
|
|
606
639
|
function createInlineLinkRegex() {
|
|
607
640
|
return /src::(\S+)|\[([^\]\n]+)\]\((https?:\/\/(?:[^\s()]|\([^\s()]*\))+)\)|\[([^\]\n]+)\]\(((?:[^()\n]|\([^()\n]*\))+)\)|(https?:\/\/[^\s<>"']+)/g;
|
|
608
641
|
}
|
|
@@ -853,6 +886,13 @@ function linkUnavailableKeyForPath(remotePath) {
|
|
|
853
886
|
function linkUnavailableKeyForHref(href) {
|
|
854
887
|
return "href:" + (href || "");
|
|
855
888
|
}
|
|
889
|
+
function linkUnavailableKeysForPath(remotePath) {
|
|
890
|
+
if (!remotePath) return [];
|
|
891
|
+
return [
|
|
892
|
+
linkUnavailableKeyForPath(remotePath),
|
|
893
|
+
linkUnavailableKeyForHref(buildDisplayExpiredAttachmentHref(remotePath))
|
|
894
|
+
];
|
|
895
|
+
}
|
|
856
896
|
function isLinkUnavailable(link, map) {
|
|
857
897
|
if (!link || !map) return false;
|
|
858
898
|
if (link.remotePath && map[linkUnavailableKeyForPath(link.remotePath)]) return true;
|
|
@@ -1275,8 +1315,11 @@ function clearImagePreviewCache(scope) {
|
|
|
1275
1315
|
}
|
|
1276
1316
|
function peekImagePreviewUrl(ctx, remotePath) {
|
|
1277
1317
|
var hit = previewUrlCache[cacheKey(ctx.scope, remotePath)];
|
|
1278
|
-
if (hit
|
|
1279
|
-
return null;
|
|
1318
|
+
if (!hit) return null;
|
|
1319
|
+
if (Date.now() - hit.at >= LINK_REFRESH_WINDOW_MS) return null;
|
|
1320
|
+
var dies = presignExpiryEpochMs(hit.url);
|
|
1321
|
+
if (dies !== null && Date.now() >= dies - PRESIGN_SAFETY_MARGIN_MS) return null;
|
|
1322
|
+
return hit.url;
|
|
1280
1323
|
}
|
|
1281
1324
|
function resolveImagePreviewUrl(ctx, remotePath, contentType, refresh) {
|
|
1282
1325
|
var key = cacheKey(ctx.scope, remotePath);
|
|
@@ -1326,6 +1369,7 @@ function hydrateOne(img, ctx) {
|
|
|
1326
1369
|
img.setAttribute("data-bq-img-state", "loading");
|
|
1327
1370
|
img.addEventListener("load", function() {
|
|
1328
1371
|
img.setAttribute("data-bq-img-state", "ready");
|
|
1372
|
+
img.removeAttribute("data-bq-img-retry");
|
|
1329
1373
|
if (ctx.onLoad) ctx.onLoad(path);
|
|
1330
1374
|
});
|
|
1331
1375
|
img.addEventListener("error", function() {
|
|
@@ -6071,6 +6115,6 @@ function buildChatDisplayList(messages, opts) {
|
|
|
6071
6115
|
return out;
|
|
6072
6116
|
}
|
|
6073
6117
|
|
|
6074
|
-
export { BG_INDEXING_QUEUE_SUFFIX, BOM, BOM_EXTS, CLAUDE_INPUT_CAP_RATIO, CLAUDE_PER_REQUEST_INPUT_CAP, CONTEXT_WINDOW_BY_MODEL, CONTEXT_WINDOW_DEFAULT, ChatSession, DEFAULT_CLAUDE_MODEL, DEFAULT_CONTEXT_WINDOW, DEFAULT_OPENAI_MODEL, EMPTY_INDEXING_REPLY, EXPIRED_ATTACHMENT_URL_HOST, EXPIRED_ATTACHMENT_URL_ORIGIN, EXPIRED_LINK_REFRESH_EXPIRES_SECONDS, EXT_CONTENT_TYPES, HISTORY_BUDGET_RATIO, HISTORY_FILL_SLACK_PX, HISTORY_TOKEN_BUDGET, HTML_EXTS, HTML_HEAD_WINDOW, IMAGE_PREVIEWS_PER_MESSAGE, INDEXING_COMPLETE_MARKER, INLINE_LINK_GLYPH, INLINE_LINK_UNAVAILABLE_GLYPH, INLINE_LINK_UNAVAILABLE_SUFFIX, INPUT_CAP_RATIO, LINK_LABEL_MAX_DISPLAY_CHARS, LINK_REFRESH_WINDOW_MS, MAX_CONCURRENT_BG_POLLS, MAX_HISTORY_FILL_PAGES, MAX_HISTORY_MESSAGES, MAX_OUTPUT_BY_MODEL, MAX_OUTPUT_TOKENS, MAX_PARSED_CONTENT_CHARS, MCP_NAME, MIN_INPUT_TOKEN_BUDGET, MIN_PER_REQUEST_INPUT_CAP, OUTPUT_TOKEN_RESERVE, POLL_INTERVAL, PREVIEWABLE_IMAGE_CONTENT_TYPES, PREVIEW_BROWSER_CACHE_SECONDS, RENDER_FROM_TOKEN, RTF_EXTS, RUN_RECORD_WORKING_STALE_MS, TOOL_AND_RESPONSE_BUFFER, XML_EXTS, __resetSplitHistoryState, applyEncodingDeclaration, bgIndexingQueueName, buildAiAgentValue, buildBoundedChatMessages, buildChatDisplayList, buildChatSystemPrompt, buildDisplayExpiredAttachmentHref, buildHistoryItemFullId, buildIndexingContinueMessage, buildIndexingRenderContinueTemplate, buildIndexingRenderMessage, buildIndexingSystemPrompt, buildIndexingUserMessage, buildIndexingWindowMessage, callClaudeWithMcp, callClaudeWithPublicMcp, callOpenAIWithPublicMcp, chatEngineConfig, classifyInlineLink, clearAttachmentParsers, clearImagePreviewCache, composeUserMessage, configureChatEngine, contentTypeForExt, createHistoryFiller, createInlineLinkRegex, encodePathSegments, encodingClassForExt, ensureHtmlCharset, ensureXmlEncoding, escapeInlineHtml, escapeRtfNonAscii, estimateMessageTokens, estimateTextTokens, extOf, extractClaudeText, extractLastUserTextFromRequest, extractOpenAIText, extractRemotePathFromAttachmentHref, fetchLiveIndexingKeys, fillHistoryViewport, filterListByClearHorizon, findAttachmentParser, formatChatTimestamp, getAttachmentParsers, getChatHistory, getContextWindow, getErrorMessage, getExpiredAttachmentVisiblePath, getInputTokenBudget, getMaxOutputTokens, getModelContextWindow, getProjectContextWindow, getSplitChatHistory, getVisionProfile, groupAttachmentFailures, hasBom, hydrateImagePreviews, indexDoneUniqueId, isAuthExpiredError, isBgIndexingQueue, isErrorResponseBody, isHttpUrlLike, isIndexingRequestText, isLinkUnavailable, isNonRetryableRequestError, isOfficeFile, isPreviewableImagePath, isProviderApiKeyError, isServerExtractable, isServiceDbAttachmentHref, linkUnavailableKeyForHref, linkUnavailableKeyForPath, listClaudeModels, listOpenAIModels, looksLikeRtf, makeExtractPlaceholder, mapHistoryListToMessages, markImagePreviewStale, needsBomForExt, normalizeAttachmentPathCandidate, normalizeExt, normalizeTextContent, normalizeTrailingInlineToken, notifyAgentSaveAttachment, parseAiAgentValue, parseAttachmentContent, parseIndexingLabel, parseIndexingRequestText, peekImagePreviewUrl, prepareDownloadText, previewImageContentType, previewableExtOf, readExpiredAttachmentHref, registerAttachmentParser, registerModelContextWindows, renderInlineLinkHtml, repairUrlEntities, repairUrlWhitespace, resolveImagePreviewUrl, runIndexUniqueId, safeDecodeURIComponent, sanitizeAttachmentLinksForHistory, setProjectContextWindow, stripFileBlocksFromHistory, transformContentWithImages, transformContentWithOpenAIImages, truncateLabelForDisplay, upsertIndexRunRecordSafe, wallClockNow };
|
|
6118
|
+
export { BG_INDEXING_QUEUE_SUFFIX, BOM, BOM_EXTS, CLAUDE_INPUT_CAP_RATIO, CLAUDE_PER_REQUEST_INPUT_CAP, CONTEXT_WINDOW_BY_MODEL, CONTEXT_WINDOW_DEFAULT, ChatSession, DEFAULT_CLAUDE_MODEL, DEFAULT_CONTEXT_WINDOW, DEFAULT_OPENAI_MODEL, EMPTY_INDEXING_REPLY, EXPIRED_ATTACHMENT_URL_HOST, EXPIRED_ATTACHMENT_URL_ORIGIN, EXPIRED_LINK_REFRESH_EXPIRES_SECONDS, EXT_CONTENT_TYPES, HISTORY_BUDGET_RATIO, HISTORY_FILL_SLACK_PX, HISTORY_TOKEN_BUDGET, HTML_EXTS, HTML_HEAD_WINDOW, IMAGE_PREVIEWS_PER_MESSAGE, INDEXING_COMPLETE_MARKER, INLINE_LINK_GLYPH, INLINE_LINK_UNAVAILABLE_GLYPH, INLINE_LINK_UNAVAILABLE_SUFFIX, INPUT_CAP_RATIO, LINK_LABEL_MAX_DISPLAY_CHARS, LINK_REFRESH_WINDOW_MS, 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, OUTPUT_TOKEN_RESERVE, POLL_INTERVAL, PRESIGN_SAFETY_MARGIN_MS, PREVIEWABLE_IMAGE_CONTENT_TYPES, PREVIEW_BROWSER_CACHE_SECONDS, PREVIEW_URL_EXPIRES_SECONDS, RENDER_FROM_TOKEN, RTF_EXTS, RUN_RECORD_WORKING_STALE_MS, TOOL_AND_RESPONSE_BUFFER, XML_EXTS, __resetSplitHistoryState, applyEncodingDeclaration, bgIndexingQueueName, buildAiAgentValue, buildBoundedChatMessages, buildChatDisplayList, buildChatSystemPrompt, buildDisplayExpiredAttachmentHref, buildHistoryItemFullId, buildIndexingContinueMessage, buildIndexingRenderContinueTemplate, buildIndexingRenderMessage, buildIndexingSystemPrompt, buildIndexingUserMessage, buildIndexingWindowMessage, callClaudeWithMcp, callClaudeWithPublicMcp, callOpenAIWithPublicMcp, chatEngineConfig, classifyInlineLink, clearAttachmentParsers, clearImagePreviewCache, composeUserMessage, configureChatEngine, contentTypeForExt, createHistoryFiller, createInlineLinkRegex, encodePathSegments, encodingClassForExt, ensureHtmlCharset, ensureXmlEncoding, escapeInlineHtml, escapeRtfNonAscii, estimateMessageTokens, estimateTextTokens, extOf, extractClaudeText, extractLastUserTextFromRequest, extractOpenAIText, extractRemotePathFromAttachmentHref, fetchLiveIndexingKeys, fillHistoryViewport, filterListByClearHorizon, findAttachmentParser, formatChatTimestamp, getAttachmentParsers, getChatHistory, getContextWindow, getErrorMessage, getExpiredAttachmentVisiblePath, getInputTokenBudget, getMaxOutputTokens, getModelContextWindow, getProjectContextWindow, getSplitChatHistory, getVisionProfile, groupAttachmentFailures, hasBom, hydrateImagePreviews, indexDoneUniqueId, isAuthExpiredError, isBgIndexingQueue, isErrorResponseBody, isHttpUrlLike, isIndexingRequestText, isLinkUnavailable, isNonRetryableRequestError, isOfficeFile, isPreviewableImagePath, isProviderApiKeyError, isServerExtractable, isServiceDbAttachmentHref, linkUnavailableKeyForHref, linkUnavailableKeyForPath, linkUnavailableKeysForPath, listClaudeModels, listOpenAIModels, looksLikeRtf, makeExtractPlaceholder, mapHistoryListToMessages, markImagePreviewStale, mintCacheBustStamp, needsBomForExt, normalizeAttachmentPathCandidate, normalizeExt, normalizeTextContent, normalizeTrailingInlineToken, notifyAgentSaveAttachment, parseAiAgentValue, parseAttachmentContent, parseIndexingLabel, parseIndexingRequestText, peekImagePreviewUrl, prepareDownloadText, presignExpiryEpochMs, previewImageContentType, previewMintCacheToken, previewableExtOf, readExpiredAttachmentHref, registerAttachmentParser, registerModelContextWindows, renderInlineLinkHtml, repairUrlEntities, repairUrlWhitespace, resolveImagePreviewUrl, runIndexUniqueId, safeDecodeURIComponent, sanitizeAttachmentLinksForHistory, setProjectContextWindow, stripFileBlocksFromHistory, transformContentWithImages, transformContentWithOpenAIImages, truncateLabelForDisplay, upsertIndexRunRecordSafe, wallClockNow };
|
|
6075
6119
|
//# sourceMappingURL=engine.mjs.map
|
|
6076
6120
|
//# sourceMappingURL=engine.mjs.map
|