@lota-sdk/shared 0.1.16 → 0.1.18

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.16",
3
+ "version": "0.1.18",
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": "node ../node_modules/oxlint/bin/oxlint --fix -c ../oxlint.config.ts src",
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"
@@ -1,34 +1,34 @@
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:exacto' as const
5
- export const OPENROUTER_DELEGATED_REASONING_MODEL_ID = 'openrouter/google/gemini-3-flash-preview:exacto' as const
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
- 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:exacto' as const
7
+ export const OPENROUTER_FAST_REASONING_MODEL_ID = 'openrouter/qwen/qwen3.5-flash-02-23' as const
8
+ export const OPENROUTER_STRUCTURED_REASONING_MODEL_ID = 'openrouter/google/gemini-3.1-pro-preview' as const
9
9
 
10
- export const BIFROST_REASONING_SUMMARY_LEVEL = 'detailed' as const
10
+ export const AI_GATEWAY_REASONING_SUMMARY_LEVEL = 'detailed' as const
11
11
 
12
12
  export const OPENAI_HIGH_REASONING_PROVIDER_OPTIONS = {
13
- openai: { forceReasoning: true, reasoningEffort: 'high', reasoningSummary: BIFROST_REASONING_SUMMARY_LEVEL },
13
+ openai: { forceReasoning: true, reasoningEffort: 'high', reasoningSummary: AI_GATEWAY_REASONING_SUMMARY_LEVEL },
14
14
  } as const
15
15
 
16
16
  export const OPENROUTER_HIGH_REASONING_PROVIDER_OPTIONS = {
17
- openai: { forceReasoning: true, reasoningEffort: 'high', reasoningSummary: BIFROST_REASONING_SUMMARY_LEVEL },
17
+ openai: { forceReasoning: true, reasoningEffort: 'high', reasoningSummary: AI_GATEWAY_REASONING_SUMMARY_LEVEL },
18
18
  } as const
19
19
 
20
20
  export const OPENROUTER_XHIGH_REASONING_PROVIDER_OPTIONS = {
21
- openai: { forceReasoning: true, reasoningEffort: 'xhigh', reasoningSummary: BIFROST_REASONING_SUMMARY_LEVEL },
21
+ openai: { forceReasoning: true, reasoningEffort: 'xhigh', reasoningSummary: AI_GATEWAY_REASONING_SUMMARY_LEVEL },
22
22
  } as const
23
23
 
24
24
  export const OPENROUTER_MEDIUM_REASONING_PROVIDER_OPTIONS = {
25
- openai: { forceReasoning: true, reasoningEffort: 'medium', reasoningSummary: BIFROST_REASONING_SUMMARY_LEVEL },
25
+ openai: { forceReasoning: true, reasoningEffort: 'medium', reasoningSummary: AI_GATEWAY_REASONING_SUMMARY_LEVEL },
26
26
  } as const
27
27
 
28
28
  export const OPENROUTER_LOW_REASONING_PROVIDER_OPTIONS = {
29
- openai: { forceReasoning: true, reasoningEffort: 'low', reasoningSummary: BIFROST_REASONING_SUMMARY_LEVEL },
29
+ openai: { forceReasoning: true, reasoningEffort: 'low', reasoningSummary: AI_GATEWAY_REASONING_SUMMARY_LEVEL },
30
30
  } as const
31
31
 
32
32
  export const OPENROUTER_MINIMAL_REASONING_PROVIDER_OPTIONS = {
33
- openai: { forceReasoning: true, reasoningEffort: 'minimal', reasoningSummary: BIFROST_REASONING_SUMMARY_LEVEL },
33
+ openai: { forceReasoning: true, reasoningEffort: 'minimal', reasoningSummary: AI_GATEWAY_REASONING_SUMMARY_LEVEL },
34
34
  } as const
package/src/index.ts CHANGED
@@ -29,4 +29,5 @@ export * from './utils/confidence'
29
29
  export * from './utils/date-time'
30
30
  export * from './utils/errors'
31
31
  export * from './utils/markdown-normalization'
32
+ export * from './utils/slack-social-reply'
32
33
  export * from './utils/string'
@@ -1,4 +1,11 @@
1
- import type { Output, PrepareStepFunction, StopCondition, ToolLoopAgentOnFinishCallback, ToolSet } from 'ai'
1
+ import type {
2
+ LanguageModel,
3
+ Output,
4
+ PrepareStepFunction,
5
+ StopCondition,
6
+ ToolLoopAgentOnFinishCallback,
7
+ ToolSet,
8
+ } from 'ai'
2
9
 
3
10
  export type ChatMode = 'direct' | 'workstreamMode' | 'fixedWorkstreamMode'
4
11
 
@@ -6,11 +13,12 @@ export interface CreateRoutedAgentOptions<TTools extends ToolSet = ToolSet> {
6
13
  mode: ChatMode
7
14
  tools: TTools
8
15
  extraInstructions?: string
16
+ headers?: Record<string, string>
9
17
  stopWhen?: StopCondition<TTools> | Array<StopCondition<TTools>>
10
18
  prepareStep?: PrepareStepFunction<TTools>
11
19
  maxRetries?: number
12
20
  output?: Output.Output
13
- modelOverride?: { model: unknown; providerOptions?: Record<string, unknown> }
21
+ modelOverride?: { model: LanguageModel; providerOptions?: Record<string, unknown> }
14
22
  onFinish?: ToolLoopAgentOnFinishCallback<TTools>
15
23
  }
16
24
 
@@ -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
+ }