AI tracker: /trackers/ai with public news, owner-only bots and usage; ai schema (news_items, bot_status, usage_entries); idempotent import scripts; preflight ai grants check
Some checks failed
Deploy production / deploy (push) Has been cancelled
Some checks failed
Deploy production / deploy (push) Has been cancelled
This commit is contained in:
14
src/routes/trackers/ai/bots/+page.server.ts
Normal file
14
src/routes/trackers/ai/bots/+page.server.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { requireOwner } from '#lib/server/owner.js';
|
||||
import { loadBots } from '#lib/server/ai-tracker.js';
|
||||
import type { PageServerLoad } from './$types';
|
||||
|
||||
// Owner only: one row per Grok Bot agent, short summaries written by Daisy (no transcripts).
|
||||
export const load: PageServerLoad = async (event) => {
|
||||
requireOwner(event);
|
||||
event.setHeaders({ 'cache-control': 'private, no-store' });
|
||||
return {
|
||||
bots: await loadBots(),
|
||||
now: Date.now(),
|
||||
seo: { title: 'AI tracker · bots', description: 'My bots.', index: false }
|
||||
};
|
||||
};
|
||||
127
src/routes/trackers/ai/bots/+page.svelte
Normal file
127
src/routes/trackers/ai/bots/+page.svelte
Normal file
@@ -0,0 +1,127 @@
|
||||
<script lang="ts">
|
||||
import { relativeTime } from '#lib/relative-time.js';
|
||||
import Bot from 'lucide-svelte/icons/bot';
|
||||
|
||||
let { data } = $props();
|
||||
|
||||
// Stable accent per bot name, so each row gets its own colourful avatar.
|
||||
const HUES = [
|
||||
['#60a5fa', '#2563eb'],
|
||||
['#f472b6', '#db2777'],
|
||||
['#34d399', '#059669'],
|
||||
['#fb923c', '#ea580c'],
|
||||
['#a78bfa', '#7c3aed'],
|
||||
['#22d3ee', '#0891b2'],
|
||||
['#facc15', '#ca8a04'],
|
||||
['#f87171', '#dc2626']
|
||||
];
|
||||
const hue = (name: string) => {
|
||||
let h = 0;
|
||||
for (const ch of name) h = (h * 31 + ch.charCodeAt(0)) >>> 0;
|
||||
return HUES[h % HUES.length];
|
||||
};
|
||||
const stamp = (iso: string) =>
|
||||
new Date(iso).toLocaleString('en-GB', {
|
||||
day: 'numeric',
|
||||
month: 'short',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
timeZone: 'Europe/Amsterdam'
|
||||
});
|
||||
</script>
|
||||
|
||||
{#if !data.bots.length}
|
||||
<p class="empty">No bots yet. Daisy fills this from short daily summaries.</p>
|
||||
{:else}
|
||||
<p class="meta">{data.bots.length} bots · summaries only, never transcripts</p>
|
||||
<ul class="bots">
|
||||
{#each data.bots as bot (bot.name)}
|
||||
{@const [from, to] = hue(bot.name)}
|
||||
<li class="bot">
|
||||
<span class="avatar" style:--from={from} style:--to={to}><Bot size={16} /></span>
|
||||
<div class="body">
|
||||
<div class="top">
|
||||
<h2>{bot.name}</h2>
|
||||
{#if bot.lastActive}
|
||||
<time datetime={bot.lastActive} title={`${stamp(bot.lastActive)} (Amsterdam)`}
|
||||
>{relativeTime(bot.lastActive, data.now)}</time
|
||||
>
|
||||
{/if}
|
||||
</div>
|
||||
{#if bot.focus}<p class="focus">{bot.focus}</p>{/if}
|
||||
{#if bot.recent}<p class="recent">{bot.recent}</p>{/if}
|
||||
</div>
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.empty,
|
||||
.meta {
|
||||
color: var(--site-muted);
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
.empty {
|
||||
padding: 2rem 0;
|
||||
}
|
||||
.bots {
|
||||
display: grid;
|
||||
gap: 0.5rem;
|
||||
grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr));
|
||||
}
|
||||
.bot {
|
||||
display: flex;
|
||||
gap: 0.7rem;
|
||||
padding: 0.75rem 0.85rem;
|
||||
border: 1px solid var(--site-border);
|
||||
border-radius: 0.75rem;
|
||||
background: var(--site-surface);
|
||||
transition: border-color 0.15s;
|
||||
}
|
||||
.bot:hover {
|
||||
border-color: var(--site-muted);
|
||||
}
|
||||
.avatar {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
border-radius: 0.6rem;
|
||||
color: #fff;
|
||||
background: linear-gradient(135deg, var(--from), var(--to));
|
||||
}
|
||||
.body {
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.2rem;
|
||||
}
|
||||
.top {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: baseline;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
h2 {
|
||||
font-weight: 600;
|
||||
font-size: 0.95rem;
|
||||
}
|
||||
time {
|
||||
font-size: 0.72rem;
|
||||
color: var(--site-muted);
|
||||
white-space: nowrap;
|
||||
}
|
||||
.focus {
|
||||
font-size: 0.85rem;
|
||||
line-height: 1.35;
|
||||
}
|
||||
.recent {
|
||||
font-size: 0.8rem;
|
||||
color: var(--site-muted);
|
||||
line-height: 1.35;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user