obol-ai 0.3.44 → 0.3.45
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 +1 -1
- package/src/runtime/heartbeat.js +16 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "obol-ai",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.45",
|
|
4
4
|
"description": "Self-evolving AI assistant that learns, remembers, and acts on its own. Persistent vector memory, self-rewriting personality, proactive heartbeats.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": {
|
package/src/runtime/heartbeat.js
CHANGED
|
@@ -6,6 +6,7 @@ const { ensureUserDir, getUserTimezone } = require('../config');
|
|
|
6
6
|
const { runAnalysis } = require('../analysis');
|
|
7
7
|
const { runProactiveNews } = require('../news');
|
|
8
8
|
const { createSelfMemory } = require('../memory/self');
|
|
9
|
+
const { createAnthropicClient, ensureFreshToken } = require('../claude/client');
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
const ANALYSIS_HOURS = new Set([4, 7, 10, 13, 16, 19, 22]);
|
|
@@ -16,6 +17,14 @@ const _newsRunning = new Set();
|
|
|
16
17
|
const _inflight = new Set();
|
|
17
18
|
const _analysisRunning = new Set();
|
|
18
19
|
|
|
20
|
+
async function getFreshClient(config) {
|
|
21
|
+
const ac = config.anthropic;
|
|
22
|
+
if (ac.oauth?.accessToken) await ensureFreshToken(ac);
|
|
23
|
+
return ac._oauthFailed
|
|
24
|
+
? createAnthropicClient(ac, { useOAuth: false })
|
|
25
|
+
: createAnthropicClient(ac);
|
|
26
|
+
}
|
|
27
|
+
|
|
19
28
|
function getLocalHour(timezone) {
|
|
20
29
|
const parts = new Intl.DateTimeFormat('en-US', {
|
|
21
30
|
timeZone: timezone,
|
|
@@ -42,8 +51,9 @@ async function runEvolutionForUser(bot, config, userId) {
|
|
|
42
51
|
|
|
43
52
|
try {
|
|
44
53
|
const tenant = await getTenant(userId, config);
|
|
54
|
+
const client = await getFreshClient(config);
|
|
45
55
|
const selfMemory = config.supabase ? await createSelfMemory(config.supabase, 0).catch(() => null) : null;
|
|
46
|
-
const result = await evolve(
|
|
56
|
+
const result = await evolve(client, tenant.messageLog, tenant.memory, tenant.userDir, config.supabase, selfMemory);
|
|
47
57
|
tenant.claude.reloadPersonality?.();
|
|
48
58
|
|
|
49
59
|
let msg = `🪙 Evolution #${result.evolutionNumber} complete.`;
|
|
@@ -85,7 +95,8 @@ async function runAnalysisForUser(bot, config, userId) {
|
|
|
85
95
|
try {
|
|
86
96
|
const tenant = await getTenant(userId, config);
|
|
87
97
|
if (!tenant.messageLog || !tenant.scheduler || !tenant.patterns) return;
|
|
88
|
-
|
|
98
|
+
const client = await getFreshClient(config);
|
|
99
|
+
await runAnalysis(client, tenant.messageLog, tenant.scheduler, tenant.patterns, tenant.memory, userId, userId, timezone);
|
|
89
100
|
} catch (e) {
|
|
90
101
|
console.error(`[analysis] Failed for user ${userId}:`, e.message);
|
|
91
102
|
} finally {
|
|
@@ -320,12 +331,14 @@ async function runAgenticEvent(bot, config, event) {
|
|
|
320
331
|
'Do NOT output JSON, code blocks, tool calls, or structured data. Write as a direct Telegram message.'
|
|
321
332
|
);
|
|
322
333
|
|
|
334
|
+
const client = await getFreshClient(config);
|
|
335
|
+
|
|
323
336
|
const controller = new AbortController();
|
|
324
337
|
const timeout = setTimeout(() => controller.abort(), EVENT_TIMEOUT_MS);
|
|
325
338
|
|
|
326
339
|
let response;
|
|
327
340
|
try {
|
|
328
|
-
response = await
|
|
341
|
+
response = await client.messages.create({
|
|
329
342
|
model: 'claude-sonnet-4-6',
|
|
330
343
|
max_tokens: 300,
|
|
331
344
|
system: systemParts.join('\n\n'),
|