@lota-sdk/core 0.1.39 → 0.1.41

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.39",
3
+ "version": "0.1.41",
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.39",
35
+ "@lota-sdk/shared": "0.1.41",
36
36
  "@mendable/firecrawl-js": "^4.18.0",
37
37
  "@surrealdb/node": "^3.0.3",
38
38
  "ai": "^6.0.141",
@@ -65,9 +65,11 @@ Format: {"agentId":"<id>","routingContext":"<1-sentence instruction>"}`
65
65
  const CHECK_SYSTEM_PROMPT = `You decide if another team member should also respond after the previous agent.
66
66
 
67
67
  Rules:
68
- - Only add another agent if the user's question has a clearly separate dimension not yet covered.
69
- - Do NOT add agents for agreement or acknowledgement.
70
- - Most messages need only one agent. Reply with ONLY a JSON object, no other text.
68
+ - Add another agent if the user's message has a clearly separate dimension not yet covered.
69
+ - If the user explicitly addressed multiple agents (e.g. "CTO: ... CMO: ..."), each addressed agent MUST respond.
70
+ - If the previous agent deferred to another specialist, that specialist SHOULD respond.
71
+ - Do NOT add agents for agreement or acknowledgement only.
72
+ - Reply with ONLY a JSON object, no other text.
71
73
 
72
74
  Format: {"done":true} or {"done":false,"agentId":"<id>","routingContext":"<1-sentence>"}`
73
75
 
@@ -112,14 +114,32 @@ export async function triageWorkstreamMessage(params: {
112
114
  .join('\n\n')
113
115
 
114
116
  const agent = createRouterAgent(TRIAGE_SYSTEM_PROMPT)
115
- const result = await agent.generate({ messages: [{ role: 'user', content: prompt }], timeout: { totalMs: 30_000 } })
117
+ let result: Awaited<ReturnType<typeof agent.generate>>
118
+ try {
119
+ result = await agent.generate({ messages: [{ role: 'user', content: prompt }], timeout: { totalMs: 30_000 } })
120
+ } catch (error) {
121
+ console.error('[workstream-router] triage failed:', error instanceof Error ? error.message : error)
122
+ return null
123
+ }
116
124
 
117
- const json = extractJson(typeof result.text === 'string' ? result.text : '')
125
+ const rawText = typeof result.text === 'string' ? result.text : ''
126
+ console.log('[workstream-router] triage raw:', rawText.slice(0, 300))
127
+ const json = extractJson(rawText)
118
128
  const parsed = TriageResultSchema.safeParse(json)
119
- if (!parsed.success) return null
120
- if (!parsed.data.agentId) return null
121
- if (!params.members.includes(parsed.data.agentId)) return null
129
+ if (!parsed.success) {
130
+ console.log('[workstream-router] triage parse failed:', JSON.stringify(parsed.error.issues))
131
+ return null
132
+ }
133
+ if (!parsed.data.agentId) {
134
+ console.log('[workstream-router] triage returned empty agentId — fallback to owner')
135
+ return null
136
+ }
137
+ if (!params.members.includes(parsed.data.agentId)) {
138
+ console.log('[workstream-router] triage returned unknown agent:', parsed.data.agentId)
139
+ return null
140
+ }
122
141
 
142
+ console.log('[workstream-router] triage routed to:', parsed.data.agentId)
123
143
  return parsed.data
124
144
  }
125
145