@lota-sdk/core 0.4.12 → 0.4.13
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lota-sdk/core",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@ai-sdk/openai": "^3.0.53",
|
|
32
32
|
"@chat-adapter/slack": "^4.26.0",
|
|
33
33
|
"@chat-adapter/state-ioredis": "^4.26.0",
|
|
34
|
-
"@lota-sdk/shared": "0.4.
|
|
34
|
+
"@lota-sdk/shared": "0.4.13",
|
|
35
35
|
"@mendable/firecrawl-js": "^4.18.3",
|
|
36
36
|
"@surrealdb/node": "^3.0.3",
|
|
37
37
|
"ai": "^6.0.168",
|
|
@@ -56,30 +56,6 @@ function readHeadingTitle(line: string): string | null {
|
|
|
56
56
|
return null
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
function readLeadLineTitle(line: string): string | null {
|
|
60
|
-
const trimmed = stripMarkdownTitleDecorators(line)
|
|
61
|
-
if (!trimmed) return null
|
|
62
|
-
if (trimmed.length > 90) return null
|
|
63
|
-
if (/[.!?]$/.test(trimmed)) return null
|
|
64
|
-
return trimmed
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function readFirstCompleteSentence(chunk: string): string | null {
|
|
68
|
-
const compact = normalizeWhitespace(chunk)
|
|
69
|
-
if (!compact) return null
|
|
70
|
-
const sentenceMatch = compact.match(/^(.+?[.!?])(?:\s|$)/)
|
|
71
|
-
if (sentenceMatch?.[1]) {
|
|
72
|
-
return sentenceMatch[1]
|
|
73
|
-
}
|
|
74
|
-
return null
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function isStableReasoningChunk(chunk: string, isLastChunk: boolean, isFinal: boolean): boolean {
|
|
78
|
-
if (!isLastChunk || isFinal) return true
|
|
79
|
-
if (chunk.includes('\n')) return true
|
|
80
|
-
return /[.!?:]\s*$/.test(chunk.trim())
|
|
81
|
-
}
|
|
82
|
-
|
|
83
59
|
export function extractThinkingTitlesFromReasoning(params: { text: string; isFinal?: boolean }): string[] {
|
|
84
60
|
const cleaned = sanitizeReasoningText(params.text).trim()
|
|
85
61
|
if (cleaned.length === 0) return []
|
|
@@ -91,35 +67,16 @@ export function extractThinkingTitlesFromReasoning(params: { text: string; isFin
|
|
|
91
67
|
|
|
92
68
|
const titles: string[] = []
|
|
93
69
|
|
|
94
|
-
for (const
|
|
95
|
-
const
|
|
96
|
-
if (!isStableReasoningChunk(chunk, isLastChunk, params.isFinal === true)) {
|
|
97
|
-
continue
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const lines = chunk
|
|
70
|
+
for (const chunk of chunks) {
|
|
71
|
+
const firstLine = chunk
|
|
101
72
|
.split('\n')
|
|
102
|
-
.
|
|
103
|
-
|
|
104
|
-
if (
|
|
73
|
+
.find((line) => line.trim().length > 0)
|
|
74
|
+
?.trim()
|
|
75
|
+
if (!firstLine) continue
|
|
105
76
|
|
|
106
|
-
const headingTitle = readHeadingTitle(
|
|
77
|
+
const headingTitle = readHeadingTitle(firstLine)
|
|
107
78
|
if (headingTitle) {
|
|
108
79
|
titles.push(normalizeThinkingTitle(headingTitle))
|
|
109
|
-
continue
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (lines.length > 1 || params.isFinal === true) {
|
|
113
|
-
const leadLineTitle = readLeadLineTitle(lines[0])
|
|
114
|
-
if (leadLineTitle) {
|
|
115
|
-
titles.push(normalizeThinkingTitle(leadLineTitle))
|
|
116
|
-
continue
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
const sentenceTitle = readFirstCompleteSentence(chunk)
|
|
121
|
-
if (sentenceTitle) {
|
|
122
|
-
titles.push(normalizeThinkingTitle(sentenceTitle))
|
|
123
80
|
}
|
|
124
81
|
}
|
|
125
82
|
|