bazilion 0.0.0
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/.understand-anything/.understandignore +25 -0
- package/.understand-anything/fingerprints.json +14267 -0
- package/.understand-anything/knowledge-graph.json +18128 -0
- package/.understand-anything/meta.json +6 -0
- package/CLAUDE.md +164 -0
- package/LICENSE +21 -0
- package/README.md +195 -0
- package/apps/cli/package.json +21 -0
- package/apps/cli/src/auth-file.ts +18 -0
- package/apps/cli/src/client.ts +37 -0
- package/apps/cli/src/columnize.ts +32 -0
- package/apps/cli/src/commands/agent.ts +574 -0
- package/apps/cli/src/commands/auth.ts +110 -0
- package/apps/cli/src/commands/backup.ts +135 -0
- package/apps/cli/src/commands/completion.ts +155 -0
- package/apps/cli/src/commands/config.ts +95 -0
- package/apps/cli/src/commands/doctor.ts +131 -0
- package/apps/cli/src/commands/group.ts +132 -0
- package/apps/cli/src/commands/inbox.ts +82 -0
- package/apps/cli/src/commands/login.ts +73 -0
- package/apps/cli/src/commands/memory.ts +106 -0
- package/apps/cli/src/commands/profile.ts +259 -0
- package/apps/cli/src/commands/provider.ts +170 -0
- package/apps/cli/src/commands/send.ts +24 -0
- package/apps/cli/src/commands/serve.ts +89 -0
- package/apps/cli/src/commands/skill.ts +120 -0
- package/apps/cli/src/commands/token.ts +148 -0
- package/apps/cli/src/commands/trigger.ts +129 -0
- package/apps/cli/src/commands/uninstall.ts +156 -0
- package/apps/cli/src/index.ts +196 -0
- package/apps/cli/src/paths.ts +12 -0
- package/apps/cli/test/agent.test.ts +213 -0
- package/apps/cli/test/backup.test.ts +95 -0
- package/apps/cli/test/chat.test.ts +539 -0
- package/apps/cli/test/columnize.test.ts +29 -0
- package/apps/cli/test/completion.test.ts +45 -0
- package/apps/cli/test/config-page.test.ts +151 -0
- package/apps/cli/test/group.test.ts +74 -0
- package/apps/cli/test/helpers.ts +70 -0
- package/apps/cli/test/inbox-autodeliver.test.ts +143 -0
- package/apps/cli/test/inbox.test.ts +147 -0
- package/apps/cli/test/memory.test.ts +69 -0
- package/apps/cli/test/profile.test.ts +110 -0
- package/apps/cli/test/send.test.ts +30 -0
- package/apps/cli/test/server-fixture.ts +212 -0
- package/apps/cli/test/session-head.test.ts +45 -0
- package/apps/cli/test/skill.test.ts +128 -0
- package/apps/cli/test/token.test.ts +109 -0
- package/apps/cli/test/trigger.test.ts +245 -0
- package/apps/cli/tsconfig.json +4 -0
- package/apps/daemon/package.json +31 -0
- package/apps/daemon/src/app.ts +41 -0
- package/apps/daemon/src/core/agent/archive.ts +8 -0
- package/apps/daemon/src/core/agent/delete.ts +30 -0
- package/apps/daemon/src/core/agent/resolve.ts +31 -0
- package/apps/daemon/src/core/agent/spawn.ts +95 -0
- package/apps/daemon/src/core/agent/unarchive.ts +11 -0
- package/apps/daemon/src/core/availableModels.ts +58 -0
- package/apps/daemon/src/core/db/client.ts +113 -0
- package/apps/daemon/src/core/db/migrate.ts +41 -0
- package/apps/daemon/src/core/db/migrations/0001_init.sql +179 -0
- package/apps/daemon/src/core/group/delete.ts +21 -0
- package/apps/daemon/src/core/group/register.ts +68 -0
- package/apps/daemon/src/core/index.ts +71 -0
- package/apps/daemon/src/core/paths.ts +56 -0
- package/apps/daemon/src/core/profile/create.ts +78 -0
- package/apps/daemon/src/core/profile/delete.ts +26 -0
- package/apps/daemon/src/core/profile/identity.ts +70 -0
- package/apps/daemon/src/core/profile/load.ts +45 -0
- package/apps/daemon/src/core/profile/seed.ts +74 -0
- package/apps/daemon/src/core/profile/templates.ts +60 -0
- package/apps/daemon/src/core/profile/update.ts +57 -0
- package/apps/daemon/src/core/profile/validate.ts +9 -0
- package/apps/daemon/src/core/repos/agents.ts +202 -0
- package/apps/daemon/src/core/repos/config.ts +78 -0
- package/apps/daemon/src/core/repos/groups.ts +55 -0
- package/apps/daemon/src/core/repos/messages.ts +127 -0
- package/apps/daemon/src/core/repos/profiles.ts +83 -0
- package/apps/daemon/src/core/repos/providerModels.ts +58 -0
- package/apps/daemon/src/core/repos/providerState.ts +37 -0
- package/apps/daemon/src/core/repos/secrets.ts +145 -0
- package/apps/daemon/src/core/repos/skillMeta.ts +49 -0
- package/apps/daemon/src/core/repos/triggers.ts +101 -0
- package/apps/daemon/src/core/repos/webTokens.ts +87 -0
- package/apps/daemon/src/core/secrets.ts +65 -0
- package/apps/daemon/src/core/services.ts +264 -0
- package/apps/daemon/src/core/skills/discover.ts +28 -0
- package/apps/daemon/src/core/skills/import.ts +136 -0
- package/apps/daemon/src/core/skills/parse.ts +52 -0
- package/apps/daemon/src/core/skills/resolve.ts +50 -0
- package/apps/daemon/src/index.ts +45 -0
- package/apps/daemon/src/lib/agent-cancel.ts +48 -0
- package/apps/daemon/src/lib/agent-id.ts +13 -0
- package/apps/daemon/src/lib/agent-turn.ts +56 -0
- package/apps/daemon/src/lib/api-key.ts +56 -0
- package/apps/daemon/src/lib/auth.ts +41 -0
- package/apps/daemon/src/lib/cron.ts +93 -0
- package/apps/daemon/src/lib/ctx.ts +80 -0
- package/apps/daemon/src/lib/messaging-host.ts +34 -0
- package/apps/daemon/src/lib/middleware-auth.ts +52 -0
- package/apps/daemon/src/lib/scheduler.ts +294 -0
- package/apps/daemon/src/routes/agents.ts +772 -0
- package/apps/daemon/src/routes/auth-login.ts +193 -0
- package/apps/daemon/src/routes/config.ts +267 -0
- package/apps/daemon/src/routes/groups.ts +133 -0
- package/apps/daemon/src/routes/messages.ts +29 -0
- package/apps/daemon/src/routes/misc.ts +239 -0
- package/apps/daemon/src/routes/profiles.ts +197 -0
- package/apps/daemon/src/routes/skills.ts +123 -0
- package/apps/daemon/src/routes/triggers.ts +29 -0
- package/apps/daemon/src/runtime/auth/openai-codex.ts +121 -0
- package/apps/daemon/src/runtime/auto-reply/heartbeat.ts +31 -0
- package/apps/daemon/src/runtime/index.ts +77 -0
- package/apps/daemon/src/runtime/memory/files.ts +103 -0
- package/apps/daemon/src/runtime/memory/qmd.ts +152 -0
- package/apps/daemon/src/runtime/memory/types.ts +16 -0
- package/apps/daemon/src/runtime/pi/events.ts +173 -0
- package/apps/daemon/src/runtime/pi/session.ts +536 -0
- package/apps/daemon/src/runtime/pi/tools.ts +85 -0
- package/apps/daemon/src/runtime/providers/catalog.ts +145 -0
- package/apps/daemon/src/runtime/providers/pi-adapter.ts +272 -0
- package/apps/daemon/src/runtime/providers/registry.ts +374 -0
- package/apps/daemon/src/runtime/providers/retry.ts +176 -0
- package/apps/daemon/src/runtime/providers/types.ts +33 -0
- package/apps/daemon/src/runtime/session/prompt.ts +83 -0
- package/apps/daemon/src/runtime/tools/bootstrap.ts +22 -0
- package/apps/daemon/src/runtime/tools/home.ts +114 -0
- package/apps/daemon/src/runtime/tools/memory.ts +81 -0
- package/apps/daemon/src/runtime/tools/messaging.ts +127 -0
- package/apps/daemon/src/runtime/tools/registry.ts +29 -0
- package/apps/daemon/src/runtime/tools/types.ts +13 -0
- package/apps/daemon/src/runtime/tools/web-extract.ts +110 -0
- package/apps/daemon/src/runtime/tools/web-ssrf.ts +245 -0
- package/apps/daemon/src/runtime/tools/web.ts +273 -0
- package/apps/daemon/src/runtime/worker/entry.ts +221 -0
- package/apps/daemon/src/runtime/worker/ipc-protocol.ts +75 -0
- package/apps/daemon/src/runtime/worker/spawn.ts +249 -0
- package/apps/daemon/test/core/agents.test.ts +319 -0
- package/apps/daemon/test/core/available-models.test.ts +63 -0
- package/apps/daemon/test/core/config.test.ts +99 -0
- package/apps/daemon/test/core/groups.test.ts +63 -0
- package/apps/daemon/test/core/helpers.ts +50 -0
- package/apps/daemon/test/core/identity.test.ts +85 -0
- package/apps/daemon/test/core/migrations.test.ts +83 -0
- package/apps/daemon/test/core/profiles.test.ts +182 -0
- package/apps/daemon/test/core/provider-models.test.ts +57 -0
- package/apps/daemon/test/core/provider-state.test.ts +36 -0
- package/apps/daemon/test/core/skill-meta.test.ts +45 -0
- package/apps/daemon/test/core/skills.test.ts +271 -0
- package/apps/daemon/test/core/triggers.test.ts +182 -0
- package/apps/daemon/test/core/web-tokens.test.ts +79 -0
- package/apps/daemon/test/cron.test.ts +90 -0
- package/apps/daemon/test/runtime/heartbeat.test.ts +34 -0
- package/apps/daemon/test/runtime/memory-qmd.test.ts +97 -0
- package/apps/daemon/test/runtime/memory.test.ts +78 -0
- package/apps/daemon/test/runtime/messaging.test.ts +213 -0
- package/apps/daemon/test/runtime/mock-server.ts +65 -0
- package/apps/daemon/test/runtime/openai-codex-auth.test.ts +116 -0
- package/apps/daemon/test/runtime/providers.test.ts +306 -0
- package/apps/daemon/test/runtime/retry.test.ts +191 -0
- package/apps/daemon/test/runtime/session-head.test.ts +90 -0
- package/apps/daemon/test/runtime/tools-home.test.ts +102 -0
- package/apps/daemon/test/runtime/tools-web.test.ts +206 -0
- package/apps/daemon/tsconfig.json +4 -0
- package/apps/mobile/README.md +60 -0
- package/apps/mobile/app/_layout.tsx +58 -0
- package/apps/mobile/app/agents/[id]/chat.tsx +486 -0
- package/apps/mobile/app/agents/[id]/index.tsx +166 -0
- package/apps/mobile/app/agents/index.tsx +212 -0
- package/apps/mobile/app/index.tsx +21 -0
- package/apps/mobile/app/pair.tsx +226 -0
- package/apps/mobile/app/settings.tsx +419 -0
- package/apps/mobile/app.json +49 -0
- package/apps/mobile/assets/adaptive-icon.png +0 -0
- package/apps/mobile/assets/favicon.png +0 -0
- package/apps/mobile/assets/icon.png +0 -0
- package/apps/mobile/assets/splash-icon.png +0 -0
- package/apps/mobile/babel.config.js +6 -0
- package/apps/mobile/metro.config.js +28 -0
- package/apps/mobile/package.json +44 -0
- package/apps/mobile/src/auth.ts +66 -0
- package/apps/mobile/src/pair-url.ts +48 -0
- package/apps/mobile/src/theme-context.tsx +88 -0
- package/apps/mobile/src/theme.ts +135 -0
- package/apps/mobile/test/pair-url.test.ts +46 -0
- package/apps/mobile/tsconfig.json +23 -0
- package/apps/web/components.json +25 -0
- package/apps/web/package.json +39 -0
- package/apps/web/public/baziu.svg +8 -0
- package/apps/web/src/components/AgentTabs.tsx +45 -0
- package/apps/web/src/components/BaziuLogo.tsx +21 -0
- package/apps/web/src/components/ChatPane.tsx +1033 -0
- package/apps/web/src/components/ConfigTabs.tsx +29 -0
- package/apps/web/src/components/CopyButton.tsx +68 -0
- package/apps/web/src/components/CreateGroupDialog.tsx +127 -0
- package/apps/web/src/components/FieldRow.tsx +94 -0
- package/apps/web/src/components/Footer.tsx +10 -0
- package/apps/web/src/components/PawIcon.tsx +15 -0
- package/apps/web/src/components/Sidebar.tsx +287 -0
- package/apps/web/src/components/SpawnDialog.tsx +129 -0
- package/apps/web/src/components/ThemeToggle.tsx +75 -0
- package/apps/web/src/components/TopNav.tsx +34 -0
- package/apps/web/src/components/ui/button.tsx +67 -0
- package/apps/web/src/components/ui/card.tsx +103 -0
- package/apps/web/src/components/ui/checkbox.tsx +31 -0
- package/apps/web/src/components/ui/dialog.tsx +168 -0
- package/apps/web/src/components/ui/input.tsx +19 -0
- package/apps/web/src/components/ui/label.tsx +22 -0
- package/apps/web/src/components/ui/radio-group.tsx +44 -0
- package/apps/web/src/components/ui/select.tsx +192 -0
- package/apps/web/src/components/ui/separator.tsx +26 -0
- package/apps/web/src/components/ui/table.tsx +116 -0
- package/apps/web/src/components/ui/tabs.tsx +88 -0
- package/apps/web/src/components/ui/textarea.tsx +18 -0
- package/apps/web/src/lib/auth.ts +50 -0
- package/apps/web/src/lib/daemon-client.ts +34 -0
- package/apps/web/src/lib/md.ts +45 -0
- package/apps/web/src/lib/utils.ts +6 -0
- package/apps/web/src/lib/wire-constants.ts +27 -0
- package/apps/web/src/routeTree.gen.ts +408 -0
- package/apps/web/src/router.tsx +20 -0
- package/apps/web/src/routes/__root.tsx +123 -0
- package/apps/web/src/routes/agents/$id/inbox.tsx +207 -0
- package/apps/web/src/routes/agents/$id/index.tsx +527 -0
- package/apps/web/src/routes/agents/$id/triggers.tsx +239 -0
- package/apps/web/src/routes/agents/index.tsx +265 -0
- package/apps/web/src/routes/api/$.ts +88 -0
- package/apps/web/src/routes/config/index.tsx +315 -0
- package/apps/web/src/routes/config/services.tsx +49 -0
- package/apps/web/src/routes/config/tokens.tsx +192 -0
- package/apps/web/src/routes/groups/$id/index.tsx +153 -0
- package/apps/web/src/routes/groups/$id/memory.tsx +321 -0
- package/apps/web/src/routes/groups/index.tsx +191 -0
- package/apps/web/src/routes/index.tsx +133 -0
- package/apps/web/src/routes/login.tsx +63 -0
- package/apps/web/src/routes/profiles/$id.tsx +549 -0
- package/apps/web/src/routes/profiles/index.tsx +458 -0
- package/apps/web/src/routes/skills/index.tsx +297 -0
- package/apps/web/src/routes/welcome.tsx +61 -0
- package/apps/web/src/styles.css +449 -0
- package/apps/web/tsconfig.json +25 -0
- package/apps/web/vite.config.ts +25 -0
- package/biome.json +23 -0
- package/docs/agent-engine.md +219 -0
- package/docs/architecture.md +627 -0
- package/docs/backlog/README.md +42 -0
- package/docs/backlog/draft/BAZ-001-a2a-federation-spike.md +125 -0
- package/docs/openclaw-reference.md +210 -0
- package/package.json +38 -0
- package/packages/api-types/package.json +11 -0
- package/packages/api-types/src/entities.ts +146 -0
- package/packages/api-types/src/events.ts +55 -0
- package/packages/api-types/src/index.ts +488 -0
- package/packages/api-types/src/memory.ts +15 -0
- package/packages/client/package.json +13 -0
- package/packages/client/src/index.ts +117 -0
- package/pnpm-workspace.yaml +3 -0
- package/tsconfig.base.json +23 -0
- package/tsconfig.json +11 -0
- package/vitest.config.ts +22 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { ApiClientError } from '@bazilion/client'
|
|
2
|
+
import type {
|
|
3
|
+
Agent,
|
|
4
|
+
ListInboxResponse,
|
|
5
|
+
Message,
|
|
6
|
+
ResolvedAgent,
|
|
7
|
+
} from '@bazilion/api-types'
|
|
8
|
+
import { createFileRoute, redirect } from '@tanstack/react-router'
|
|
9
|
+
import { createServerFn } from '@tanstack/react-start'
|
|
10
|
+
import { AgentTabs } from '../../../components/AgentTabs'
|
|
11
|
+
import { daemonClient } from '../../../lib/daemon-client'
|
|
12
|
+
|
|
13
|
+
interface InboxView {
|
|
14
|
+
resolved: ResolvedAgent
|
|
15
|
+
messages: Message[]
|
|
16
|
+
unreadCount: number
|
|
17
|
+
selected: Message | null
|
|
18
|
+
agentNames: Record<string, string>
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const fetchInbox = createServerFn({ method: 'POST' })
|
|
22
|
+
.inputValidator((d: { id: string; unreadOnly: boolean; selectedId: string }) => d)
|
|
23
|
+
.handler(async ({ data }): Promise<InboxView | null> => {
|
|
24
|
+
const c = daemonClient()
|
|
25
|
+
let resolved: ResolvedAgent
|
|
26
|
+
try {
|
|
27
|
+
resolved = await c.get<ResolvedAgent>(`/api/agents/${encodeURIComponent(data.id)}`)
|
|
28
|
+
} catch (err) {
|
|
29
|
+
if (err instanceof ApiClientError && err.status === 404) return null
|
|
30
|
+
throw err
|
|
31
|
+
}
|
|
32
|
+
const inboxQs = data.unreadOnly ? '?unread=1' : ''
|
|
33
|
+
const [list, unread, allAgents] = await Promise.all([
|
|
34
|
+
c.get<ListInboxResponse>(
|
|
35
|
+
`/api/agents/${encodeURIComponent(resolved.agent.id)}/messages${inboxQs}`,
|
|
36
|
+
),
|
|
37
|
+
c.get<ListInboxResponse>(
|
|
38
|
+
`/api/agents/${encodeURIComponent(resolved.agent.id)}/messages?unread=1`,
|
|
39
|
+
),
|
|
40
|
+
c.get<Agent[]>('/api/agents?includeArchived=true'),
|
|
41
|
+
])
|
|
42
|
+
let selected: Message | null = null
|
|
43
|
+
if (data.selectedId) {
|
|
44
|
+
try {
|
|
45
|
+
selected = await c.get<Message>(`/api/messages/${encodeURIComponent(data.selectedId)}`)
|
|
46
|
+
} catch (err) {
|
|
47
|
+
if (!(err instanceof ApiClientError) || err.status !== 404) throw err
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const agentNames: Record<string, string> = {}
|
|
51
|
+
for (const a of allAgents) agentNames[a.id] = a.name
|
|
52
|
+
return {
|
|
53
|
+
resolved,
|
|
54
|
+
messages: [...list.messages].reverse(),
|
|
55
|
+
unreadCount: unread.messages.length,
|
|
56
|
+
selected,
|
|
57
|
+
agentNames,
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
export const Route = createFileRoute('/agents/$id/inbox')({
|
|
62
|
+
validateSearch: (s: Record<string, unknown>): { unread?: '1'; id?: string } => ({
|
|
63
|
+
unread: s.unread === '1' ? '1' : undefined,
|
|
64
|
+
id: typeof s.id === 'string' ? s.id : undefined,
|
|
65
|
+
}),
|
|
66
|
+
loaderDeps: ({ search }) => ({
|
|
67
|
+
unreadOnly: search.unread === '1',
|
|
68
|
+
selectedId: search.id ?? '',
|
|
69
|
+
}),
|
|
70
|
+
loader: async ({ params, deps }) => {
|
|
71
|
+
const data = await fetchInbox({ data: { id: params.id, ...deps } })
|
|
72
|
+
if (!data) throw redirect({ to: '/agents' })
|
|
73
|
+
return data
|
|
74
|
+
},
|
|
75
|
+
component: InboxPage,
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
function decodeText(payload: string): string {
|
|
79
|
+
try {
|
|
80
|
+
const obj = JSON.parse(payload) as { text?: unknown }
|
|
81
|
+
if (typeof obj.text === 'string') return obj.text
|
|
82
|
+
} catch {}
|
|
83
|
+
return payload
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function InboxPage() {
|
|
87
|
+
const { resolved, messages, unreadCount, selected, agentNames } = Route.useLoaderData()
|
|
88
|
+
const search = Route.useSearch()
|
|
89
|
+
const unreadOnly = search.unread === '1'
|
|
90
|
+
const misaddressed = Boolean(selected && selected.toAgentId !== resolved.agent.id)
|
|
91
|
+
|
|
92
|
+
function agentLabel(aid: string): string {
|
|
93
|
+
const name = agentNames[aid]
|
|
94
|
+
return name ? `${name} (${aid.slice(0, 8)})` : aid.slice(0, 8)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<main className="mx-auto max-w-5xl px-6 py-8">
|
|
99
|
+
<h1 className="font-serif text-3xl text-foreground mb-1">{resolved.agent.name}</h1>
|
|
100
|
+
<p className="text-xs text-muted-foreground mb-6">
|
|
101
|
+
<code className="font-mono">{resolved.agent.id.slice(0, 8)}…</code> · unread: {unreadCount}
|
|
102
|
+
</p>
|
|
103
|
+
<AgentTabs
|
|
104
|
+
agentId={resolved.agent.id}
|
|
105
|
+
active="inbox"
|
|
106
|
+
archived={resolved.agent.status === 'archived'}
|
|
107
|
+
/>
|
|
108
|
+
|
|
109
|
+
<div className="grid grid-cols-1 md:grid-cols-[360px_1fr] gap-6">
|
|
110
|
+
<div>
|
|
111
|
+
<div className="flex gap-1 border-b mb-3">
|
|
112
|
+
<a
|
|
113
|
+
href={`/agents/${resolved.agent.id}/inbox`}
|
|
114
|
+
className={`px-3 py-1.5 text-sm border-b-2 -mb-px ${
|
|
115
|
+
!unreadOnly
|
|
116
|
+
? 'border-primary text-primary font-semibold'
|
|
117
|
+
: 'border-transparent text-muted-foreground'
|
|
118
|
+
}`}
|
|
119
|
+
>
|
|
120
|
+
all
|
|
121
|
+
</a>
|
|
122
|
+
<a
|
|
123
|
+
href={`/agents/${resolved.agent.id}/inbox?unread=1`}
|
|
124
|
+
className={`px-3 py-1.5 text-sm border-b-2 -mb-px ${
|
|
125
|
+
unreadOnly
|
|
126
|
+
? 'border-primary text-primary font-semibold'
|
|
127
|
+
: 'border-transparent text-muted-foreground'
|
|
128
|
+
}`}
|
|
129
|
+
>
|
|
130
|
+
unread
|
|
131
|
+
</a>
|
|
132
|
+
</div>
|
|
133
|
+
<div className="rounded-lg border bg-card max-h-[640px] overflow-y-auto">
|
|
134
|
+
{messages.length === 0 ? (
|
|
135
|
+
<div className="p-6 text-center text-muted-foreground italic">
|
|
136
|
+
{unreadOnly ? 'no unread messages' : 'inbox empty'}
|
|
137
|
+
</div>
|
|
138
|
+
) : (
|
|
139
|
+
messages.map((m) => {
|
|
140
|
+
const text = decodeText(m.payload)
|
|
141
|
+
const preview = text.length > 80 ? `${text.slice(0, 80)}…` : text
|
|
142
|
+
const when = new Date(m.createdAt).toLocaleString()
|
|
143
|
+
const isActive = selected?.id === m.id
|
|
144
|
+
const isUnread = m.readAt === null
|
|
145
|
+
const qs = unreadOnly ? `?unread=1&id=${m.id}` : `?id=${m.id}`
|
|
146
|
+
return (
|
|
147
|
+
<a
|
|
148
|
+
key={m.id}
|
|
149
|
+
href={`/agents/${resolved.agent.id}/inbox${qs}`}
|
|
150
|
+
className={`block border-b last:border-0 px-3 py-2 text-sm hover:bg-accent/30 ${
|
|
151
|
+
isActive ? 'bg-accent/40' : ''
|
|
152
|
+
} ${isUnread ? 'font-medium' : ''}`}
|
|
153
|
+
>
|
|
154
|
+
<div className="flex justify-between text-xs text-muted-foreground">
|
|
155
|
+
<span className="font-mono">
|
|
156
|
+
{isUnread && (
|
|
157
|
+
<span className="inline-block w-1.5 h-1.5 rounded-full bg-primary mr-1.5 align-middle" />
|
|
158
|
+
)}
|
|
159
|
+
from {agentLabel(m.fromAgentId)}
|
|
160
|
+
</span>
|
|
161
|
+
<span className="font-mono">{when}</span>
|
|
162
|
+
</div>
|
|
163
|
+
<div className="text-foreground mt-0.5 truncate">{preview}</div>
|
|
164
|
+
</a>
|
|
165
|
+
)
|
|
166
|
+
})
|
|
167
|
+
)}
|
|
168
|
+
</div>
|
|
169
|
+
</div>
|
|
170
|
+
|
|
171
|
+
<div>
|
|
172
|
+
{selected && !misaddressed && (
|
|
173
|
+
<div className="rounded-lg border bg-card p-5 mb-4">
|
|
174
|
+
<div className="font-mono text-xs text-muted-foreground mb-2 space-y-0.5">
|
|
175
|
+
<div>id: <code>{selected.id}</code></div>
|
|
176
|
+
<div>from: <code>{agentLabel(selected.fromAgentId)}</code></div>
|
|
177
|
+
<div>received: {new Date(selected.createdAt).toLocaleString()}</div>
|
|
178
|
+
<div>
|
|
179
|
+
read:{' '}
|
|
180
|
+
{selected.readAt ? new Date(selected.readAt).toLocaleString() : '(unread)'}
|
|
181
|
+
</div>
|
|
182
|
+
{selected.replyTo && (
|
|
183
|
+
<div>
|
|
184
|
+
reply to: <code>{selected.replyTo}</code>
|
|
185
|
+
</div>
|
|
186
|
+
)}
|
|
187
|
+
</div>
|
|
188
|
+
<div className="border-t pt-3 font-mono text-sm whitespace-pre-wrap break-words">
|
|
189
|
+
{decodeText(selected.payload)}
|
|
190
|
+
</div>
|
|
191
|
+
</div>
|
|
192
|
+
)}
|
|
193
|
+
{misaddressed && (
|
|
194
|
+
<div className="rounded-lg border bg-card p-5 mb-4 text-muted-foreground">
|
|
195
|
+
message is not addressed to this agent
|
|
196
|
+
</div>
|
|
197
|
+
)}
|
|
198
|
+
<p className="text-xs text-muted-foreground">
|
|
199
|
+
Agents exchange messages automatically via their{' '}
|
|
200
|
+
<code className="font-mono">send_message</code> tool. An idle recipient's scheduler
|
|
201
|
+
tick drains unread mail.
|
|
202
|
+
</p>
|
|
203
|
+
</div>
|
|
204
|
+
</div>
|
|
205
|
+
</main>
|
|
206
|
+
)
|
|
207
|
+
}
|