@lota-sdk/core 0.1.37 → 0.1.38
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 +2 -2
- package/src/config/agent-defaults.ts +3 -3
- package/src/create-runtime.ts +1 -1
- package/src/runtime/runtime-config.ts +1 -1
- package/src/services/workstream-turn-preparation.service.ts +1 -1
- package/src/system-agents/index.ts +1 -1
- package/src/system-agents/{workstream-manager.agent.ts → workstream-router.agent.ts} +18 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lota-sdk/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.38",
|
|
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.38",
|
|
36
36
|
"@mendable/firecrawl-js": "^4.18.0",
|
|
37
37
|
"@surrealdb/node": "^3.0.3",
|
|
38
38
|
"ai": "^6.0.141",
|
|
@@ -12,7 +12,7 @@ function defaultGetAgentRuntimeConfig(): Record<string, never> {
|
|
|
12
12
|
export let agentDisplayNames: Record<string, string> = {}
|
|
13
13
|
export let agentShortDisplayNames: Record<string, string> = {}
|
|
14
14
|
export let agentDescriptions: Record<string, string> = {}
|
|
15
|
-
export let
|
|
15
|
+
export let routerModelId: string | undefined = undefined
|
|
16
16
|
export let agentRoster: readonly string[] = []
|
|
17
17
|
export let leadAgentId = ''
|
|
18
18
|
export let teamConsultParticipants: readonly string[] = []
|
|
@@ -39,7 +39,7 @@ export function configureAgents(config: {
|
|
|
39
39
|
displayNames: Record<string, string>
|
|
40
40
|
shortDisplayNames?: Record<string, string>
|
|
41
41
|
descriptions?: Record<string, string>
|
|
42
|
-
|
|
42
|
+
routerModelId?: string
|
|
43
43
|
teamConsultParticipants: readonly string[]
|
|
44
44
|
getCoreWorkstreamProfile?: (coreType: string) => CoreWorkstreamProfile
|
|
45
45
|
}): void {
|
|
@@ -52,7 +52,7 @@ export function configureAgents(config: {
|
|
|
52
52
|
agentDisplayNames = config.displayNames
|
|
53
53
|
agentShortDisplayNames = config.shortDisplayNames ?? {}
|
|
54
54
|
agentDescriptions = config.descriptions ?? {}
|
|
55
|
-
|
|
55
|
+
routerModelId = config.routerModelId
|
|
56
56
|
teamConsultParticipants = config.teamConsultParticipants
|
|
57
57
|
if (config.getCoreWorkstreamProfile) {
|
|
58
58
|
getCoreWorkstreamProfile = config.getCoreWorkstreamProfile
|
package/src/create-runtime.ts
CHANGED
|
@@ -251,7 +251,7 @@ export async function createLotaRuntime(config: LotaRuntimeConfig): Promise<Lota
|
|
|
251
251
|
displayNames: agentDisplayNames,
|
|
252
252
|
shortDisplayNames: runtimeConfig.agents.shortDisplayNames,
|
|
253
253
|
descriptions: runtimeConfig.agents.descriptions,
|
|
254
|
-
|
|
254
|
+
routerModelId: runtimeConfig.agents.routerModelId,
|
|
255
255
|
teamConsultParticipants: runtimeConfig.agents.teamConsultParticipants,
|
|
256
256
|
getCoreWorkstreamProfile: runtimeConfig.agents.getCoreWorkstreamProfile,
|
|
257
257
|
})
|
|
@@ -176,7 +176,7 @@ const agentsConfigSchema = z
|
|
|
176
176
|
descriptions: z
|
|
177
177
|
.custom<Record<string, string>>(isStringRecord, { error: 'agents.descriptions must be a string record' })
|
|
178
178
|
.optional(),
|
|
179
|
-
|
|
179
|
+
routerModelId: z.string().trim().min(1).optional(),
|
|
180
180
|
teamConsultParticipants: z.array(z.string().trim().min(1)),
|
|
181
181
|
getCoreWorkstreamProfile: z
|
|
182
182
|
.custom<(coreType: string) => CoreWorkstreamProfile>(isFunction, {
|
|
@@ -58,7 +58,7 @@ import type { WorkstreamState } from '../runtime/workstream-state'
|
|
|
58
58
|
import { assembleWorkstreamTurnContext } from '../runtime/workstream-turn-context'
|
|
59
59
|
import { chatRunRegistry } from '../services/chat-run-registry.service'
|
|
60
60
|
import type { NormalizedWorkstream, WorkstreamRecord } from '../services/workstream.types'
|
|
61
|
-
import { triageWorkstreamMessage, checkForNextAgent } from '../system-agents/workstream-
|
|
61
|
+
import { triageWorkstreamMessage, checkForNextAgent } from '../system-agents/workstream-router.agent'
|
|
62
62
|
import { safeEnqueue } from '../utils/async'
|
|
63
63
|
import { AppError } from '../utils/errors'
|
|
64
64
|
import { attachmentService } from './attachment.service'
|
|
@@ -3,7 +3,7 @@ import { z } from 'zod'
|
|
|
3
3
|
|
|
4
4
|
import { aiGatewayChatModel } from '../ai-gateway/ai-gateway'
|
|
5
5
|
import { buildAiGatewayDirectCacheHeaders } from '../ai-gateway/cache-headers'
|
|
6
|
-
import { agentDescriptions, agentDisplayNames,
|
|
6
|
+
import { agentDescriptions, agentDisplayNames, routerModelId } from '../config/agent-defaults'
|
|
7
7
|
import {
|
|
8
8
|
OPENROUTER_FAST_REASONING_MODEL_ID,
|
|
9
9
|
OPENROUTER_XHIGH_REASONING_PROVIDER_OPTIONS,
|
|
@@ -22,8 +22,8 @@ const CheckResultSchema = z.object({
|
|
|
22
22
|
routingContext: z.string().optional(),
|
|
23
23
|
})
|
|
24
24
|
|
|
25
|
-
export type
|
|
26
|
-
export type
|
|
25
|
+
export type RouterTriageResult = z.infer<typeof TriageResultSchema>
|
|
26
|
+
export type RouterCheckResult = z.infer<typeof CheckResultSchema>
|
|
27
27
|
|
|
28
28
|
// ---------------------------------------------------------------------------
|
|
29
29
|
// Helpers
|
|
@@ -75,15 +75,20 @@ Format: {"done":true} or {"done":false,"agentId":"<id>","routingContext":"<1-sen
|
|
|
75
75
|
// Agent functions
|
|
76
76
|
// ---------------------------------------------------------------------------
|
|
77
77
|
|
|
78
|
-
function
|
|
79
|
-
const modelId =
|
|
80
|
-
const providerOptions =
|
|
81
|
-
?
|
|
78
|
+
function createRouterAgent(systemPrompt: string) {
|
|
79
|
+
const modelId = routerModelId ?? OPENROUTER_FAST_REASONING_MODEL_ID
|
|
80
|
+
const providerOptions = routerModelId
|
|
81
|
+
? {
|
|
82
|
+
openai: {
|
|
83
|
+
...OPENROUTER_XHIGH_REASONING_PROVIDER_OPTIONS.openai,
|
|
84
|
+
provider: { order: ['groq'], allow_fallbacks: true },
|
|
85
|
+
},
|
|
86
|
+
}
|
|
82
87
|
: OPENROUTER_HIGH_REASONING_PROVIDER_OPTIONS
|
|
83
88
|
return new ToolLoopAgent({
|
|
84
|
-
id: 'workstream-
|
|
89
|
+
id: 'workstream-router',
|
|
85
90
|
model: aiGatewayChatModel(modelId),
|
|
86
|
-
headers: buildAiGatewayDirectCacheHeaders('workstream-
|
|
91
|
+
headers: buildAiGatewayDirectCacheHeaders('workstream-router'),
|
|
87
92
|
providerOptions,
|
|
88
93
|
instructions: systemPrompt,
|
|
89
94
|
maxOutputTokens: 256,
|
|
@@ -95,7 +100,7 @@ export async function triageWorkstreamMessage(params: {
|
|
|
95
100
|
members: readonly string[]
|
|
96
101
|
messageText: string
|
|
97
102
|
recentContext?: string
|
|
98
|
-
}): Promise<
|
|
103
|
+
}): Promise<RouterTriageResult | null> {
|
|
99
104
|
const membersDesc = buildMembersDescription(params.members)
|
|
100
105
|
const prompt = [
|
|
101
106
|
`Workstream: "${params.workstreamTitle}"`,
|
|
@@ -106,7 +111,7 @@ export async function triageWorkstreamMessage(params: {
|
|
|
106
111
|
.filter(Boolean)
|
|
107
112
|
.join('\n\n')
|
|
108
113
|
|
|
109
|
-
const agent =
|
|
114
|
+
const agent = createRouterAgent(TRIAGE_SYSTEM_PROMPT)
|
|
110
115
|
const result = await agent.generate({ messages: [{ role: 'user', content: prompt }], timeout: { totalMs: 30_000 } })
|
|
111
116
|
|
|
112
117
|
const json = extractJson(typeof result.text === 'string' ? result.text : '')
|
|
@@ -124,7 +129,7 @@ export async function checkForNextAgent(params: {
|
|
|
124
129
|
messageText: string
|
|
125
130
|
respondedAgents: string[]
|
|
126
131
|
lastResponseSummary: string
|
|
127
|
-
}): Promise<
|
|
132
|
+
}): Promise<RouterCheckResult> {
|
|
128
133
|
const remainingMembers = params.members.filter((id) => !params.respondedAgents.includes(id))
|
|
129
134
|
if (remainingMembers.length === 0) return { done: true }
|
|
130
135
|
|
|
@@ -139,7 +144,7 @@ export async function checkForNextAgent(params: {
|
|
|
139
144
|
`Last response summary: "${params.lastResponseSummary}"`,
|
|
140
145
|
].join('\n\n')
|
|
141
146
|
|
|
142
|
-
const agent =
|
|
147
|
+
const agent = createRouterAgent(CHECK_SYSTEM_PROMPT)
|
|
143
148
|
const result = await agent.generate({ messages: [{ role: 'user', content: prompt }], timeout: { totalMs: 30_000 } })
|
|
144
149
|
|
|
145
150
|
const json = extractJson(typeof result.text === 'string' ? result.text : '')
|