@lota-sdk/core 0.4.20 → 0.4.21
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,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lota-sdk/core",
|
|
3
|
-
"version": "0.4.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"main": "./src/index.ts",
|
|
6
|
-
"types": "./src/index.ts",
|
|
3
|
+
"version": "0.4.21",
|
|
7
4
|
"files": [
|
|
8
5
|
"src",
|
|
9
6
|
"infrastructure/schema"
|
|
10
7
|
],
|
|
8
|
+
"type": "module",
|
|
9
|
+
"main": "./src/index.ts",
|
|
10
|
+
"types": "./src/index.ts",
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
13
|
"bun": "./src/index.ts",
|
|
@@ -15,6 +15,10 @@
|
|
|
15
15
|
"types": "./src/index.ts"
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public",
|
|
20
|
+
"registry": "https://registry.npmjs.org/"
|
|
21
|
+
},
|
|
18
22
|
"scripts": {
|
|
19
23
|
"lint": "bunx oxlint --fix -c ../oxlint.config.ts src",
|
|
20
24
|
"format": "bunx oxfmt src",
|
|
@@ -22,23 +26,19 @@
|
|
|
22
26
|
"test:unit": "bun test --max-concurrency=1 ../tests/unit/core",
|
|
23
27
|
"test:coverage": "bun test --coverage ../tests/unit/core"
|
|
24
28
|
},
|
|
25
|
-
"publishConfig": {
|
|
26
|
-
"access": "public",
|
|
27
|
-
"registry": "https://registry.npmjs.org/"
|
|
28
|
-
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@ai-sdk/devtools": "^0.0.
|
|
31
|
-
"@ai-sdk/openai": "^3.0.
|
|
30
|
+
"@ai-sdk/devtools": "^0.0.16",
|
|
31
|
+
"@ai-sdk/openai": "^3.0.54",
|
|
32
32
|
"@chat-adapter/slack": "^4.26.0",
|
|
33
33
|
"@chat-adapter/state-ioredis": "^4.26.0",
|
|
34
|
-
"@lota-sdk/shared": "0.4.
|
|
35
|
-
"@mendable/firecrawl-js": "^4.
|
|
34
|
+
"@lota-sdk/shared": "0.4.21",
|
|
35
|
+
"@mendable/firecrawl-js": "^4.20.0",
|
|
36
36
|
"@surrealdb/node": "^3.0.3",
|
|
37
|
-
"ai": "^6.0.
|
|
38
|
-
"bullmq": "^5.
|
|
37
|
+
"ai": "^6.0.170",
|
|
38
|
+
"bullmq": "^5.76.4",
|
|
39
39
|
"chat": "^4.26.0",
|
|
40
|
-
"effect": "^4.0.0-beta.
|
|
41
|
-
"hono": "^4.12.
|
|
40
|
+
"effect": "^4.0.0-beta.59",
|
|
41
|
+
"hono": "^4.12.15",
|
|
42
42
|
"ioredis": "5.9.3",
|
|
43
43
|
"mammoth": "^1.12.0",
|
|
44
44
|
"pdf-parse": "^2.4.5",
|
|
@@ -721,6 +721,16 @@ function isReasoningEnabled(params: AiGatewayCallOptions): boolean {
|
|
|
721
721
|
return typeof openaiOptions.reasoningEffort === 'string' && openaiOptions.reasoningEffort !== 'none'
|
|
722
722
|
}
|
|
723
723
|
|
|
724
|
+
function hasFunctionTools(params: AiGatewayCallOptions): boolean {
|
|
725
|
+
return Array.isArray(params.tools) && params.tools.some((tool) => isRecord(tool) && tool.type === 'function')
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
function isGpt55Model(modelId: string): boolean {
|
|
729
|
+
const normalized = modelId.trim().toLowerCase()
|
|
730
|
+
const modelName = normalized.split('/').at(-1) ?? normalized
|
|
731
|
+
return modelName === 'gpt-5.5' || modelName.startsWith('gpt-5.5-')
|
|
732
|
+
}
|
|
733
|
+
|
|
724
734
|
function isOpenRouterModel(modelId: string): boolean {
|
|
725
735
|
return modelId.trim().toLowerCase().startsWith('openrouter/')
|
|
726
736
|
}
|
|
@@ -887,7 +897,11 @@ function resolveProviderModel(
|
|
|
887
897
|
modelId: string,
|
|
888
898
|
providerId: string,
|
|
889
899
|
): AiGatewayLanguageModel {
|
|
890
|
-
|
|
900
|
+
if (providerId !== OPENAI_CHAT_PROVIDER_ID) {
|
|
901
|
+
return provider(modelId)
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
return provider.chat(modelId)
|
|
891
905
|
}
|
|
892
906
|
|
|
893
907
|
export type AiGatewayDeps = {
|
|
@@ -927,7 +941,10 @@ function createAiGatewayLanguageModelMiddleware(
|
|
|
927
941
|
transformParams: ({ params, type }) =>
|
|
928
942
|
Promise.resolve(
|
|
929
943
|
withDefaultAiGatewayCacheHeaders(
|
|
930
|
-
addAiGatewayReasoningRawChunks(
|
|
944
|
+
addAiGatewayReasoningRawChunks(
|
|
945
|
+
providerId === OPENAI_CHAT_PROVIDER_ID ? normalizeAiGatewayChatProviderOptions(params, modelId) : params,
|
|
946
|
+
type,
|
|
947
|
+
),
|
|
931
948
|
),
|
|
932
949
|
),
|
|
933
950
|
wrapGenerate: ({ params }) => {
|
|
@@ -972,9 +989,38 @@ function createAiGatewayLanguageModelMiddleware(
|
|
|
972
989
|
|
|
973
990
|
export function normalizeAiGatewayChatProviderOptions(
|
|
974
991
|
params: AiGatewayCallOptions,
|
|
975
|
-
|
|
992
|
+
modelId?: string,
|
|
976
993
|
): AiGatewayCallOptions {
|
|
977
|
-
|
|
994
|
+
if (!modelId || !isGpt55Model(modelId) || !hasFunctionTools(params)) {
|
|
995
|
+
return params
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
if (!isRecord(params.providerOptions) || !isRecord(params.providerOptions.openai)) {
|
|
999
|
+
return params
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
const openaiOptions = { ...params.providerOptions.openai }
|
|
1003
|
+
const strippedReasoningOptions =
|
|
1004
|
+
'forceReasoning' in openaiOptions || 'reasoningEffort' in openaiOptions || 'reasoningSummary' in openaiOptions
|
|
1005
|
+
if (!strippedReasoningOptions) {
|
|
1006
|
+
return params
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
delete openaiOptions.forceReasoning
|
|
1010
|
+
delete openaiOptions.reasoningEffort
|
|
1011
|
+
delete openaiOptions.reasoningSummary
|
|
1012
|
+
|
|
1013
|
+
const providerOptions = { ...params.providerOptions }
|
|
1014
|
+
delete providerOptions.openai
|
|
1015
|
+
const nextProviderOptions =
|
|
1016
|
+
Object.keys(openaiOptions).length === 0 ? providerOptions : { ...providerOptions, openai: openaiOptions }
|
|
1017
|
+
|
|
1018
|
+
if (Object.keys(nextProviderOptions).length === 0) {
|
|
1019
|
+
const { providerOptions: _providerOptions, ...nextParams } = params
|
|
1020
|
+
return nextParams
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
return { ...params, providerOptions: nextProviderOptions as AiGatewayCallOptions['providerOptions'] }
|
|
978
1024
|
}
|
|
979
1025
|
|
|
980
1026
|
function withAiGatewayDevTools<TModel extends AiGatewayLanguageModel>(model: TModel): TModel {
|
|
@@ -82,15 +82,15 @@ type PromisifiedService<T> = {
|
|
|
82
82
|
|
|
83
83
|
type HostSvc<T extends { readonly Service: object }> = PromisifiedService<T['Service']>
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
type PromisifiedThreadService = HostSvc<typeof ThreadServiceTag>
|
|
86
|
+
type PromisifiedDocumentChunkService = HostSvc<typeof DocumentChunkServiceTag>
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
type ArchiveSdkThread = (
|
|
89
89
|
threadId: Parameters<Svc<typeof ThreadServiceTag>['updateStatus']>[0],
|
|
90
90
|
status?: 'archived',
|
|
91
91
|
) => ReturnType<Svc<typeof ThreadServiceTag>['updateStatus']>
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
type UnarchiveSdkThread = (
|
|
94
94
|
threadId: Parameters<Svc<typeof ThreadServiceTag>['updateStatus']>[0],
|
|
95
95
|
status?: 'active',
|
|
96
96
|
) => ReturnType<Svc<typeof ThreadServiceTag>['updateStatus']>
|
|
@@ -5,7 +5,7 @@ import { nowEpochMillis } from '../utils/date-time'
|
|
|
5
5
|
import { buildCompletionCheckStructuredOutputHints } from './agent-runtime-policy'
|
|
6
6
|
import { mergeInstructionSections } from './instruction-sections'
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
interface PlanTurnUpstreamHandoff {
|
|
9
9
|
nodeId: string
|
|
10
10
|
label: string
|
|
11
11
|
ownerRef: string
|
|
@@ -16,7 +16,7 @@ import type { LotaRuntimeBackgroundCursor } from '../../runtime/runtime-extensio
|
|
|
16
16
|
import type { SocialChatHistoryMessage } from '../../services/social-chat-history.service'
|
|
17
17
|
import { unsafeDateFrom } from '../../utils/date-time'
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
interface ThreadDigestMessage {
|
|
20
20
|
source: 'thread'
|
|
21
21
|
sourceId: string
|
|
22
22
|
role: 'system' | 'user' | 'assistant'
|
|
@@ -25,7 +25,7 @@ export interface ThreadDigestMessage {
|
|
|
25
25
|
cursor: LotaRuntimeBackgroundCursor
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
type SocialDigestMessage = Pick<
|
|
29
29
|
SocialChatHistoryMessage,
|
|
30
30
|
'source' | 'sourceId' | 'role' | 'parts' | 'metadata' | 'cursor'
|
|
31
31
|
>
|