kiku-agent 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/README.md +459 -407
  2. package/package.json +27 -3
  3. package/server/agent/agentCore.js +635 -267
  4. package/server/agent/appPaths.js +2 -0
  5. package/server/agent/catalogEntityResolver.js +629 -0
  6. package/server/agent/citations.js +0 -21
  7. package/server/agent/clarificationAnalytics.js +1 -1
  8. package/server/agent/clarifyingQuestions.js +286 -216
  9. package/server/agent/cli.js +528 -73
  10. package/server/agent/commandFeatures.js +123 -24
  11. package/server/agent/commandRegistry.js +128 -62
  12. package/server/agent/commands.js +1410 -95
  13. package/server/agent/config.js +253 -163
  14. package/server/agent/contextCompactor.js +239 -25
  15. package/server/agent/dynamicCatalog.js +192 -0
  16. package/server/agent/envBootstrap.js +46 -0
  17. package/server/agent/envManager.js +317 -0
  18. package/server/agent/eventBus.js +3 -3
  19. package/server/agent/feedbackLearning.js +0 -8
  20. package/server/agent/gpuMetrics.js +188 -55
  21. package/server/agent/ingestionWorker.js +339 -0
  22. package/server/agent/lanDiscovery.js +369 -0
  23. package/server/agent/llmClient.js +111 -39
  24. package/server/agent/lmStudioWakeup.js +144 -0
  25. package/server/agent/mcpClient.js +2 -2
  26. package/server/agent/memory.js +635 -494
  27. package/server/agent/modelConfig.js +487 -0
  28. package/server/agent/newsIntelligence.js +219 -0
  29. package/server/agent/newsWatch.js +85 -0
  30. package/server/agent/prompts.js +146 -0
  31. package/server/agent/publicTools.js +7 -0
  32. package/server/agent/queryDetails.js +62 -1
  33. package/server/agent/research.js +314 -35
  34. package/server/agent/routingInterceptor.js +77 -0
  35. package/server/agent/rumoredProjects.js +15 -0
  36. package/server/agent/sanitizer.js +117 -17
  37. package/server/agent/subagent.js +52 -9
  38. package/server/agent/suggestionTui.js +33 -13
  39. package/server/agent/suggestions.js +29 -13
  40. package/server/agent/telemetry.js +0 -11
  41. package/server/agent/terminalImage.js +0 -1
  42. package/server/agent/textToolProtocol.js +190 -0
  43. package/server/agent/tokenTracker.js +220 -0
  44. package/server/agent/toolRouter.js +362 -216
  45. package/server/agent/tools.js +1155 -194
  46. package/server/agent/ui.js +144 -41
  47. package/server/agent/vramService.js +572 -0
  48. package/server/agent/webSearch.js +2279 -273
  49. package/server/agent/youtubeAuth.js +82 -73
  50. package/server/agent/youtubeTranscript.js +209 -0
  51. package/server/apiRouter.js +383 -179
  52. package/server/mcp/data/brands.js +5 -5
  53. package/server/mcp/data/discography.js +56 -45
  54. package/server/mcp/data/gallery.js +9 -0
  55. package/server/mcp/data/index.js +1 -0
  56. package/server/mcp/data/industryIndex.js +251 -0
  57. package/server/mcp/data/profile.js +5 -5
  58. package/server/mcp/data/timeline.js +2 -2
  59. package/server/mcp/data/works.js +2 -2
  60. package/server/mcp/handler.js +0 -2
  61. package/server/mcp/prompts.js +42 -2
  62. package/server/mcp/resources.js +5 -1
  63. package/server/mcp/security.js +25 -14
  64. package/server/mcp/server.js +92 -3
  65. package/server/mcp/tools.js +20 -11
  66. package/server/web-chat/core/connection.js +218 -194
  67. package/server/web-chat/core/conversationContext.js +1 -1
  68. package/server/web-chat/core/directCatalogEngine.js +190 -184
  69. package/server/web-chat/core/followUpEngine.js +88 -11
  70. package/server/web-chat/core/security.js +7 -4
  71. package/server/web-chat/router.js +54 -17
  72. package/server/web-chat/routes/bilibiliRoute.js +34 -0
  73. package/server/web-chat/routes/chatRoute.js +488 -397
  74. package/server/web-chat/routes/clarifyConfigRoute.js +1 -2
  75. package/server/web-chat/routes/exportRoute.js +2 -1
  76. package/server/web-chat/routes/lanDiscoveryRoute.js +90 -0
  77. package/server/web-chat/routes/newsRoute.js +36 -6
  78. package/server/web-chat/routes/providerRoute.js +87 -0
  79. package/server/web-chat/routes/staticRoute.js +61 -13
  80. package/server/web-chat/routes/statusRoute.js +23 -2
  81. package/server/web-chat/routes/vramRoute.js +22 -0
  82. package/server/web-chat/server.js +135 -106
  83. package/server/web-chat/ui/htmlBuilder.js +8 -8
  84. package/server/web-chat/ui/previews/modelSettings.preview.html +41 -0
  85. package/server/web-chat/ui/scripts/agentBubbleSystem.js +0 -5
  86. package/server/web-chat/ui/scripts/client.js +10526 -8397
  87. package/server/web-chat/ui/scripts/webchatI18n.js +190 -138
  88. package/server/web-chat/ui/styles/main.css +7471 -4246
  89. package/server/web-chat/ui/templates/body.html +305 -179
  90. package/src/data/brandsData.js +29 -6
  91. package/src/data/discographyData.js +918 -900
  92. package/src/data/galleryData.js +66 -0
  93. package/src/data/industryIndexData.js +292 -0
  94. package/src/data/musicVideoData.js +48 -5
  95. package/src/data/profileData.js +15 -1
  96. package/src/data/timelineData.js +4 -3
  97. package/src/data/worksData.js +536 -535
  98. package/src/lib/vram/estimator.js +464 -0
  99. package/src/lib/vram/modelRegistry.js +387 -0
  100. package/tokens.css +33 -2
@@ -3,7 +3,6 @@ function normalizeForMatch(str) {
3
3
  return str.toLowerCase().replace(/[\s\-_'"《》〈〉「」『』()()\[\]【】]/g, '');
4
4
  }
5
5
 
6
-
7
6
  export function extractCitations(answerText = '', recordedTools = []) {
8
7
  if (!Array.isArray(recordedTools) || recordedTools.length === 0) {
9
8
  return [];
@@ -31,7 +30,6 @@ export function extractCitations(answerText = '', recordedTools = []) {
31
30
  const titleEn = item.titleEn || '';
32
31
  const year = item.year || item.releaseYear || '';
33
32
 
34
-
35
33
  const isMentioned = !normAnswer ||
36
34
  (titleTh && normAnswer.includes(normalizeForMatch(titleTh))) ||
37
35
  (titleCn && normAnswer.includes(normalizeForMatch(titleCn))) ||
@@ -56,7 +54,6 @@ export function extractCitations(answerText = '', recordedTools = []) {
56
54
  }
57
55
  }
58
56
 
59
-
60
57
  if ((toolName === 'search_discography' || toolName === 'get_song_detail') && Array.isArray(res.songs || res.results)) {
61
58
  const list = res.songs || res.results;
62
59
  for (const item of list) {
@@ -186,7 +183,6 @@ export function extractCitations(answerText = '', recordedTools = []) {
186
183
  }
187
184
  }
188
185
 
189
-
190
186
  if (toolName === 'web_search' && Array.isArray(res.results)) {
191
187
  for (const r of res.results) {
192
188
  if (!r || !r.title) continue;
@@ -209,20 +205,12 @@ export function extractCitations(answerText = '', recordedTools = []) {
209
205
  }
210
206
  }
211
207
 
212
-
213
208
  return candidateCitations.slice(0, 8).map((cit, idx) => ({
214
209
  ...cit,
215
210
  id: idx + 1,
216
211
  }));
217
212
  }
218
213
 
219
- /**
220
- * Formats citations as a clean markdown/terminal reference list.
221
- *
222
- * @param {Array<Object>} citations
223
- * @param {Object} [options]
224
- * @returns {string}
225
- */
226
214
  export function formatCitationsBlock(citations = [], { lang = 'th', plain = false } = {}) {
227
215
  if (!Array.isArray(citations) || citations.length === 0) return '';
228
216
 
@@ -242,14 +230,6 @@ export function formatCitationsBlock(citations = [], { lang = 'th', plain = fals
242
230
  return `${header}\n${items.join('\n')}`;
243
231
  }
244
232
 
245
- /**
246
- * Resolves a citation reference like "[1]", "1", or an entity substring
247
- * to the cited item from a previous conversation turn.
248
- *
249
- * @param {string} query - The user's query or reference string
250
- * @param {Array<Object>} citations - Array of citation objects
251
- * @returns {Object|null}
252
- */
253
233
  export function resolveCitationReference(query = '', citations = []) {
254
234
  if (!query || !Array.isArray(citations) || citations.length === 0) return null;
255
235
 
@@ -262,7 +242,6 @@ export function resolveCitationReference(query = '', citations = []) {
262
242
  return citations.find(c => c.id === targetId) || null;
263
243
  }
264
244
 
265
-
266
245
  const normQuery = normalizeForMatch(trimmed);
267
246
  if (normQuery.length >= 2) {
268
247
  for (const c of citations) {
@@ -8,7 +8,7 @@ const DEFAULT_CONFIG = {
8
8
  confidenceThreshold: 0.65,
9
9
  maxRounds: 2,
10
10
  timeoutMs: 30000,
11
- preferLLMQuestions: false,
11
+ preferLLMQuestions: true,
12
12
  trackedCategories: [
13
13
  'timeframe', 'scope', 'depth', 'comparison', 'media_type',
14
14
  'language', 'specific_work', 'aspect_focus', 'date_range', 'content_format'