@lota-sdk/shared 0.1.16 → 0.1.17
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/shared",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
"scripts": {
|
|
18
|
-
"lint": "
|
|
18
|
+
"lint": "bunx oxlint --fix -c ../oxlint.config.ts src",
|
|
19
19
|
"format": "bunx oxfmt src",
|
|
20
20
|
"typecheck": "bunx tsgo --noEmit",
|
|
21
21
|
"test:unit": "bun test ../tests/unit/shared"
|
package/src/constants/model.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export const OPENAI_REASONING_MODEL_ID = 'openai/gpt-5.4' as const
|
|
2
2
|
|
|
3
3
|
export const OPENROUTER_TEAM_AGENT_MODEL_ID = 'openrouter/google/gemini-3.1-pro-preview' as const
|
|
4
|
-
export const OPENROUTER_STRUCTURED_HELPER_MODEL_ID = 'openrouter/google/gemini-3-flash-preview
|
|
5
|
-
export const OPENROUTER_DELEGATED_REASONING_MODEL_ID = 'openrouter/google/gemini-3-flash-preview
|
|
4
|
+
export const OPENROUTER_STRUCTURED_HELPER_MODEL_ID = 'openrouter/google/gemini-3-flash-preview' as const
|
|
5
|
+
export const OPENROUTER_DELEGATED_REASONING_MODEL_ID = 'openrouter/google/gemini-3-flash-preview' as const
|
|
6
6
|
export const OPENROUTER_WEB_RESEARCH_MODEL_ID = 'openrouter/stepfun/step-3.5-flash' as const
|
|
7
7
|
export const OPENROUTER_FAST_REASONING_MODEL_ID = 'openrouter/openai/gpt-oss-120b:nitro' as const
|
|
8
|
-
export const OPENROUTER_STRUCTURED_REASONING_MODEL_ID = 'openrouter/openai/gpt-oss-120b:
|
|
8
|
+
export const OPENROUTER_STRUCTURED_REASONING_MODEL_ID = 'openrouter/openai/gpt-oss-120b:nitro' as const
|
|
9
9
|
|
|
10
10
|
export const BIFROST_REASONING_SUMMARY_LEVEL = 'detailed' as const
|
|
11
11
|
|
package/src/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ export interface CreateRoutedAgentOptions<TTools extends ToolSet = ToolSet> {
|
|
|
6
6
|
mode: ChatMode
|
|
7
7
|
tools: TTools
|
|
8
8
|
extraInstructions?: string
|
|
9
|
+
headers?: Record<string, string>
|
|
9
10
|
stopWhen?: StopCondition<TTools> | Array<StopCondition<TTools>>
|
|
10
11
|
prepareStep?: PrepareStepFunction<TTools>
|
|
11
12
|
maxRetries?: number
|
|
@@ -7,9 +7,6 @@ export const messageMetadataSchema = z
|
|
|
7
7
|
.object({
|
|
8
8
|
agentId: z.string().optional(),
|
|
9
9
|
agentName: z.string().optional(),
|
|
10
|
-
reasoningProfile: z.enum(['fast', 'standard', 'deep']).optional(),
|
|
11
|
-
highImpactClasses: z.array(z.string()).optional(),
|
|
12
|
-
policyClasses: z.array(z.string()).optional(),
|
|
13
10
|
semanticTerminationReason: z.enum(['none', 'conflict', 'cycle-detected']).optional(),
|
|
14
11
|
inputTokens: z.number().optional(),
|
|
15
12
|
outputTokens: z.number().optional(),
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { normalizeAssistantMarkdown } from './markdown-normalization'
|
|
2
|
+
|
|
3
|
+
const LEADING_TOOL_NOTICE_BLOCK_PATTERN = /^```(?:md|markdown|text)?\nAgent executed[\s\S]*?tools?\.\n```\n{0,2}/
|
|
4
|
+
|
|
5
|
+
const TOOL_DISPLAY_NAME_OVERRIDES: Record<string, string> = {
|
|
6
|
+
consultSpecialist: 'Consult Specialist',
|
|
7
|
+
fetchWebpage: 'Fetch Webpage',
|
|
8
|
+
memoryRemember: 'Remember Memory',
|
|
9
|
+
memorySearch: 'Memory Search',
|
|
10
|
+
researchTopic: 'Research Topic',
|
|
11
|
+
searchWeb: 'Web Search',
|
|
12
|
+
userQuestions: 'User Questions',
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function titleCaseWord(value: string): string {
|
|
16
|
+
const firstCharacter = value.at(0)
|
|
17
|
+
return firstCharacter ? firstCharacter.toUpperCase() + value.slice(1).toLowerCase() : value
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function formatQuotedDisplayNameList(values: string[]): string {
|
|
21
|
+
if (values.length === 0) return ''
|
|
22
|
+
if (values.length === 1) return `"${values[0]}"`
|
|
23
|
+
if (values.length === 2) return `"${values[0]}" and "${values[1]}"`
|
|
24
|
+
|
|
25
|
+
const allButLast = values
|
|
26
|
+
.slice(0, -1)
|
|
27
|
+
.map((value) => `"${value}"`)
|
|
28
|
+
.join(', ')
|
|
29
|
+
const lastValue = values.at(-1)
|
|
30
|
+
return lastValue ? `${allButLast}, and "${lastValue}"` : allButLast
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function humanizeToolDisplayName(toolName: string): string {
|
|
34
|
+
const override = TOOL_DISPLAY_NAME_OVERRIDES[toolName]
|
|
35
|
+
if (override) return override
|
|
36
|
+
|
|
37
|
+
return toolName
|
|
38
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1 $2')
|
|
39
|
+
.replace(/[_-]+/g, ' ')
|
|
40
|
+
.trim()
|
|
41
|
+
.split(/\s+/)
|
|
42
|
+
.filter(Boolean)
|
|
43
|
+
.map(titleCaseWord)
|
|
44
|
+
.join(' ')
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function buildSlackToolExecutionNoticeMarkdown(toolNames: string[]): string {
|
|
48
|
+
const uniqueDisplayNames = [...new Set(toolNames.map(humanizeToolDisplayName).filter((value) => value.length > 0))]
|
|
49
|
+
if (uniqueDisplayNames.length === 0) return ''
|
|
50
|
+
|
|
51
|
+
const toolLabel = uniqueDisplayNames.length === 1 ? 'tool' : 'tools'
|
|
52
|
+
return `\`\`\`\nAgent executed ${formatQuotedDisplayNameList(uniqueDisplayNames)} ${toolLabel}.\n\`\`\``
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function stripSlackToolExecutionNoticeMarkdown(markdown: string): string {
|
|
56
|
+
return markdown.replace(LEADING_TOOL_NOTICE_BLOCK_PATTERN, '').trim()
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function buildSlackSocialReplyMarkdown(params: { replyMarkdown: string; executedToolNames?: string[] }): string {
|
|
60
|
+
const normalizedReply = normalizeAssistantMarkdown(params.replyMarkdown).trim()
|
|
61
|
+
const toolNoticeMarkdown = buildSlackToolExecutionNoticeMarkdown(params.executedToolNames ?? [])
|
|
62
|
+
|
|
63
|
+
return [toolNoticeMarkdown, normalizedReply].filter((value) => value.length > 0).join('\n\n')
|
|
64
|
+
}
|