bunnyquery 1.3.0 → 1.3.2
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.css +7 -0
- package/bunnyquery.js +75 -3
- package/dist/engine.cjs +31 -0
- package/dist/engine.cjs.map +1 -1
- package/dist/engine.d.mts +22 -1
- package/dist/engine.d.ts +22 -1
- package/dist/engine.mjs +31 -1
- package/dist/engine.mjs.map +1 -1
- package/package.json +1 -1
- package/src/engine/attachments.ts +0 -0
- package/src/engine/index.ts +5 -0
- package/src/engine/session.ts +9 -0
- package/src/widget.css +7 -0
package/dist/engine.d.mts
CHANGED
|
@@ -63,6 +63,27 @@ declare function composeUserMessage(text: string, attachmentUrls: Array<{
|
|
|
63
63
|
storagePath?: string;
|
|
64
64
|
}>): ComposedUserMessage;
|
|
65
65
|
|
|
66
|
+
/**
|
|
67
|
+
* Attachment helpers shared by every consumer's view layer.
|
|
68
|
+
*
|
|
69
|
+
* The upload ORCHESTRATION is per-consumer (agent.vue does admin storage
|
|
70
|
+
* accounting; the widget uses get-signed-url), but the failure-reporting shape
|
|
71
|
+
* is identical, so it lives here. When an upload or its indexing request fails,
|
|
72
|
+
* the orchestrator records the original `error.code` / `error.message` on the
|
|
73
|
+
* attachment (`att.errorCode` / `att.errorDetail`); this groups those failed
|
|
74
|
+
* attachments by (code, description) so a single report dialog can list each
|
|
75
|
+
* distinct error once with all the files it affected.
|
|
76
|
+
*/
|
|
77
|
+
interface AttachmentFailureGroup {
|
|
78
|
+
/** The failing `error.code` (empty string when the error carried none). */
|
|
79
|
+
code: string;
|
|
80
|
+
/** The failing `error.message` / human description. */
|
|
81
|
+
message: string;
|
|
82
|
+
/** Display names of the attachments that hit this exact (code, message). */
|
|
83
|
+
files: string[];
|
|
84
|
+
}
|
|
85
|
+
declare function groupAttachmentFailures(attachments: any[]): AttachmentFailureGroup[];
|
|
86
|
+
|
|
66
87
|
/**
|
|
67
88
|
* BASE PROMPT — Chat assistant
|
|
68
89
|
* ============================================================================
|
|
@@ -472,4 +493,4 @@ declare class ChatSession {
|
|
|
472
493
|
bumpGate(): void;
|
|
473
494
|
}
|
|
474
495
|
|
|
475
|
-
export { type AttachmentSaveInfo, BG_INDEXING_QUEUE_SUFFIX, type BgTaskEntry, type BoundedChatOptions, type BuildIndexingUserMessageOptions, 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_OPENAI_MODEL, EXPIRED_ATTACHMENT_URL_HOST, EXPIRED_ATTACHMENT_URL_ORIGIN, type ExtractDirective, HISTORY_TOKEN_BUDGET, type IndexingAttachmentInfo, type IndexingSystemPromptParams, LINK_LABEL_MAX_DISPLAY_CHARS, MAX_HISTORY_MESSAGES, MCP_NAME, MIN_INPUT_TOKEN_BUDGET, type MapHistoryOptions, OUTPUT_TOKEN_RESERVE, type OpenAIMessage, POLL_INTERVAL, TOOL_AND_RESPONSE_BUFFER, buildBoundedChatMessages, buildChatSystemPrompt, buildDisplayExpiredAttachmentHref, buildIndexingSystemPrompt, buildIndexingUserMessage, callClaudeWithMcp, callClaudeWithPublicMcp, callOpenAIWithPublicMcp, chatEngineConfig, composeUserMessage, configureChatEngine, createInlineLinkRegex, encodePathSegments, estimateMessageTokens, estimateTextTokens, extractClaudeText, extractLastUserTextFromRequest, extractOpenAIText, extractRemotePathFromAttachmentHref, filterListByClearHorizon, getChatHistory, getContextWindow, getErrorMessage, getExpiredAttachmentVisiblePath, isAuthExpiredError, isErrorResponseBody, isOfficeFile, listClaudeModels, listOpenAIModels, makeExtractPlaceholder, mapHistoryListToMessages, normalizeAttachmentPathCandidate, normalizeTextContent, notifyAgentSaveAttachment, safeDecodeURIComponent, sanitizeAttachmentLinksForHistory, stripFileBlocksFromHistory, transformContentWithImages, transformContentWithOpenAIImages, truncateLabelForDisplay };
|
|
496
|
+
export { type AttachmentFailureGroup, type AttachmentSaveInfo, BG_INDEXING_QUEUE_SUFFIX, type BgTaskEntry, type BoundedChatOptions, type BuildIndexingUserMessageOptions, 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_OPENAI_MODEL, EXPIRED_ATTACHMENT_URL_HOST, EXPIRED_ATTACHMENT_URL_ORIGIN, type ExtractDirective, HISTORY_TOKEN_BUDGET, type IndexingAttachmentInfo, type IndexingSystemPromptParams, LINK_LABEL_MAX_DISPLAY_CHARS, MAX_HISTORY_MESSAGES, MCP_NAME, MIN_INPUT_TOKEN_BUDGET, type MapHistoryOptions, OUTPUT_TOKEN_RESERVE, type OpenAIMessage, POLL_INTERVAL, TOOL_AND_RESPONSE_BUFFER, buildBoundedChatMessages, buildChatSystemPrompt, buildDisplayExpiredAttachmentHref, buildIndexingSystemPrompt, buildIndexingUserMessage, callClaudeWithMcp, callClaudeWithPublicMcp, callOpenAIWithPublicMcp, chatEngineConfig, composeUserMessage, configureChatEngine, createInlineLinkRegex, encodePathSegments, estimateMessageTokens, estimateTextTokens, extractClaudeText, extractLastUserTextFromRequest, extractOpenAIText, extractRemotePathFromAttachmentHref, filterListByClearHorizon, getChatHistory, getContextWindow, getErrorMessage, getExpiredAttachmentVisiblePath, groupAttachmentFailures, isAuthExpiredError, isErrorResponseBody, isOfficeFile, listClaudeModels, listOpenAIModels, makeExtractPlaceholder, mapHistoryListToMessages, normalizeAttachmentPathCandidate, normalizeTextContent, notifyAgentSaveAttachment, safeDecodeURIComponent, sanitizeAttachmentLinksForHistory, stripFileBlocksFromHistory, transformContentWithImages, transformContentWithOpenAIImages, truncateLabelForDisplay };
|
package/dist/engine.d.ts
CHANGED
|
@@ -63,6 +63,27 @@ declare function composeUserMessage(text: string, attachmentUrls: Array<{
|
|
|
63
63
|
storagePath?: string;
|
|
64
64
|
}>): ComposedUserMessage;
|
|
65
65
|
|
|
66
|
+
/**
|
|
67
|
+
* Attachment helpers shared by every consumer's view layer.
|
|
68
|
+
*
|
|
69
|
+
* The upload ORCHESTRATION is per-consumer (agent.vue does admin storage
|
|
70
|
+
* accounting; the widget uses get-signed-url), but the failure-reporting shape
|
|
71
|
+
* is identical, so it lives here. When an upload or its indexing request fails,
|
|
72
|
+
* the orchestrator records the original `error.code` / `error.message` on the
|
|
73
|
+
* attachment (`att.errorCode` / `att.errorDetail`); this groups those failed
|
|
74
|
+
* attachments by (code, description) so a single report dialog can list each
|
|
75
|
+
* distinct error once with all the files it affected.
|
|
76
|
+
*/
|
|
77
|
+
interface AttachmentFailureGroup {
|
|
78
|
+
/** The failing `error.code` (empty string when the error carried none). */
|
|
79
|
+
code: string;
|
|
80
|
+
/** The failing `error.message` / human description. */
|
|
81
|
+
message: string;
|
|
82
|
+
/** Display names of the attachments that hit this exact (code, message). */
|
|
83
|
+
files: string[];
|
|
84
|
+
}
|
|
85
|
+
declare function groupAttachmentFailures(attachments: any[]): AttachmentFailureGroup[];
|
|
86
|
+
|
|
66
87
|
/**
|
|
67
88
|
* BASE PROMPT — Chat assistant
|
|
68
89
|
* ============================================================================
|
|
@@ -472,4 +493,4 @@ declare class ChatSession {
|
|
|
472
493
|
bumpGate(): void;
|
|
473
494
|
}
|
|
474
495
|
|
|
475
|
-
export { type AttachmentSaveInfo, BG_INDEXING_QUEUE_SUFFIX, type BgTaskEntry, type BoundedChatOptions, type BuildIndexingUserMessageOptions, 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_OPENAI_MODEL, EXPIRED_ATTACHMENT_URL_HOST, EXPIRED_ATTACHMENT_URL_ORIGIN, type ExtractDirective, HISTORY_TOKEN_BUDGET, type IndexingAttachmentInfo, type IndexingSystemPromptParams, LINK_LABEL_MAX_DISPLAY_CHARS, MAX_HISTORY_MESSAGES, MCP_NAME, MIN_INPUT_TOKEN_BUDGET, type MapHistoryOptions, OUTPUT_TOKEN_RESERVE, type OpenAIMessage, POLL_INTERVAL, TOOL_AND_RESPONSE_BUFFER, buildBoundedChatMessages, buildChatSystemPrompt, buildDisplayExpiredAttachmentHref, buildIndexingSystemPrompt, buildIndexingUserMessage, callClaudeWithMcp, callClaudeWithPublicMcp, callOpenAIWithPublicMcp, chatEngineConfig, composeUserMessage, configureChatEngine, createInlineLinkRegex, encodePathSegments, estimateMessageTokens, estimateTextTokens, extractClaudeText, extractLastUserTextFromRequest, extractOpenAIText, extractRemotePathFromAttachmentHref, filterListByClearHorizon, getChatHistory, getContextWindow, getErrorMessage, getExpiredAttachmentVisiblePath, isAuthExpiredError, isErrorResponseBody, isOfficeFile, listClaudeModels, listOpenAIModels, makeExtractPlaceholder, mapHistoryListToMessages, normalizeAttachmentPathCandidate, normalizeTextContent, notifyAgentSaveAttachment, safeDecodeURIComponent, sanitizeAttachmentLinksForHistory, stripFileBlocksFromHistory, transformContentWithImages, transformContentWithOpenAIImages, truncateLabelForDisplay };
|
|
496
|
+
export { type AttachmentFailureGroup, type AttachmentSaveInfo, BG_INDEXING_QUEUE_SUFFIX, type BgTaskEntry, type BoundedChatOptions, type BuildIndexingUserMessageOptions, 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_OPENAI_MODEL, EXPIRED_ATTACHMENT_URL_HOST, EXPIRED_ATTACHMENT_URL_ORIGIN, type ExtractDirective, HISTORY_TOKEN_BUDGET, type IndexingAttachmentInfo, type IndexingSystemPromptParams, LINK_LABEL_MAX_DISPLAY_CHARS, MAX_HISTORY_MESSAGES, MCP_NAME, MIN_INPUT_TOKEN_BUDGET, type MapHistoryOptions, OUTPUT_TOKEN_RESERVE, type OpenAIMessage, POLL_INTERVAL, TOOL_AND_RESPONSE_BUFFER, buildBoundedChatMessages, buildChatSystemPrompt, buildDisplayExpiredAttachmentHref, buildIndexingSystemPrompt, buildIndexingUserMessage, callClaudeWithMcp, callClaudeWithPublicMcp, callOpenAIWithPublicMcp, chatEngineConfig, composeUserMessage, configureChatEngine, createInlineLinkRegex, encodePathSegments, estimateMessageTokens, estimateTextTokens, extractClaudeText, extractLastUserTextFromRequest, extractOpenAIText, extractRemotePathFromAttachmentHref, filterListByClearHorizon, getChatHistory, getContextWindow, getErrorMessage, getExpiredAttachmentVisiblePath, groupAttachmentFailures, isAuthExpiredError, isErrorResponseBody, isOfficeFile, listClaudeModels, listOpenAIModels, makeExtractPlaceholder, mapHistoryListToMessages, normalizeAttachmentPathCandidate, normalizeTextContent, notifyAgentSaveAttachment, safeDecodeURIComponent, sanitizeAttachmentLinksForHistory, stripFileBlocksFromHistory, transformContentWithImages, transformContentWithOpenAIImages, truncateLabelForDisplay };
|
package/dist/engine.mjs
CHANGED
|
@@ -77,6 +77,28 @@ Extracted content of attached office files (read inline below; do NOT fetch thei
|
|
|
77
77
|
return { composed, composedForLlm, extractContent };
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
// src/engine/attachments.ts
|
|
81
|
+
function groupAttachmentFailures(attachments) {
|
|
82
|
+
const groups = {};
|
|
83
|
+
const order = [];
|
|
84
|
+
(attachments || []).forEach(function(att) {
|
|
85
|
+
if (!att || att.status !== "error" && att.status !== "indexError") return;
|
|
86
|
+
const code = String(att.errorCode || "");
|
|
87
|
+
const message = String(
|
|
88
|
+
att.errorDetail || att.errorMessage || (att.status === "indexError" ? "File indexing failed" : "File upload has failed")
|
|
89
|
+
);
|
|
90
|
+
const key = code + "\0" + message;
|
|
91
|
+
if (!groups[key]) {
|
|
92
|
+
groups[key] = { code, message, files: [] };
|
|
93
|
+
order.push(key);
|
|
94
|
+
}
|
|
95
|
+
groups[key].files.push(String(att.name || "(unnamed file)"));
|
|
96
|
+
});
|
|
97
|
+
return order.map(function(k) {
|
|
98
|
+
return groups[k];
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
80
102
|
// src/engine/prompts/chat_system_prompt.ts
|
|
81
103
|
function buildChatSystemPrompt(params) {
|
|
82
104
|
const { formattedServiceId, serviceName, serviceDescription } = params;
|
|
@@ -1721,6 +1743,8 @@ var ChatSession = class {
|
|
|
1721
1743
|
att.status = "uploading";
|
|
1722
1744
|
att.progress = 0;
|
|
1723
1745
|
att.errorMessage = "";
|
|
1746
|
+
att.errorCode = "";
|
|
1747
|
+
att.errorDetail = "";
|
|
1724
1748
|
this.host.renderAttachmentChips();
|
|
1725
1749
|
var members = att.kind === "folder" ? (att.files || []).map(function(f) {
|
|
1726
1750
|
return { file: f.file, relPath: f.path, storagePath: self.host.storagePathFor(f.path) };
|
|
@@ -1802,6 +1826,10 @@ var ChatSession = class {
|
|
|
1802
1826
|
}, function(e) {
|
|
1803
1827
|
console.error("[chat-engine] indexing request failed", e);
|
|
1804
1828
|
anyIndexFailed = true;
|
|
1829
|
+
if (!att.errorCode && !att.errorDetail) {
|
|
1830
|
+
att.errorCode = e && (e.code || e.body && e.body.code) || "";
|
|
1831
|
+
att.errorDetail = e && (e.message || e.body && e.body.message) || (typeof e === "string" ? e : "");
|
|
1832
|
+
}
|
|
1805
1833
|
});
|
|
1806
1834
|
});
|
|
1807
1835
|
});
|
|
@@ -1856,6 +1884,8 @@ var ChatSession = class {
|
|
|
1856
1884
|
if (removed || aborted) return;
|
|
1857
1885
|
att.status = "error";
|
|
1858
1886
|
att.errorMessage = "File upload has failed";
|
|
1887
|
+
att.errorCode = err && (err.code || err.body && err.body.code) || "";
|
|
1888
|
+
att.errorDetail = err && (err.message || err.body && err.body.message) || (typeof err === "string" ? err : "");
|
|
1859
1889
|
self.host.renderAttachmentChips();
|
|
1860
1890
|
});
|
|
1861
1891
|
});
|
|
@@ -1879,6 +1909,6 @@ var ChatSession = class {
|
|
|
1879
1909
|
}
|
|
1880
1910
|
};
|
|
1881
1911
|
|
|
1882
|
-
export { BG_INDEXING_QUEUE_SUFFIX, CLAUDE_PER_REQUEST_INPUT_CAP, CONTEXT_WINDOW_BY_MODEL, CONTEXT_WINDOW_DEFAULT, ChatSession, DEFAULT_CLAUDE_MODEL, DEFAULT_OPENAI_MODEL, EXPIRED_ATTACHMENT_URL_HOST, EXPIRED_ATTACHMENT_URL_ORIGIN, HISTORY_TOKEN_BUDGET, LINK_LABEL_MAX_DISPLAY_CHARS, MAX_HISTORY_MESSAGES, MCP_NAME, MIN_INPUT_TOKEN_BUDGET, OUTPUT_TOKEN_RESERVE, POLL_INTERVAL, TOOL_AND_RESPONSE_BUFFER, buildBoundedChatMessages, buildChatSystemPrompt, buildDisplayExpiredAttachmentHref, buildIndexingSystemPrompt, buildIndexingUserMessage, callClaudeWithMcp, callClaudeWithPublicMcp, callOpenAIWithPublicMcp, chatEngineConfig, composeUserMessage, configureChatEngine, createInlineLinkRegex, encodePathSegments, estimateMessageTokens, estimateTextTokens, extractClaudeText, extractLastUserTextFromRequest, extractOpenAIText, extractRemotePathFromAttachmentHref, filterListByClearHorizon, getChatHistory, getContextWindow, getErrorMessage, getExpiredAttachmentVisiblePath, isAuthExpiredError, isErrorResponseBody, isOfficeFile, listClaudeModels, listOpenAIModels, makeExtractPlaceholder, mapHistoryListToMessages, normalizeAttachmentPathCandidate, normalizeTextContent, notifyAgentSaveAttachment, safeDecodeURIComponent, sanitizeAttachmentLinksForHistory, stripFileBlocksFromHistory, transformContentWithImages, transformContentWithOpenAIImages, truncateLabelForDisplay };
|
|
1912
|
+
export { BG_INDEXING_QUEUE_SUFFIX, CLAUDE_PER_REQUEST_INPUT_CAP, CONTEXT_WINDOW_BY_MODEL, CONTEXT_WINDOW_DEFAULT, ChatSession, DEFAULT_CLAUDE_MODEL, DEFAULT_OPENAI_MODEL, EXPIRED_ATTACHMENT_URL_HOST, EXPIRED_ATTACHMENT_URL_ORIGIN, HISTORY_TOKEN_BUDGET, LINK_LABEL_MAX_DISPLAY_CHARS, MAX_HISTORY_MESSAGES, MCP_NAME, MIN_INPUT_TOKEN_BUDGET, OUTPUT_TOKEN_RESERVE, POLL_INTERVAL, TOOL_AND_RESPONSE_BUFFER, buildBoundedChatMessages, buildChatSystemPrompt, buildDisplayExpiredAttachmentHref, buildIndexingSystemPrompt, buildIndexingUserMessage, callClaudeWithMcp, callClaudeWithPublicMcp, callOpenAIWithPublicMcp, chatEngineConfig, composeUserMessage, configureChatEngine, createInlineLinkRegex, encodePathSegments, estimateMessageTokens, estimateTextTokens, extractClaudeText, extractLastUserTextFromRequest, extractOpenAIText, extractRemotePathFromAttachmentHref, filterListByClearHorizon, getChatHistory, getContextWindow, getErrorMessage, getExpiredAttachmentVisiblePath, groupAttachmentFailures, isAuthExpiredError, isErrorResponseBody, isOfficeFile, listClaudeModels, listOpenAIModels, makeExtractPlaceholder, mapHistoryListToMessages, normalizeAttachmentPathCandidate, normalizeTextContent, notifyAgentSaveAttachment, safeDecodeURIComponent, sanitizeAttachmentLinksForHistory, stripFileBlocksFromHistory, transformContentWithImages, transformContentWithOpenAIImages, truncateLabelForDisplay };
|
|
1883
1913
|
//# sourceMappingURL=engine.mjs.map
|
|
1884
1914
|
//# sourceMappingURL=engine.mjs.map
|