@astro-minimax/ai 0.9.0 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +108 -18
- package/dist/cache/global-cache.d.ts +6 -2
- package/dist/cache/global-cache.d.ts.map +1 -1
- package/dist/cache/global-cache.js +24 -9
- package/dist/cache/index.d.ts +7 -6
- package/dist/cache/index.d.ts.map +1 -1
- package/dist/cache/index.js +12 -4
- package/dist/cache/injection-cache.d.ts +36 -0
- package/dist/cache/injection-cache.d.ts.map +1 -0
- package/dist/cache/injection-cache.js +90 -0
- package/dist/cache/kv-adapter.d.ts.map +1 -1
- package/dist/cache/kv-adapter.js +2 -1
- package/dist/cache/memory-adapter.d.ts.map +1 -1
- package/dist/cache/memory-adapter.js +2 -1
- package/dist/cache/response-cache.d.ts +10 -5
- package/dist/cache/response-cache.d.ts.map +1 -1
- package/dist/cache/response-cache.js +18 -6
- package/dist/components/AIChatContainer.d.ts +2 -2
- package/dist/components/AIChatContainer.d.ts.map +1 -1
- package/dist/components/AIChatContainer.js +8 -920
- package/dist/components/ChatInput.d.ts +15 -0
- package/dist/components/ChatInput.d.ts.map +1 -0
- package/dist/components/ChatInput.js +72 -0
- package/dist/components/ChatPanel.d.ts +1 -1
- package/dist/components/ChatPanel.d.ts.map +1 -1
- package/dist/components/ChatPanel.js +210 -672
- package/dist/components/CodeBlock.d.ts +31 -0
- package/dist/components/CodeBlock.d.ts.map +1 -0
- package/dist/components/CodeBlock.js +143 -0
- package/dist/components/MarkmapBlock.d.ts +4 -0
- package/dist/components/MarkmapBlock.d.ts.map +1 -0
- package/dist/components/MarkmapBlock.js +180 -0
- package/dist/components/MermaidBlock.d.ts +4 -0
- package/dist/components/MermaidBlock.d.ts.map +1 -0
- package/dist/components/MermaidBlock.js +193 -0
- package/dist/components/MessageBubble.d.ts +21 -0
- package/dist/components/MessageBubble.d.ts.map +1 -0
- package/dist/components/MessageBubble.js +233 -0
- package/dist/components/ReasoningBlock.d.ts +6 -0
- package/dist/components/ReasoningBlock.d.ts.map +1 -0
- package/dist/components/ReasoningBlock.js +11 -0
- package/dist/components/RichText.d.ts +41 -0
- package/dist/components/RichText.d.ts.map +1 -0
- package/dist/components/RichText.js +202 -0
- package/dist/components/VizShared.d.ts +57 -0
- package/dist/components/VizShared.d.ts.map +1 -0
- package/dist/components/VizShared.js +233 -0
- package/dist/components/tool-auto-continue.d.ts +5 -0
- package/dist/components/tool-auto-continue.d.ts.map +1 -0
- package/dist/components/tool-auto-continue.js +33 -0
- package/dist/constants.d.ts +61 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +72 -0
- package/dist/data/index.d.ts +4 -3
- package/dist/data/index.d.ts.map +1 -1
- package/dist/data/index.js +4 -10
- package/dist/data/knowledge-types.d.ts +8 -0
- package/dist/data/knowledge-types.d.ts.map +1 -0
- package/dist/data/knowledge-types.js +14 -0
- package/dist/data/metadata-loader.d.ts +4 -28
- package/dist/data/metadata-loader.d.ts.map +1 -1
- package/dist/data/metadata-loader.js +11 -34
- package/dist/data/types.d.ts +17 -2
- package/dist/data/types.d.ts.map +1 -1
- package/dist/extensions/index.d.ts +5 -0
- package/dist/extensions/index.d.ts.map +1 -0
- package/dist/extensions/index.js +24 -0
- package/dist/extensions/injector.d.ts +14 -0
- package/dist/extensions/injector.d.ts.map +1 -0
- package/dist/extensions/injector.js +146 -0
- package/dist/extensions/loader.d.ts +5 -0
- package/dist/extensions/loader.d.ts.map +1 -0
- package/dist/extensions/loader.js +45 -0
- package/dist/extensions/registry.d.ts +4 -0
- package/dist/extensions/registry.d.ts.map +1 -0
- package/dist/extensions/registry.js +144 -0
- package/dist/extensions/types.d.ts +126 -0
- package/dist/extensions/types.d.ts.map +1 -0
- package/dist/extensions/types.js +0 -0
- package/dist/fact-registry/prompt-injector.d.ts +1 -1
- package/dist/fact-registry/prompt-injector.d.ts.map +1 -1
- package/dist/fact-registry/prompt-injector.js +2 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/intelligence/citation-guard.d.ts +2 -13
- package/dist/intelligence/citation-guard.d.ts.map +1 -1
- package/dist/intelligence/citation-guard.js +52 -23
- package/dist/intelligence/evidence-analysis.d.ts +24 -16
- package/dist/intelligence/evidence-analysis.d.ts.map +1 -1
- package/dist/intelligence/evidence-analysis.js +118 -20
- package/dist/intelligence/evidence-budget.d.ts +13 -0
- package/dist/intelligence/evidence-budget.d.ts.map +1 -0
- package/dist/intelligence/evidence-budget.js +49 -0
- package/dist/intelligence/index.d.ts +10 -4
- package/dist/intelligence/index.d.ts.map +1 -1
- package/dist/intelligence/index.js +27 -3
- package/dist/intelligence/keyword-extract.d.ts +1 -1
- package/dist/intelligence/keyword-extract.d.ts.map +1 -1
- package/dist/intelligence/keyword-extract.js +5 -9
- package/dist/intelligence/request-interpretation.d.ts +40 -0
- package/dist/intelligence/request-interpretation.d.ts.map +1 -0
- package/dist/intelligence/request-interpretation.js +71 -0
- package/dist/intelligence/response-templates.d.ts +1 -0
- package/dist/intelligence/response-templates.d.ts.map +1 -1
- package/dist/intelligence/response-templates.js +13 -0
- package/dist/prompt/dynamic-layer.d.ts +1 -5
- package/dist/prompt/dynamic-layer.d.ts.map +1 -1
- package/dist/prompt/dynamic-layer.js +145 -9
- package/dist/prompt/prompt-builder.d.ts +1 -1
- package/dist/prompt/prompt-builder.d.ts.map +1 -1
- package/dist/prompt/prompt-builder.js +5 -1
- package/dist/prompt/semi-static-layer.d.ts +1 -1
- package/dist/prompt/semi-static-layer.d.ts.map +1 -1
- package/dist/prompt/semi-static-layer.js +22 -12
- package/dist/prompt/static-layer.d.ts.map +1 -1
- package/dist/prompt/static-layer.js +37 -4
- package/dist/prompt/types.d.ts +9 -4
- package/dist/prompt/types.d.ts.map +1 -1
- package/dist/provider-manager/base.d.ts +5 -1
- package/dist/provider-manager/base.d.ts.map +1 -1
- package/dist/provider-manager/base.js +22 -2
- package/dist/provider-manager/config.d.ts.map +1 -1
- package/dist/provider-manager/config.js +3 -2
- package/dist/provider-manager/index.d.ts +1 -1
- package/dist/provider-manager/index.d.ts.map +1 -1
- package/dist/provider-manager/index.js +1 -2
- package/dist/provider-manager/manager.d.ts +10 -1
- package/dist/provider-manager/manager.d.ts.map +1 -1
- package/dist/provider-manager/manager.js +26 -10
- package/dist/provider-manager/openai.d.ts +2 -2
- package/dist/provider-manager/openai.d.ts.map +1 -1
- package/dist/provider-manager/openai.js +19 -4
- package/dist/provider-manager/types.d.ts +18 -38
- package/dist/provider-manager/types.d.ts.map +1 -1
- package/dist/provider-manager/workers.d.ts +2 -2
- package/dist/provider-manager/workers.d.ts.map +1 -1
- package/dist/provider-manager/workers.js +15 -4
- package/dist/query/followup.d.ts +7 -0
- package/dist/query/followup.d.ts.map +1 -0
- package/dist/query/followup.js +46 -0
- package/dist/query/intent.d.ts +6 -0
- package/dist/query/intent.d.ts.map +1 -0
- package/dist/query/intent.js +137 -0
- package/dist/query/types.d.ts +8 -0
- package/dist/query/types.d.ts.map +1 -0
- package/dist/query/types.js +0 -0
- package/dist/search/hybrid-search.d.ts +111 -0
- package/dist/search/hybrid-search.d.ts.map +1 -0
- package/dist/search/hybrid-search.js +326 -0
- package/dist/search/index.d.ts +11 -9
- package/dist/search/index.d.ts.map +1 -1
- package/dist/search/index.js +46 -10
- package/dist/search/scoring.d.ts +18 -0
- package/dist/search/scoring.d.ts.map +1 -0
- package/dist/search/{search-utils.js → scoring.js} +14 -27
- package/dist/search/search-api.d.ts +16 -1
- package/dist/search/search-api.d.ts.map +1 -1
- package/dist/search/search-api.js +118 -15
- package/dist/search/search-index.d.ts +2 -2
- package/dist/search/search-index.d.ts.map +1 -1
- package/dist/search/search-index.js +4 -2
- package/dist/search/session-cache.d.ts +4 -10
- package/dist/search/session-cache.d.ts.map +1 -1
- package/dist/search/session-cache.js +12 -45
- package/dist/search/types.d.ts +28 -0
- package/dist/search/types.d.ts.map +1 -1
- package/dist/search/vector-reranker.d.ts +3 -3
- package/dist/search/vector-reranker.d.ts.map +1 -1
- package/dist/search/vector-reranker.js +14 -2
- package/dist/server/chat-handler.d.ts +86 -1
- package/dist/server/chat-handler.d.ts.map +1 -1
- package/dist/server/chat-handler.js +835 -401
- package/dist/server/chat-message-utils.d.ts +6 -0
- package/dist/server/chat-message-utils.d.ts.map +1 -0
- package/dist/server/chat-message-utils.js +40 -0
- package/dist/server/chat-utils.d.ts +30 -0
- package/dist/server/chat-utils.d.ts.map +1 -0
- package/dist/server/chat-utils.js +88 -0
- package/dist/server/dev-server.js +238 -101
- package/dist/server/env-config.d.ts +22 -0
- package/dist/server/env-config.d.ts.map +1 -0
- package/dist/server/env-config.js +25 -0
- package/dist/server/errors.d.ts +1 -0
- package/dist/server/errors.d.ts.map +1 -1
- package/dist/server/errors.js +14 -7
- package/dist/server/index.d.ts +2 -4
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +4 -25
- package/dist/server/metadata-init.d.ts +10 -5
- package/dist/server/metadata-init.d.ts.map +1 -1
- package/dist/server/metadata-init.js +78 -34
- package/dist/server/notify.d.ts +12 -11
- package/dist/server/notify.d.ts.map +1 -1
- package/dist/server/notify.js +46 -48
- package/dist/server/prompt-runtime.d.ts +60 -0
- package/dist/server/prompt-runtime.d.ts.map +1 -0
- package/dist/server/prompt-runtime.js +284 -0
- package/dist/server/stream-helpers.d.ts +30 -16
- package/dist/server/stream-helpers.d.ts.map +1 -1
- package/dist/server/stream-helpers.js +152 -15
- package/dist/server/types.d.ts +47 -12
- package/dist/server/types.d.ts.map +1 -1
- package/dist/structured-output/generator.d.ts +6 -0
- package/dist/structured-output/generator.d.ts.map +1 -0
- package/dist/structured-output/generator.js +164 -0
- package/dist/structured-output/index.d.ts +4 -0
- package/dist/structured-output/index.d.ts.map +1 -0
- package/dist/structured-output/index.js +6 -0
- package/dist/structured-output/schemas/evidence.d.ts +88 -0
- package/dist/structured-output/schemas/evidence.d.ts.map +1 -0
- package/dist/structured-output/schemas/evidence.js +65 -0
- package/dist/structured-output/types.d.ts +69 -0
- package/dist/structured-output/types.d.ts.map +1 -0
- package/dist/structured-output/types.js +0 -0
- package/dist/tools/action-tools.d.ts +63 -0
- package/dist/tools/action-tools.d.ts.map +1 -0
- package/dist/tools/action-tools.js +158 -0
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +30 -0
- package/dist/utils/i18n.d.ts +1 -1
- package/dist/utils/i18n.d.ts.map +1 -1
- package/dist/utils/i18n.js +1 -1
- package/dist/utils/logger.d.ts +11 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +36 -0
- package/dist/utils/text.d.ts +11 -0
- package/dist/utils/text.d.ts.map +1 -0
- package/dist/utils/text.js +87 -0
- package/dist/utils/url.d.ts +19 -0
- package/dist/utils/url.d.ts.map +1 -0
- package/dist/utils/url.js +13 -0
- package/package.json +46 -12
- package/dist/intelligence/intent-detect.d.ts +0 -40
- package/dist/intelligence/intent-detect.d.ts.map +0 -1
- package/dist/intelligence/intent-detect.js +0 -93
- package/dist/providers/index.d.ts +0 -2
- package/dist/providers/index.d.ts.map +0 -1
- package/dist/providers/index.js +0 -5
- package/dist/search/search-utils.d.ts +0 -47
- package/dist/search/search-utils.d.ts.map +0 -1
- package/dist/stream/index.d.ts +0 -3
- package/dist/stream/index.d.ts.map +0 -1
- package/dist/stream/index.js +0 -8
- package/dist/stream/mock-stream.d.ts +0 -12
- package/dist/stream/mock-stream.d.ts.map +0 -1
- package/dist/stream/mock-stream.js +0 -26
- package/dist/stream/response.d.ts +0 -10
- package/dist/stream/response.d.ts.map +0 -1
- package/dist/stream/response.js +0 -21
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { tool } from "ai";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { searchArticles, searchProjects } from "../search/search-api.js";
|
|
4
|
+
const toggleThemeTool = tool({
|
|
5
|
+
description: "Toggle the blog theme between light, dark, and system modes. Use this when the user wants to change the visual theme of the blog.",
|
|
6
|
+
inputSchema: z.object({
|
|
7
|
+
theme: z.enum(["light", "dark", "system"]).describe(
|
|
8
|
+
'The theme to switch to: "light" for bright mode, "dark" for dark mode, "system" to follow system preference'
|
|
9
|
+
)
|
|
10
|
+
})
|
|
11
|
+
});
|
|
12
|
+
const navigateToArticleTool = tool({
|
|
13
|
+
description: "Navigate to a specific blog article by its slug. Use this when the user wants to open or jump to a specific article.",
|
|
14
|
+
inputSchema: z.object({
|
|
15
|
+
slug: z.string().describe(
|
|
16
|
+
'The URL slug of the article to navigate to (e.g., "ai-module-architecture")'
|
|
17
|
+
),
|
|
18
|
+
sectionId: z.string().optional().describe(
|
|
19
|
+
'Optional: The section ID to scroll to after navigation (e.g., "\u4E09\u7CFB\u7EDF\u67B6\u6784\u8BBE\u8BA1")'
|
|
20
|
+
),
|
|
21
|
+
lang: z.enum(["zh", "en"]).optional().describe('Optional: The language of the article (defaults to "zh")')
|
|
22
|
+
})
|
|
23
|
+
});
|
|
24
|
+
const scrollToSectionTool = tool({
|
|
25
|
+
description: "Scroll to a specific section within the current article. Use this when the user wants to jump to a chapter or section.",
|
|
26
|
+
inputSchema: z.object({
|
|
27
|
+
sectionId: z.string().describe(
|
|
28
|
+
'The ID of the section to scroll to (e.g., "\u4E09\u7CFB\u7EDF\u67B6\u6784\u8BBE\u8BA1" or "chapter-3")'
|
|
29
|
+
),
|
|
30
|
+
highlight: z.boolean().optional().describe(
|
|
31
|
+
"Whether to highlight the section after scrolling (default: true)"
|
|
32
|
+
),
|
|
33
|
+
behavior: z.enum(["smooth", "instant"]).optional().describe('Scroll behavior (default: "smooth")')
|
|
34
|
+
})
|
|
35
|
+
});
|
|
36
|
+
const toggleReadingModeTool = tool({
|
|
37
|
+
description: "Toggle reading mode on or off. Reading mode provides a distraction-free reading experience with larger text and optimized layout.",
|
|
38
|
+
inputSchema: z.object({
|
|
39
|
+
enabled: z.boolean().optional().describe(
|
|
40
|
+
"Whether to enable (true) or disable (false) reading mode. If not specified, toggles the current state."
|
|
41
|
+
),
|
|
42
|
+
fontSize: z.enum(["sm", "md", "lg", "xl"]).optional().describe("Font size for reading mode"),
|
|
43
|
+
fontFamily: z.string().optional().describe("Font family for reading mode")
|
|
44
|
+
})
|
|
45
|
+
});
|
|
46
|
+
const highlightTextTool = tool({
|
|
47
|
+
description: "Highlight specific text in the article. Use this when the user wants to emphasize or mark text.",
|
|
48
|
+
inputSchema: z.object({
|
|
49
|
+
text: z.string().optional().describe("The text content to highlight"),
|
|
50
|
+
selector: z.string().optional().describe("CSS selector for the element to highlight"),
|
|
51
|
+
style: z.enum(["accent", "warning", "info", "success"]).optional().describe('Highlight style (default: "accent")'),
|
|
52
|
+
duration: z.number().optional().describe(
|
|
53
|
+
"Duration in milliseconds for the highlight effect (default: 3000, 0 for permanent)"
|
|
54
|
+
),
|
|
55
|
+
scrollIntoView: z.boolean().optional().describe("Whether to scroll the highlighted element into view")
|
|
56
|
+
})
|
|
57
|
+
});
|
|
58
|
+
const setPreferenceTool = tool({
|
|
59
|
+
description: "Set a user preference value. Use this when the user wants to customize their experience.",
|
|
60
|
+
inputSchema: z.object({
|
|
61
|
+
key: z.string().describe('The preference key (e.g., "theme", "reading.fontSize")'),
|
|
62
|
+
value: z.unknown().describe("The value to set")
|
|
63
|
+
})
|
|
64
|
+
});
|
|
65
|
+
const searchArticlesTool = tool({
|
|
66
|
+
description: 'Search for blog articles and projects matching a query. Use this when the user wants to find specific content or when they ask to navigate to a topic (e.g., "AI module", "architecture"). Returns matching articles with titles, URLs, and summaries.',
|
|
67
|
+
inputSchema: z.object({
|
|
68
|
+
query: z.string().describe("The search query (keywords or topic)"),
|
|
69
|
+
limit: z.number().optional().default(5).describe("Maximum number of results to return (default: 5)"),
|
|
70
|
+
includeProjects: z.boolean().optional().default(true).describe("Whether to include projects in search results")
|
|
71
|
+
}),
|
|
72
|
+
execute: async ({
|
|
73
|
+
query,
|
|
74
|
+
limit,
|
|
75
|
+
includeProjects
|
|
76
|
+
}) => {
|
|
77
|
+
const articles = searchArticles(query);
|
|
78
|
+
const projects = includeProjects ? searchProjects(query) : [];
|
|
79
|
+
return {
|
|
80
|
+
articles: articles.slice(0, limit ?? 5).map((a) => ({
|
|
81
|
+
title: a.title,
|
|
82
|
+
url: a.url,
|
|
83
|
+
excerpt: a.summary?.slice(0, 200) ?? "",
|
|
84
|
+
categories: a.categories ?? [],
|
|
85
|
+
tags: [],
|
|
86
|
+
keyPoints: a.keyPoints ?? [],
|
|
87
|
+
dateTime: a.dateTime,
|
|
88
|
+
lang: "zh",
|
|
89
|
+
score: a.score
|
|
90
|
+
})),
|
|
91
|
+
projects: projects.slice(0, 3).map((p) => ({
|
|
92
|
+
name: p.name,
|
|
93
|
+
url: p.url,
|
|
94
|
+
description: p.description?.slice(0, 200) ?? ""
|
|
95
|
+
}))
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
const builtinTools = {
|
|
100
|
+
toggleTheme: toggleThemeTool,
|
|
101
|
+
navigateToArticle: navigateToArticleTool,
|
|
102
|
+
scrollToSection: scrollToSectionTool,
|
|
103
|
+
toggleReadingMode: toggleReadingModeTool,
|
|
104
|
+
highlightText: highlightTextTool,
|
|
105
|
+
setPreference: setPreferenceTool,
|
|
106
|
+
searchArticles: searchArticlesTool
|
|
107
|
+
};
|
|
108
|
+
const customTools = {};
|
|
109
|
+
function registerTool(name, definition) {
|
|
110
|
+
customTools[name] = definition;
|
|
111
|
+
}
|
|
112
|
+
function unregisterTool(name) {
|
|
113
|
+
delete customTools[name];
|
|
114
|
+
}
|
|
115
|
+
function getAllTools() {
|
|
116
|
+
return { ...builtinTools, ...customTools };
|
|
117
|
+
}
|
|
118
|
+
const allTools = builtinTools;
|
|
119
|
+
const BUILTIN_CLIENT_TOOLS = [
|
|
120
|
+
"toggleTheme",
|
|
121
|
+
"navigateToArticle",
|
|
122
|
+
"scrollToSection",
|
|
123
|
+
"toggleReadingMode",
|
|
124
|
+
"highlightText",
|
|
125
|
+
"setPreference"
|
|
126
|
+
];
|
|
127
|
+
const BUILTIN_SERVER_TOOLS = ["searchArticles"];
|
|
128
|
+
function getClientSideTools() {
|
|
129
|
+
return [
|
|
130
|
+
...BUILTIN_CLIENT_TOOLS,
|
|
131
|
+
...Object.keys(customTools).filter(
|
|
132
|
+
(k) => !customTools[k].execute
|
|
133
|
+
)
|
|
134
|
+
];
|
|
135
|
+
}
|
|
136
|
+
function getServerSideTools() {
|
|
137
|
+
return [
|
|
138
|
+
...BUILTIN_SERVER_TOOLS,
|
|
139
|
+
...Object.keys(customTools).filter(
|
|
140
|
+
(k) => !!customTools[k].execute
|
|
141
|
+
)
|
|
142
|
+
];
|
|
143
|
+
}
|
|
144
|
+
export {
|
|
145
|
+
allTools,
|
|
146
|
+
getAllTools,
|
|
147
|
+
getClientSideTools,
|
|
148
|
+
getServerSideTools,
|
|
149
|
+
highlightTextTool,
|
|
150
|
+
navigateToArticleTool,
|
|
151
|
+
registerTool,
|
|
152
|
+
scrollToSectionTool,
|
|
153
|
+
searchArticlesTool,
|
|
154
|
+
setPreferenceTool,
|
|
155
|
+
toggleReadingModeTool,
|
|
156
|
+
toggleThemeTool,
|
|
157
|
+
unregisterTool
|
|
158
|
+
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { allTools, getAllTools, registerTool, unregisterTool, toggleThemeTool, navigateToArticleTool, scrollToSectionTool, toggleReadingModeTool, highlightTextTool, setPreferenceTool, searchArticlesTool, getClientSideTools, getServerSideTools, type ToolName, } from "./action-tools.js";
|
|
2
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,cAAc,EACd,eAAe,EACf,qBAAqB,EACrB,mBAAmB,EACnB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,KAAK,QAAQ,GACd,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
allTools,
|
|
3
|
+
getAllTools,
|
|
4
|
+
registerTool,
|
|
5
|
+
unregisterTool,
|
|
6
|
+
toggleThemeTool,
|
|
7
|
+
navigateToArticleTool,
|
|
8
|
+
scrollToSectionTool,
|
|
9
|
+
toggleReadingModeTool,
|
|
10
|
+
highlightTextTool,
|
|
11
|
+
setPreferenceTool,
|
|
12
|
+
searchArticlesTool,
|
|
13
|
+
getClientSideTools,
|
|
14
|
+
getServerSideTools
|
|
15
|
+
} from "./action-tools.js";
|
|
16
|
+
export {
|
|
17
|
+
allTools,
|
|
18
|
+
getAllTools,
|
|
19
|
+
getClientSideTools,
|
|
20
|
+
getServerSideTools,
|
|
21
|
+
highlightTextTool,
|
|
22
|
+
navigateToArticleTool,
|
|
23
|
+
registerTool,
|
|
24
|
+
scrollToSectionTool,
|
|
25
|
+
searchArticlesTool,
|
|
26
|
+
setPreferenceTool,
|
|
27
|
+
toggleReadingModeTool,
|
|
28
|
+
toggleThemeTool,
|
|
29
|
+
unregisterTool
|
|
30
|
+
};
|
package/dist/utils/i18n.d.ts
CHANGED
|
@@ -14,5 +14,5 @@ export declare function t(key: AITranslationKey, lang?: string, vars?: Record<st
|
|
|
14
14
|
* Get normalized language code.
|
|
15
15
|
* Returns 'zh' for Chinese, 'en' for everything else.
|
|
16
16
|
*/
|
|
17
|
-
export declare function getLang(lang?: string):
|
|
17
|
+
export declare function getLang(lang?: string): "zh" | "en";
|
|
18
18
|
//# sourceMappingURL=i18n.d.ts.map
|
package/dist/utils/i18n.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/utils/i18n.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,gBAAgB,GAExB,uBAAuB,GACvB,4BAA4B,GAC5B,sBAAsB,GAEtB,kBAAkB,GAClB,kBAAkB,GAClB,oBAAoB,GACpB,sBAAsB,GACtB,kBAAkB,GAClB,iBAAiB,GACjB,mBAAmB,GAEnB,gBAAgB,GAChB,UAAU,GACV,sBAAsB,GACtB,UAAU,GACV,cAAc,GACd,UAAU,GACV,qBAAqB,GACrB,sBAAsB,GACtB,iBAAiB,GACjB,oBAAoB,GACpB,oBAAoB,GAEpB,qBAAqB,GACrB,qBAAqB,GACrB,iBAAiB,GACjB,qBAAqB,GACrB,mBAAmB,GACnB,mBAAmB,GAEnB,oBAAoB,GACpB,oBAAoB,GACpB,qBAAqB,GACrB,iBAAiB,GACjB,qBAAqB,GACrB,uBAAuB,GAEvB,mBAAmB,GACnB,gBAAgB,GAEhB,kBAAkB,GAClB,gBAAgB,GAEhB,uBAAuB,GACvB,uBAAuB,GACvB,uBAAuB,GACvB,kBAAkB,GAElB,0BAA0B,GAC1B,8BAA8B,GAC9B,0BAA0B,GAE1B,oCAAoC,GACpC,0BAA0B,GAC1B,8BAA8B,GAC9B,+BAA+B,GAC/B,gCAAgC,GAChC,2BAA2B,GAC3B,+BAA+B,GAC/B,mCAAmC,GAEnC,4BAA4B,GAC5B,0BAA0B,GAC1B,8BAA8B,GAC9B,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/utils/i18n.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,gBAAgB,GAExB,uBAAuB,GACvB,4BAA4B,GAC5B,sBAAsB,GAEtB,kBAAkB,GAClB,kBAAkB,GAClB,oBAAoB,GACpB,sBAAsB,GACtB,kBAAkB,GAClB,iBAAiB,GACjB,mBAAmB,GAEnB,gBAAgB,GAChB,UAAU,GACV,sBAAsB,GACtB,UAAU,GACV,cAAc,GACd,UAAU,GACV,qBAAqB,GACrB,sBAAsB,GACtB,iBAAiB,GACjB,oBAAoB,GACpB,oBAAoB,GAEpB,qBAAqB,GACrB,qBAAqB,GACrB,iBAAiB,GACjB,qBAAqB,GACrB,mBAAmB,GACnB,mBAAmB,GAEnB,oBAAoB,GACpB,oBAAoB,GACpB,qBAAqB,GACrB,iBAAiB,GACjB,qBAAqB,GACrB,uBAAuB,GAEvB,mBAAmB,GACnB,gBAAgB,GAEhB,kBAAkB,GAClB,gBAAgB,GAEhB,uBAAuB,GACvB,uBAAuB,GACvB,uBAAuB,GACvB,kBAAkB,GAElB,0BAA0B,GAC1B,8BAA8B,GAC9B,0BAA0B,GAE1B,oCAAoC,GACpC,0BAA0B,GAC1B,8BAA8B,GAC9B,+BAA+B,GAC/B,gCAAgC,GAChC,2BAA2B,GAC3B,+BAA+B,GAC/B,mCAAmC,GAEnC,4BAA4B,GAC5B,0BAA0B,GAC1B,8BAA8B,GAC9B,8BAA8B,CAAC;AAyJnC;;;;;GAKG;AACH,wBAAgB,CAAC,CACf,GAAG,EAAE,gBAAgB,EACrB,IAAI,GAAE,MAAa,EACnB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,GACrC,MAAM,CAYR;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAElD"}
|
package/dist/utils/i18n.js
CHANGED
|
@@ -136,7 +136,7 @@ Ask me to summarize, explain a concept, or explore related topics.`,
|
|
|
136
136
|
}
|
|
137
137
|
};
|
|
138
138
|
function t(key, lang = "zh", vars) {
|
|
139
|
-
const l = lang
|
|
139
|
+
const l = getLang(lang);
|
|
140
140
|
let text = translations[l]?.[key] ?? translations["en"][key] ?? key;
|
|
141
141
|
if (vars) {
|
|
142
142
|
for (const [k, v] of Object.entries(vars)) {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent';
|
|
2
|
+
export interface Logger {
|
|
3
|
+
debug(message: string, ...args: unknown[]): void;
|
|
4
|
+
info(message: string, ...args: unknown[]): void;
|
|
5
|
+
warn(message: string, ...args: unknown[]): void;
|
|
6
|
+
error(message: string, ...args: unknown[]): void;
|
|
7
|
+
}
|
|
8
|
+
export declare function setLogLevel(level: LogLevel): void;
|
|
9
|
+
export declare function getLogLevel(): LogLevel;
|
|
10
|
+
export declare function createLogger(namespace: string): Logger;
|
|
11
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEtE,MAAM,WAAW,MAAM;IACrB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IACjD,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAChD,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAChD,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;CAClD;AAYD,wBAAgB,WAAW,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAEjD;AAED,wBAAgB,WAAW,IAAI,QAAQ,CAEtC;AAED,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAiBtD"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const LOG_LEVELS = {
|
|
2
|
+
debug: 0,
|
|
3
|
+
info: 1,
|
|
4
|
+
warn: 2,
|
|
5
|
+
error: 3,
|
|
6
|
+
silent: 4
|
|
7
|
+
};
|
|
8
|
+
let globalLevel = "warn";
|
|
9
|
+
function setLogLevel(level) {
|
|
10
|
+
globalLevel = level;
|
|
11
|
+
}
|
|
12
|
+
function getLogLevel() {
|
|
13
|
+
return globalLevel;
|
|
14
|
+
}
|
|
15
|
+
function createLogger(namespace) {
|
|
16
|
+
const prefix = `[${namespace}]`;
|
|
17
|
+
return {
|
|
18
|
+
debug(message, ...args) {
|
|
19
|
+
if (LOG_LEVELS[globalLevel] <= LOG_LEVELS.debug) console.debug(prefix, message, ...args);
|
|
20
|
+
},
|
|
21
|
+
info(message, ...args) {
|
|
22
|
+
if (LOG_LEVELS[globalLevel] <= LOG_LEVELS.info) console.log(prefix, message, ...args);
|
|
23
|
+
},
|
|
24
|
+
warn(message, ...args) {
|
|
25
|
+
if (LOG_LEVELS[globalLevel] <= LOG_LEVELS.warn) console.warn(prefix, message, ...args);
|
|
26
|
+
},
|
|
27
|
+
error(message, ...args) {
|
|
28
|
+
if (LOG_LEVELS[globalLevel] <= LOG_LEVELS.error) console.error(prefix, message, ...args);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export {
|
|
33
|
+
createLogger,
|
|
34
|
+
getLogLevel,
|
|
35
|
+
setLogLevel
|
|
36
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text normalization and tokenization utilities.
|
|
3
|
+
* Shared between search, intelligence, and other modules.
|
|
4
|
+
*/
|
|
5
|
+
export declare function normalizeText(text: string): string;
|
|
6
|
+
export declare function tokenize(text: string): string[];
|
|
7
|
+
export declare function dedupeByContainment(terms: string[]): string[];
|
|
8
|
+
export declare function extractCodeAnchors(text: string): string[];
|
|
9
|
+
export declare function hasCodeAnchors(text: string): boolean;
|
|
10
|
+
export declare function normalizeCodeBlockLang(lang?: string): string;
|
|
11
|
+
//# sourceMappingURL=text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/utils/text.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMlD;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAK/C;AA+BD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAS7D;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAqBzD;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEpD;AAcD,wBAAgB,sBAAsB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAI5D"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
function normalizeText(text) {
|
|
2
|
+
return text.toLowerCase().replace(/[^\u4e00-\u9fa5\w\s]/g, " ").replace(/\s+/g, " ").trim();
|
|
3
|
+
}
|
|
4
|
+
function tokenize(text) {
|
|
5
|
+
const normalized = normalizeText(text);
|
|
6
|
+
const parts = normalized.split(/\s+/).filter(Boolean);
|
|
7
|
+
const expanded = parts.flatMap((part) => expandToken(part));
|
|
8
|
+
return dedupeByContainment(expanded);
|
|
9
|
+
}
|
|
10
|
+
function expandToken(token) {
|
|
11
|
+
if (!token) return [];
|
|
12
|
+
if (/^[\u4e00-\u9fa5]+$/.test(token)) {
|
|
13
|
+
return buildCjkTokenVariants(token);
|
|
14
|
+
}
|
|
15
|
+
return [token];
|
|
16
|
+
}
|
|
17
|
+
function buildCjkTokenVariants(text) {
|
|
18
|
+
const chars = [...text].filter((char) => /[\u4e00-\u9fa5]/.test(char));
|
|
19
|
+
if (chars.length <= 1) return chars;
|
|
20
|
+
const variants = /* @__PURE__ */ new Set();
|
|
21
|
+
for (const char of chars) {
|
|
22
|
+
variants.add(char);
|
|
23
|
+
}
|
|
24
|
+
for (let size = 2; size <= Math.min(4, chars.length); size++) {
|
|
25
|
+
for (let i = 0; i <= chars.length - size; i++) {
|
|
26
|
+
variants.add(chars.slice(i, i + size).join(""));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
variants.add(chars.join(""));
|
|
30
|
+
return [...variants];
|
|
31
|
+
}
|
|
32
|
+
function dedupeByContainment(terms) {
|
|
33
|
+
const unique = [...new Set(terms)];
|
|
34
|
+
const kept = [];
|
|
35
|
+
for (const term of unique.sort((a, b) => b.length - a.length)) {
|
|
36
|
+
if (!kept.some((existing) => existing.includes(term))) {
|
|
37
|
+
kept.push(term);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return kept;
|
|
41
|
+
}
|
|
42
|
+
function extractCodeAnchors(text) {
|
|
43
|
+
if (!text.trim()) return [];
|
|
44
|
+
const anchors = /* @__PURE__ */ new Set();
|
|
45
|
+
const patterns = [
|
|
46
|
+
/`([^`]{2,})`/g,
|
|
47
|
+
/\b[a-z]+[A-Z][A-Za-z0-9]*\b/g,
|
|
48
|
+
/\buse[A-Z][A-Za-z0-9]*\b/g,
|
|
49
|
+
/\b[a-zA-Z_][\w-]*\.(?:ts|tsx|js|jsx|astro|md|json)\b/g,
|
|
50
|
+
/\b[a-zA-Z_][A-Za-z0-9_]*\(/g
|
|
51
|
+
];
|
|
52
|
+
for (const pattern of patterns) {
|
|
53
|
+
for (const match of text.matchAll(pattern)) {
|
|
54
|
+
const rawValue = (match[1] ?? match[0] ?? "").trim();
|
|
55
|
+
const value = rawValue.endsWith("(") ? rawValue.slice(0, -1) : rawValue;
|
|
56
|
+
if (value.length >= 2) anchors.add(value);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return [...anchors].sort((a, b) => b.length - a.length);
|
|
60
|
+
}
|
|
61
|
+
function hasCodeAnchors(text) {
|
|
62
|
+
return extractCodeAnchors(text).length > 0;
|
|
63
|
+
}
|
|
64
|
+
const CODE_BLOCK_LANG_ALIASES = {
|
|
65
|
+
js: "javascript",
|
|
66
|
+
ts: "typescript",
|
|
67
|
+
py: "python",
|
|
68
|
+
rb: "ruby",
|
|
69
|
+
sh: "bash",
|
|
70
|
+
shell: "bash",
|
|
71
|
+
yml: "yaml",
|
|
72
|
+
md: "markdown",
|
|
73
|
+
text: "plaintext"
|
|
74
|
+
};
|
|
75
|
+
function normalizeCodeBlockLang(lang) {
|
|
76
|
+
if (!lang) return "plaintext";
|
|
77
|
+
const lower = lang.toLowerCase();
|
|
78
|
+
return CODE_BLOCK_LANG_ALIASES[lower] || lower;
|
|
79
|
+
}
|
|
80
|
+
export {
|
|
81
|
+
dedupeByContainment,
|
|
82
|
+
extractCodeAnchors,
|
|
83
|
+
hasCodeAnchors,
|
|
84
|
+
normalizeCodeBlockLang,
|
|
85
|
+
normalizeText,
|
|
86
|
+
tokenize
|
|
87
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* URL utilities for safe URL construction.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Safely joins a base URL with a path, preventing double slashes.
|
|
6
|
+
*
|
|
7
|
+
* @param baseUrl - The base URL (e.g., "https://example.com" or "https://example.com/")
|
|
8
|
+
* @param path - The path to append (e.g., "/posts/article" or "posts/article")
|
|
9
|
+
* @returns The joined URL without double slashes
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* safeJoinUrl("https://example.com/", "/posts/article") // "https://example.com/posts/article"
|
|
13
|
+
* safeJoinUrl("https://example.com", "posts/article") // "https://example.com/posts/article"
|
|
14
|
+
* safeJoinUrl("https://example.com", "/posts/article") // "https://example.com/posts/article"
|
|
15
|
+
* safeJoinUrl("", "/posts/article") // "/posts/article"
|
|
16
|
+
* safeJoinUrl("https://example.com/", "") // "https://example.com"
|
|
17
|
+
*/
|
|
18
|
+
export declare function safeJoinUrl(baseUrl: string, path: string): string;
|
|
19
|
+
//# sourceMappingURL=url.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../src/utils/url.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAmBjE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
function safeJoinUrl(baseUrl, path) {
|
|
2
|
+
if (!baseUrl) return path;
|
|
3
|
+
if (!path) return baseUrl.replace(/\/+$/, "");
|
|
4
|
+
if (path.startsWith("http://") || path.startsWith("https://")) {
|
|
5
|
+
return path;
|
|
6
|
+
}
|
|
7
|
+
const cleanBase = baseUrl.replace(/\/+$/, "");
|
|
8
|
+
const cleanPath = path.startsWith("/") ? path : `/${path}`;
|
|
9
|
+
return `${cleanBase}${cleanPath}`;
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
safeJoinUrl
|
|
13
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astro-minimax/ai",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Vendor-agnostic AI integration package with full RAG pipeline for astro-minimax blogs — supports OpenAI, Cloudflare AI, and custom providers.",
|
|
6
6
|
"author": "Souloss",
|
|
@@ -33,14 +33,14 @@
|
|
|
33
33
|
"types": "./dist/index.d.ts",
|
|
34
34
|
"import": "./dist/index.js"
|
|
35
35
|
},
|
|
36
|
-
"./providers": {
|
|
37
|
-
"types": "./dist/providers/index.d.ts",
|
|
38
|
-
"import": "./dist/providers/index.js"
|
|
39
|
-
},
|
|
40
36
|
"./middleware": {
|
|
41
37
|
"types": "./dist/middleware/index.d.ts",
|
|
42
38
|
"import": "./dist/middleware/index.js"
|
|
43
39
|
},
|
|
40
|
+
"./cache": {
|
|
41
|
+
"types": "./dist/cache/index.d.ts",
|
|
42
|
+
"import": "./dist/cache/index.js"
|
|
43
|
+
},
|
|
44
44
|
"./search": {
|
|
45
45
|
"types": "./dist/search/index.d.ts",
|
|
46
46
|
"import": "./dist/search/index.js"
|
|
@@ -61,14 +61,22 @@
|
|
|
61
61
|
"types": "./dist/fact-registry/index.d.ts",
|
|
62
62
|
"import": "./dist/fact-registry/index.js"
|
|
63
63
|
},
|
|
64
|
-
"./stream": {
|
|
65
|
-
"types": "./dist/stream/index.d.ts",
|
|
66
|
-
"import": "./dist/stream/index.js"
|
|
67
|
-
},
|
|
68
64
|
"./server": {
|
|
69
65
|
"types": "./dist/server/index.d.ts",
|
|
70
66
|
"import": "./dist/server/index.js"
|
|
71
67
|
},
|
|
68
|
+
"./extensions": {
|
|
69
|
+
"types": "./dist/extensions/index.d.ts",
|
|
70
|
+
"import": "./dist/extensions/index.js"
|
|
71
|
+
},
|
|
72
|
+
"./structured-output": {
|
|
73
|
+
"types": "./dist/structured-output/index.d.ts",
|
|
74
|
+
"import": "./dist/structured-output/index.js"
|
|
75
|
+
},
|
|
76
|
+
"./tools": {
|
|
77
|
+
"types": "./dist/tools/index.d.ts",
|
|
78
|
+
"import": "./dist/tools/index.js"
|
|
79
|
+
},
|
|
72
80
|
"./components/ChatPanel": {
|
|
73
81
|
"types": "./dist/components/ChatPanel.d.ts",
|
|
74
82
|
"import": "./dist/components/ChatPanel.js"
|
|
@@ -91,7 +99,8 @@
|
|
|
91
99
|
"@ai-sdk/openai-compatible": "^2.0.35",
|
|
92
100
|
"ai": "^6.0.116",
|
|
93
101
|
"workers-ai-provider": "^3.1.2",
|
|
94
|
-
"
|
|
102
|
+
"zod": "^4.3.6",
|
|
103
|
+
"@astro-minimax/knowledge-model": "0.9.3"
|
|
95
104
|
},
|
|
96
105
|
"optionalDependencies": {
|
|
97
106
|
"undici": "^6.0.0"
|
|
@@ -99,7 +108,12 @@
|
|
|
99
108
|
"peerDependencies": {
|
|
100
109
|
"@ai-sdk/react": "^3.0.0",
|
|
101
110
|
"@cloudflare/workers-types": "^4.0.0",
|
|
102
|
-
"preact": "^10.0.0"
|
|
111
|
+
"preact": "^10.0.0",
|
|
112
|
+
"shiki": "^1.0.0 || ^2.0.0",
|
|
113
|
+
"mermaid": "^11.0.0",
|
|
114
|
+
"markmap-lib": "^0.18.0",
|
|
115
|
+
"markmap-view": "^0.18.0",
|
|
116
|
+
"@astro-minimax/notify": "0.9.3"
|
|
103
117
|
},
|
|
104
118
|
"peerDependenciesMeta": {
|
|
105
119
|
"@ai-sdk/react": {
|
|
@@ -107,13 +121,30 @@
|
|
|
107
121
|
},
|
|
108
122
|
"preact": {
|
|
109
123
|
"optional": true
|
|
124
|
+
},
|
|
125
|
+
"shiki": {
|
|
126
|
+
"optional": true
|
|
127
|
+
},
|
|
128
|
+
"mermaid": {
|
|
129
|
+
"optional": true
|
|
130
|
+
},
|
|
131
|
+
"markmap-lib": {
|
|
132
|
+
"optional": true
|
|
133
|
+
},
|
|
134
|
+
"markmap-view": {
|
|
135
|
+
"optional": true
|
|
136
|
+
},
|
|
137
|
+
"@astro-minimax/notify": {
|
|
138
|
+
"optional": true
|
|
110
139
|
}
|
|
111
140
|
},
|
|
112
141
|
"devDependencies": {
|
|
113
142
|
"@cloudflare/workers-types": "^4.0.0",
|
|
114
143
|
"@types/node": "^22.0.0",
|
|
144
|
+
"@vitest/coverage-v8": "^3.0.0",
|
|
115
145
|
"esbuild": "^0.25.0",
|
|
116
|
-
"typescript": "^5.9.3"
|
|
146
|
+
"typescript": "^5.9.3",
|
|
147
|
+
"vitest": "^3.0.0"
|
|
117
148
|
},
|
|
118
149
|
"engines": {
|
|
119
150
|
"node": ">=22.12.0",
|
|
@@ -124,6 +155,9 @@
|
|
|
124
155
|
"build:watch": "node scripts/build.mjs --watch",
|
|
125
156
|
"build:components": "node scripts/build-components.mjs",
|
|
126
157
|
"typecheck": "tsc --noEmit",
|
|
158
|
+
"test": "vitest run",
|
|
159
|
+
"test:watch": "vitest",
|
|
160
|
+
"test:coverage": "vitest run --coverage",
|
|
127
161
|
"clean": "rm -rf dist"
|
|
128
162
|
}
|
|
129
163
|
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { CachedSearchContext, ArticleContext } from '../search/types.js';
|
|
2
|
-
export type IntentCategory = 'setup' | 'config' | 'content' | 'feature' | 'deployment' | 'troubleshooting' | 'general';
|
|
3
|
-
/**
|
|
4
|
-
* Classifies the user query into an intent category.
|
|
5
|
-
* Used to adjust search relevance scoring.
|
|
6
|
-
*/
|
|
7
|
-
export declare function classifyIntent(query: string): IntentCategory;
|
|
8
|
-
/**
|
|
9
|
-
* Re-ranks articles by intent relevance with weighted multi-dimension scoring.
|
|
10
|
-
* Scoring: title(+3) / categories(+2) / summary(+2) / keyPoints(+1) / recency(+1)
|
|
11
|
-
*/
|
|
12
|
-
export declare function rankArticlesByIntent(query: string, articles: ArticleContext[]): ArticleContext[];
|
|
13
|
-
/**
|
|
14
|
-
* Determines if the latest message is likely a follow-up to the previous context.
|
|
15
|
-
* Uses heuristics: message length, punctuation, word count.
|
|
16
|
-
*/
|
|
17
|
-
export declare function isLikelyFollowUp(message: string): boolean;
|
|
18
|
-
/**
|
|
19
|
-
* Checks whether the current query contains significant new tokens
|
|
20
|
-
* that aren't present in the cached query.
|
|
21
|
-
*/
|
|
22
|
-
export declare function hasNewSignificantTokens(currentQuery: string, cachedQuery: string): boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Checks whether the current query overlaps significantly with the cached query.
|
|
25
|
-
*/
|
|
26
|
-
export declare function hasQueryOverlap(currentQuery: string, cachedQuery: string): boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Determines whether to reuse the cached search context for this request.
|
|
29
|
-
*/
|
|
30
|
-
export declare function shouldReuseSearchContext(params: {
|
|
31
|
-
latestText: string;
|
|
32
|
-
cachedContext: CachedSearchContext | undefined;
|
|
33
|
-
userTurnCount: number;
|
|
34
|
-
now: number;
|
|
35
|
-
}): boolean;
|
|
36
|
-
/**
|
|
37
|
-
* Builds a normalized local search query from the latest message.
|
|
38
|
-
*/
|
|
39
|
-
export declare function buildLocalSearchQuery(latestText: string): string;
|
|
40
|
-
//# sourceMappingURL=intent-detect.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"intent-detect.d.ts","sourceRoot":"","sources":["../../src/intelligence/intent-detect.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAO9E,MAAM,MAAM,cAAc,GACtB,OAAO,GACP,QAAQ,GACR,SAAS,GACT,SAAS,GACT,YAAY,GACZ,iBAAiB,GACjB,SAAS,CAAC;AAYd;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,CAY5D;AAiBD;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,cAAc,EAAE,GACzB,cAAc,EAAE,CAsBlB;AAID;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAUzD;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAK1F;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAKlF;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE;IAC/C,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,mBAAmB,GAAG,SAAS,CAAC;IAC/C,aAAa,EAAE,MAAM,CAAC;IACtB,GAAG,EAAE,MAAM,CAAC;CACb,GAAG,OAAO,CASV;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEhE"}
|