@lota-sdk/core 0.4.33 → 0.4.35
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.4.
|
|
3
|
+
"version": "0.4.35",
|
|
4
4
|
"files": [
|
|
5
5
|
"src",
|
|
6
6
|
"infrastructure/schema"
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@ai-sdk/provider": "^3.0.9",
|
|
33
33
|
"@chat-adapter/slack": "^4.26.0",
|
|
34
34
|
"@chat-adapter/state-ioredis": "^4.26.0",
|
|
35
|
-
"@lota-sdk/shared": "0.4.
|
|
35
|
+
"@lota-sdk/shared": "0.4.35",
|
|
36
36
|
"@mendable/firecrawl-js": "^4.20.0",
|
|
37
37
|
"@surrealdb/node": "^3.0.3",
|
|
38
38
|
"ai": "^6.0.170",
|
|
@@ -4,10 +4,7 @@ import { ToolLoopAgent } from 'ai'
|
|
|
4
4
|
import type { AiGatewayModels } from '../ai-gateway/ai-gateway'
|
|
5
5
|
import { buildAiGatewayDirectCacheHeaders } from '../ai-gateway/cache-headers'
|
|
6
6
|
import type { ResolvedAgentConfig } from '../config/agent-defaults'
|
|
7
|
-
import {
|
|
8
|
-
OPENROUTER_STRUCTURED_HELPER_MODEL_ID,
|
|
9
|
-
OPENROUTER_HIGH_REASONING_PROVIDER_OPTIONS,
|
|
10
|
-
} from '../config/model-constants'
|
|
7
|
+
import { OPENROUTER_STRUCTURED_HELPER_MODEL_ID } from '../config/model-constants'
|
|
11
8
|
import { resolveHelperAgentOptions } from './helper-agent-options'
|
|
12
9
|
|
|
13
10
|
const RECENT_ACTIVITY_TITLE_MAX_TOKENS = 256
|
|
@@ -82,7 +79,6 @@ export function makeRecentActivityTitleRefinerAgentFactory(models: AiGatewayMode
|
|
|
82
79
|
id: 'recent-activity-title-refiner',
|
|
83
80
|
model: models.chatModel(OPENROUTER_STRUCTURED_HELPER_MODEL_ID),
|
|
84
81
|
headers: buildAiGatewayDirectCacheHeaders('lota-sdk'),
|
|
85
|
-
providerOptions: OPENROUTER_HIGH_REASONING_PROVIDER_OPTIONS,
|
|
86
82
|
...resolveHelperAgentOptions(options, {
|
|
87
83
|
instructions: buildRecentActivityTitleRefinerPrompt(agentConfig),
|
|
88
84
|
maxOutputTokens: RECENT_ACTIVITY_TITLE_MAX_TOKENS,
|
|
@@ -31,13 +31,27 @@ export interface WorkerHandle {
|
|
|
31
31
|
shutdown: () => Promise<void>
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
interface WorkerWithCurrentJobsWait {
|
|
35
|
+
whenCurrentJobsFinished?: (reconnect?: boolean) => Promise<void>
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function waitForCurrentJobsToFinish(worker: Worker): Promise<void> {
|
|
39
|
+
const workerWithWait = worker as unknown as WorkerWithCurrentJobsWait
|
|
40
|
+
if (typeof workerWithWait.whenCurrentJobsFinished === 'function') {
|
|
41
|
+
await workerWithWait.whenCurrentJobsFinished(false)
|
|
42
|
+
return
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
await worker.close(false)
|
|
46
|
+
}
|
|
47
|
+
|
|
34
48
|
async function closeWorkerWithTimeout(
|
|
35
49
|
worker: Worker,
|
|
36
50
|
name: string,
|
|
37
51
|
logger: typeof chatLogger,
|
|
38
52
|
timeoutMs = DEFAULT_SHUTDOWN_TIMEOUT_MS,
|
|
39
53
|
): Promise<void> {
|
|
40
|
-
const gracefulClose = worker
|
|
54
|
+
const gracefulClose = waitForCurrentJobsToFinish(worker)
|
|
41
55
|
const gracefulOutcome = gracefulClose.then(
|
|
42
56
|
() => ({ status: 'closed' as const }),
|
|
43
57
|
(error: unknown) => ({ status: 'failed' as const, error }),
|
|
@@ -45,7 +59,10 @@ async function closeWorkerWithTimeout(
|
|
|
45
59
|
|
|
46
60
|
const outcome = await Promise.race([gracefulOutcome, delay(timeoutMs).then(() => ({ status: 'timed_out' as const }))])
|
|
47
61
|
|
|
48
|
-
if (outcome.status === 'closed')
|
|
62
|
+
if (outcome.status === 'closed') {
|
|
63
|
+
await worker.close(false)
|
|
64
|
+
return
|
|
65
|
+
}
|
|
49
66
|
|
|
50
67
|
if (outcome.status === 'timed_out') {
|
|
51
68
|
logger.warn`${name} worker did not close within ${timeoutMs}ms; force-closing`
|