Phase 2: AI Chat, Calendar, Odoo connector, PWA

- AI Chat endpoint (/api/v1/chat) with Claude API context
- Calendar page with FullCalendar.js (day/week/month)
- Odoo API connector (import/export/webhook)
- PWA manifest + service worker for offline
- SW register component

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Claude CLI Agent
2026-03-29 10:12:53 +00:00
parent b5a6dd6d6f
commit 55993b70b2
16 changed files with 402 additions and 24 deletions

36
api/src/routes/chat.js Normal file
View File

@@ -0,0 +1,36 @@
// Task Team — AI Chat Agent — 2026-03-29
const Anthropic = require('@anthropic-ai/sdk');
async function chatRoutes(app) {
const anthropic = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY });
app.post('/chat', async (req, reply) => {
const { message, context } = req.body;
if (!message) {
reply.code(400);
return { error: 'Message is required' };
}
// Get user's tasks and groups for context
const { rows: tasks } = await app.db.query(
'SELECT title, status, priority, scheduled_at FROM tasks ORDER BY created_at DESC LIMIT 20'
);
const { rows: groups } = await app.db.query('SELECT name, color FROM task_groups ORDER BY order_index');
const systemPrompt = `Jsi Task Team AI asistent. Pomáháš uživateli s organizací úkolů, plánováním a cíli.
Aktuální úkoly: ${JSON.stringify(tasks.map(t => ({title: t.title, status: t.status, priority: t.priority})))}
Skupiny: ${groups.map(g => g.name).join(', ')}
Odpovídej v češtině, stručně a prakticky. Pokud uživatel chce vytvořit úkol, navrhni strukturu.`;
const response = await anthropic.messages.create({
model: 'claude-sonnet-4-20250514',
max_tokens: 1024,
system: systemPrompt,
messages: [{ role: 'user', content: message }]
});
return { data: { reply: response.content[0].text, model: response.model } };
});
}
module.exports = chatRoutes;