@lota-sdk/core 0.1.40 → 0.1.42
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.1.
|
|
3
|
+
"version": "0.1.42",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@chat-adapter/slack": "^4.23.0",
|
|
33
33
|
"@chat-adapter/state-ioredis": "^4.23.0",
|
|
34
34
|
"@logtape/logtape": "^2.0.5",
|
|
35
|
-
"@lota-sdk/shared": "0.1.
|
|
35
|
+
"@lota-sdk/shared": "0.1.42",
|
|
36
36
|
"@mendable/firecrawl-js": "^4.18.0",
|
|
37
37
|
"@surrealdb/node": "^3.0.3",
|
|
38
38
|
"ai": "^6.0.141",
|
|
@@ -4,11 +4,7 @@ import { z } from 'zod'
|
|
|
4
4
|
import { aiGatewayChatModel } from '../ai-gateway/ai-gateway'
|
|
5
5
|
import { buildAiGatewayDirectCacheHeaders } from '../ai-gateway/cache-headers'
|
|
6
6
|
import { agentDescriptions, agentDisplayNames, routerModelId } from '../config/agent-defaults'
|
|
7
|
-
import {
|
|
8
|
-
OPENROUTER_FAST_REASONING_MODEL_ID,
|
|
9
|
-
OPENROUTER_XHIGH_REASONING_PROVIDER_OPTIONS,
|
|
10
|
-
OPENROUTER_HIGH_REASONING_PROVIDER_OPTIONS,
|
|
11
|
-
} from '../config/model-constants'
|
|
7
|
+
import { OPENROUTER_FAST_REASONING_MODEL_ID } from '../config/model-constants'
|
|
12
8
|
|
|
13
9
|
// ---------------------------------------------------------------------------
|
|
14
10
|
// Schemas
|
|
@@ -79,14 +75,10 @@ Format: {"done":true} or {"done":false,"agentId":"<id>","routingContext":"<1-sen
|
|
|
79
75
|
|
|
80
76
|
function createRouterAgent(systemPrompt: string) {
|
|
81
77
|
const modelId = routerModelId ?? OPENROUTER_FAST_REASONING_MODEL_ID
|
|
78
|
+
// Router needs plain JSON output, not reasoning tokens
|
|
82
79
|
const providerOptions = routerModelId
|
|
83
|
-
? {
|
|
84
|
-
|
|
85
|
-
...OPENROUTER_XHIGH_REASONING_PROVIDER_OPTIONS.openai,
|
|
86
|
-
provider: { order: ['groq'], allow_fallbacks: true },
|
|
87
|
-
},
|
|
88
|
-
}
|
|
89
|
-
: OPENROUTER_HIGH_REASONING_PROVIDER_OPTIONS
|
|
80
|
+
? { openai: { provider: { order: ['groq'], allow_fallbacks: true } } }
|
|
81
|
+
: undefined
|
|
90
82
|
return new ToolLoopAgent({
|
|
91
83
|
id: 'workstream-router',
|
|
92
84
|
model: aiGatewayChatModel(modelId),
|
|
@@ -114,14 +106,32 @@ export async function triageWorkstreamMessage(params: {
|
|
|
114
106
|
.join('\n\n')
|
|
115
107
|
|
|
116
108
|
const agent = createRouterAgent(TRIAGE_SYSTEM_PROMPT)
|
|
117
|
-
|
|
109
|
+
let result: Awaited<ReturnType<typeof agent.generate>>
|
|
110
|
+
try {
|
|
111
|
+
result = await agent.generate({ messages: [{ role: 'user', content: prompt }], timeout: { totalMs: 30_000 } })
|
|
112
|
+
} catch (error) {
|
|
113
|
+
console.error('[workstream-router] triage failed:', error instanceof Error ? error.message : error)
|
|
114
|
+
return null
|
|
115
|
+
}
|
|
118
116
|
|
|
119
|
-
const
|
|
117
|
+
const rawText = typeof result.text === 'string' ? result.text : ''
|
|
118
|
+
console.log('[workstream-router] triage raw:', rawText.slice(0, 300))
|
|
119
|
+
const json = extractJson(rawText)
|
|
120
120
|
const parsed = TriageResultSchema.safeParse(json)
|
|
121
|
-
if (!parsed.success)
|
|
122
|
-
|
|
123
|
-
|
|
121
|
+
if (!parsed.success) {
|
|
122
|
+
console.log('[workstream-router] triage parse failed:', JSON.stringify(parsed.error.issues))
|
|
123
|
+
return null
|
|
124
|
+
}
|
|
125
|
+
if (!parsed.data.agentId) {
|
|
126
|
+
console.log('[workstream-router] triage returned empty agentId — fallback to owner')
|
|
127
|
+
return null
|
|
128
|
+
}
|
|
129
|
+
if (!params.members.includes(parsed.data.agentId)) {
|
|
130
|
+
console.log('[workstream-router] triage returned unknown agent:', parsed.data.agentId)
|
|
131
|
+
return null
|
|
132
|
+
}
|
|
124
133
|
|
|
134
|
+
console.log('[workstream-router] triage routed to:', parsed.data.agentId)
|
|
125
135
|
return parsed.data
|
|
126
136
|
}
|
|
127
137
|
|