-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
57 lines (44 loc) · 2.18 KB
/
Copy pathserver.js
File metadata and controls
57 lines (44 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
'use strict';
const { config } = require('./src/config');
const { loadGcpCredentialsMaybe, createStorageClient } = require('./src/clients/gcp');
const { createAnthropicClient } = require('./src/clients/anthropic');
const { createOpenAIClient } = require('./src/clients/openai');
const { createOctokit } = require('./src/clients/github');
const { createBrain } = require('./src/brain/brain');
const { createGmailClient } = require('./src/clients/gmail');
const { createCalendarClient } = require('./src/clients/calendar');
const { createTasksClient } = require('./src/clients/tasks');
const { indexRepos } = require('./src/repo-index');
(async () => {
console.log('Starting Penny...');
const startTime = Date.now();
// Load GCP credentials if needed
loadGcpCredentialsMaybe();
// Create clients
const anthropic = createAnthropicClient(config.anthropic.apiKey);
const openai = createOpenAIClient(config.openai.apiKey);
const octokit = createOctokit(config.github.token);
const storage = createStorageClient(config.gcp.projectId);
// Create brain
const brain = createBrain({
storage,
bucket: config.gcp.brainBucket,
prefix: config.gcp.brainPrefix,
});
// Create Gmail client
const gmail = createGmailClient(config.gmail);
// Create Calendar client (reuses Gmail OAuth2 creds)
const calendar = createCalendarClient(config.gmail);
// Create Tasks client (reuses Gmail OAuth2 creds + optional default list)
const tasksClient = createTasksClient({ ...config.gmail, defaultListId: config.tasks?.listId });
const deps = { config, anthropic, openai, octokit, storage, brain, gmail, calendar, tasks: tasksClient };
const { startTelegramApp } = require('./src/telegram');
await startTelegramApp(deps);
// Start roundup scheduler (background)
const { startRoundupScheduler } = require('./src/roundup');
startRoundupScheduler(deps);
console.log(`Penny started in ${Date.now() - startTime}ms`);
// Index repos in background (don't block startup)
const repoList = (process.env.OPENCLAW_REPOS || '').split(',').map(s => s.trim()).filter(Boolean);
indexRepos({ octokit, brain, repos: repoList }).catch(e => console.error('Repo index error:', e?.message || e));
})();