qarpeo 0.1.18 → 0.1.21
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/README.md +96 -96
- package/dist/chunks/auth-schema.mjs +3 -1
- package/dist/chunks/wrangler.mjs +22 -3
- package/dist/cli/index.mjs +448 -221
- package/dist/fate/index.d.ts +29 -22
- package/dist/fate/index.mjs +1 -3
- package/dist/module.d.ts +1 -1
- package/dist/module.mjs +103 -82
- package/dist/runtime/ai.d.ts +2 -2
- package/dist/runtime/app/components/BlobImage.vue +119 -107
- package/dist/runtime/app/components/CMSBlocks.vue +104 -93
- package/dist/runtime/app/components/CMSContent.vue +24 -23
- package/dist/runtime/app/components/CMSImage.vue +49 -49
- package/dist/runtime/app/components/CMSLocaleSwitcher.vue +110 -110
- package/dist/runtime/app/components/CMSPreviewBanner.vue +83 -79
- package/dist/runtime/app/components/CMSVersionBanner.vue +53 -49
- package/dist/runtime/app/components/CMSVersionSwitcher.vue +140 -140
- package/dist/runtime/app/components/ContentRenderer.vue +83 -80
- package/dist/runtime/app/components/FileUpload.vue +200 -196
- package/dist/runtime/app/components/ImpersonationBanner.vue +61 -57
- package/dist/runtime/app/components/QarpeoWelcome.vue +84 -84
- package/dist/runtime/app/components/SignedIn.vue +13 -13
- package/dist/runtime/app/components/SignedOut.vue +13 -13
- package/dist/runtime/app/components/shiki.css +34 -34
- package/dist/runtime/app/composables/ai.d.ts +22 -22
- package/dist/runtime/app/composables/ai.mjs +3 -7
- package/dist/runtime/app/composables/analytics.mjs +1 -1
- package/dist/runtime/app/composables/api-tokens.mjs +1 -1
- package/dist/runtime/app/composables/auth.d.ts +6 -7
- package/dist/runtime/app/composables/auth.mjs +6 -3
- package/dist/runtime/app/composables/chat.mjs +3 -7
- package/dist/runtime/app/composables/cms-preview.d.ts +3 -3
- package/dist/runtime/app/composables/cms-preview.mjs +1 -1
- package/dist/runtime/app/composables/cms.d.ts +3 -5
- package/dist/runtime/app/composables/cms.mjs +2 -2
- package/dist/runtime/app/composables/docs-version.d.ts +8 -7
- package/dist/runtime/app/composables/docs-version.mjs +3 -3
- package/dist/runtime/app/composables/impersonation.mjs +1 -1
- package/dist/runtime/app/composables/notifications.d.ts +5 -5
- package/dist/runtime/app/composables/notifications.mjs +4 -5
- package/dist/runtime/app/composables/organization.mjs +1 -1
- package/dist/runtime/app/composables/passkey.mjs +1 -1
- package/dist/runtime/app/composables/passwordless.mjs +1 -1
- package/dist/runtime/app/composables/payments.d.ts +2 -1
- package/dist/runtime/app/composables/payments.mjs +1 -1
- package/dist/runtime/app/composables/realtime.d.ts +13 -13
- package/dist/runtime/app/composables/realtime.mjs +2 -2
- package/dist/runtime/app/composables/resumable-upload.d.ts +11 -11
- package/dist/runtime/app/composables/resumable-upload.mjs +1 -1
- package/dist/runtime/app/composables/site.mjs +1 -1
- package/dist/runtime/app/composables/storage.d.ts +151 -11
- package/dist/runtime/app/composables/storage.mjs +291 -33
- package/dist/runtime/app/composables/turnstile.mjs +1 -1
- package/dist/runtime/app/composables/two-factor.mjs +1 -1
- package/dist/runtime/app/pages/devtools/agents.vue +716 -716
- package/dist/runtime/app/pages/devtools/analytics.vue +616 -616
- package/dist/runtime/app/pages/devtools/auth.vue +381 -350
- package/dist/runtime/app/pages/devtools/blob.vue +743 -744
- package/dist/runtime/app/pages/devtools/db.vue +545 -545
- package/dist/runtime/app/pages/devtools/domains.vue +771 -771
- package/dist/runtime/app/pages/devtools/kv.vue +827 -828
- package/dist/runtime/app/pages/devtools/logs.vue +649 -653
- package/dist/runtime/app/pages/devtools/mail.vue +388 -388
- package/dist/runtime/app/pages/devtools/overview.vue +391 -389
- package/dist/runtime/app/pages/devtools/realtime.vue +89 -27
- package/dist/runtime/app/pages/devtools/security.vue +20 -5
- package/dist/runtime/app/pages/devtools/settings.vue +559 -559
- package/dist/runtime/app/pages/devtools/tasks.vue +26 -10
- package/dist/runtime/app/pages/devtools.vue +176 -176
- package/dist/runtime/app/plugins/seo.mjs +1 -1
- package/dist/runtime/app/plugins/shortcuts.client.d.ts +1 -4
- package/dist/runtime/app/public/sw-notifications.mjs +47 -52
- package/dist/runtime/blob.mjs +11 -4
- package/dist/runtime/browser.d.ts +1 -1
- package/dist/runtime/browser.mjs +12 -2
- package/dist/runtime/cache.d.ts +2 -1
- package/dist/runtime/kv.mjs +4 -1
- package/dist/runtime/providers/qarpeo.d.ts +3 -3
- package/dist/runtime/server/durable-objects/agent.mjs +1 -1
- package/dist/runtime/server/durable-objects/room.d.ts +2 -2
- package/dist/runtime/server/durable-objects/room.mjs +5 -5
- package/dist/runtime/server/middleware/devtools.mjs +6 -2
- package/dist/runtime/server/plugins/cms.d.ts +4 -2
- package/dist/runtime/server/plugins/dev-proxy.mjs +1 -1
- package/dist/runtime/server/routes/__qarpeo/agents/chat.post.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/agents/chat.post.mjs +4 -1
- package/dist/runtime/server/routes/__qarpeo/analytics/events.get.d.ts +1 -4
- package/dist/runtime/server/routes/__qarpeo/analytics/summary.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/analytics/summary.get.mjs +5 -1
- package/dist/runtime/server/routes/__qarpeo/db/tables.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/db/tables.get.mjs +1 -1
- package/dist/runtime/server/routes/__qarpeo/logs.get.d.ts +4 -1
- package/dist/runtime/server/routes/__qarpeo/mail/track/click/[id].get.mjs +1 -1
- package/dist/runtime/server/routes/__qarpeo/mail/track/open/[id].get.mjs +2 -2
- package/dist/runtime/server/routes/__qarpeo/overview.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/realtime/broadcast.post.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/realtime/broadcast.post.mjs +1 -1
- package/dist/runtime/server/routes/__qarpeo/realtime/clear.post.d.ts +1 -4
- package/dist/runtime/server/routes/__qarpeo/realtime/clear.post.mjs +1 -1
- package/dist/runtime/server/routes/__qarpeo/realtime/disconnect.post.d.ts +1 -4
- package/dist/runtime/server/routes/__qarpeo/realtime/disconnect.post.mjs +1 -1
- package/dist/runtime/server/routes/__qarpeo/realtime/room.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/realtime/rooms.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/security/analytics.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/security/ban.post.d.ts +1 -4
- package/dist/runtime/server/routes/__qarpeo/security/clear.post.d.ts +1 -4
- package/dist/runtime/server/routes/__qarpeo/security/unban.post.d.ts +1 -4
- package/dist/runtime/server/routes/__qarpeo/settings.get.mjs +1 -1
- package/dist/runtime/server/routes/__qarpeo/tasks/run.post.mjs +3 -1
- package/dist/runtime/server/routes/agents/[agent]/chat.post.mjs +8 -2
- package/dist/runtime/server/routes/agents/[agent]/clear.post.mjs +8 -2
- package/dist/runtime/server/routes/agents/[agent]/history.get.mjs +8 -2
- package/dist/runtime/server/routes/ai/embed.post.d.ts +1 -4
- package/dist/runtime/server/routes/ai/search.post.d.ts +2 -2
- package/dist/runtime/server/routes/auth/account.delete.mjs +1 -1
- package/dist/runtime/server/routes/auth/handler.mjs +6 -1
- package/dist/runtime/server/routes/auth/magic-link/verify.get.mjs +1 -1
- package/dist/runtime/server/routes/auth/organization/members/[id].delete.mjs +7 -1
- package/dist/runtime/server/routes/auth/otp/verify.post.mjs +1 -1
- package/dist/runtime/server/routes/auth/sso/login.get.mjs +7 -1
- package/dist/runtime/server/routes/auth/sso/oidc/callback.get.mjs +8 -2
- package/dist/runtime/server/routes/auth/sso/saml/acs.post.mjs +7 -2
- package/dist/runtime/server/routes/auth/webauthn/login/options.post.mjs +1 -1
- package/dist/runtime/server/routes/auth/webauthn/login/verify.post.mjs +7 -2
- package/dist/runtime/server/routes/auth/webauthn/register/options.post.mjs +6 -1
- package/dist/runtime/server/routes/auth/webauthn/register/verify.post.mjs +6 -1
- package/dist/runtime/server/routes/browser/crawl.post.d.ts +1 -2
- package/dist/runtime/server/routes/browser/invoice.post.d.ts +1 -2
- package/dist/runtime/server/routes/browser/og-image.post.d.ts +2 -2
- package/dist/runtime/server/routes/browser/pdf.post.d.ts +1 -2
- package/dist/runtime/server/routes/browser/pdf.post.mjs +6 -1
- package/dist/runtime/server/routes/browser/screenshot.post.d.ts +2 -2
- package/dist/runtime/server/routes/browser/screenshot.post.mjs +5 -1
- package/dist/runtime/server/routes/cms/components/index.get.d.ts +2 -2
- package/dist/runtime/server/routes/cms/preview/disable.get.d.ts +4 -3
- package/dist/runtime/server/routes/cms/preview/enable.get.d.ts +8 -8
- package/dist/runtime/server/routes/cms/search.get.mjs +1 -1
- package/dist/runtime/server/routes/cms/webhooks/[provider].post.d.ts +7 -7
- package/dist/runtime/server/routes/cms/webhooks/[provider].post.mjs +9 -2
- package/dist/runtime/server/routes/docs/search.get.d.ts +9 -9
- package/dist/runtime/server/routes/fate.mjs +5 -8
- package/dist/runtime/server/routes/mail/bounce.post.d.ts +2 -2
- package/dist/runtime/server/routes/mail/unsubscribe.d.ts +2 -2
- package/dist/runtime/server/routes/mail/webhooks.post.d.ts +2 -2
- package/dist/runtime/server/routes/mail/webhooks.post.mjs +7 -1
- package/dist/runtime/server/routes/payments/usage.get.d.ts +8 -8
- package/dist/runtime/server/routes/payments/usage.post.d.ts +2 -2
- package/dist/runtime/server/routes/realtime/history.delete.d.ts +4 -3
- package/dist/runtime/server/routes/realtime/history.get.d.ts +7 -6
- package/dist/runtime/server/routes/realtime/ws.get.mjs +6 -1
- package/dist/runtime/server/routes/robots.txt.get.mjs +1 -1
- package/dist/runtime/server/routes/sitemap.xml.get.mjs +2 -1
- package/dist/runtime/server/routes/storage/multipart/abort.post.d.ts +2 -2
- package/dist/runtime/server/routes/storage/multipart/complete.post.d.ts +2 -2
- package/dist/runtime/server/routes/storage/multipart/complete.post.mjs +2 -2
- package/dist/runtime/server/routes/storage/multipart/create.post.d.ts +2 -2
- package/dist/runtime/server/routes/storage/multipart/create.post.mjs +7 -3
- package/dist/runtime/server/routes/storage/multipart/part.put.d.ts +2 -2
- package/dist/runtime/server/routes/storage/multipart/part.put.mjs +1 -1
- package/dist/runtime/server/routes/tenants/[tenant]/domains/[domain]/index.delete.mjs +2 -4
- package/dist/runtime/server/routes/tenants/[tenant]/domains/[domain]/verify.post.mjs +2 -4
- package/dist/runtime/server/routes/tenants/[tenant]/domains/index.get.mjs +1 -1
- package/dist/runtime/server/routes/tenants/[tenant]/domains/index.post.mjs +2 -4
- package/dist/runtime/server/tasks/cms/publish.mjs +1 -1
- package/dist/runtime/server/utils/ai.d.ts +9 -9
- package/dist/runtime/server/utils/ai.mjs +3 -3
- package/dist/runtime/server/utils/auth.d.ts +12 -16
- package/dist/runtime/server/utils/auth.mjs +15 -9
- package/dist/runtime/server/utils/bots.mjs +21 -7
- package/dist/runtime/server/utils/browser-utils.d.ts +44 -41
- package/dist/runtime/server/utils/browser-utils.mjs +14 -4
- package/dist/runtime/server/utils/cache.d.ts +5 -5
- package/dist/runtime/server/utils/cms/common.d.ts +26 -0
- package/dist/runtime/server/utils/cms/common.mjs +68 -0
- package/dist/runtime/server/utils/cms/git.d.ts +24 -0
- package/dist/runtime/server/utils/cms/git.mjs +240 -0
- package/dist/runtime/server/utils/cms/markdown.d.ts +22 -0
- package/dist/runtime/server/utils/cms/markdown.mjs +92 -0
- package/dist/runtime/server/utils/cms/path.d.ts +51 -0
- package/dist/runtime/server/utils/cms/path.mjs +127 -0
- package/dist/runtime/server/utils/cms/search.d.ts +22 -0
- package/dist/runtime/server/utils/cms/search.mjs +221 -0
- package/dist/runtime/server/utils/cms-events.d.ts +1 -1
- package/dist/runtime/server/utils/cms-events.mjs +2 -2
- package/dist/runtime/server/utils/cms-filter.mjs +2 -2
- package/dist/runtime/server/utils/cms.d.ts +17 -149
- package/dist/runtime/server/utils/cms.mjs +52 -761
- package/dist/runtime/server/utils/config.d.ts +5 -4
- package/dist/runtime/server/utils/domains.mjs +7 -4
- package/dist/runtime/server/utils/email-templates.d.ts +10 -7
- package/dist/runtime/server/utils/email-templates.mjs +20 -5
- package/dist/runtime/server/utils/feed.d.ts +2 -2
- package/dist/runtime/server/utils/feed.mjs +3 -1
- package/dist/runtime/server/utils/mail-suppression.d.ts +8 -24
- package/dist/runtime/server/utils/mail-suppression.mjs +2 -2
- package/dist/runtime/server/utils/mail.d.ts +7 -8
- package/dist/runtime/server/utils/mail.mjs +17 -12
- package/dist/runtime/server/utils/multipart-store.d.ts +2 -2
- package/dist/runtime/server/utils/notifications.d.ts +9 -23
- package/dist/runtime/server/utils/organization.mjs +4 -12
- package/dist/runtime/server/utils/passwordless.mjs +1 -1
- package/dist/runtime/server/utils/payments.d.ts +2 -6
- package/dist/runtime/server/utils/payments.mjs +1 -1
- package/dist/runtime/server/utils/queue.d.ts +21 -31
- package/dist/runtime/server/utils/rag.d.ts +4 -4
- package/dist/runtime/server/utils/rag.mjs +8 -8
- package/dist/runtime/server/utils/realtime-store.d.ts +2 -2
- package/dist/runtime/server/utils/realtime.d.ts +26 -28
- package/dist/runtime/server/utils/scheduled-task.d.ts +1 -3
- package/dist/runtime/server/utils/security-store.d.ts +2 -2
- package/dist/runtime/server/utils/session.d.ts +9 -11
- package/dist/runtime/server/utils/sso.d.ts +9 -15
- package/dist/runtime/server/utils/sso.mjs +4 -8
- package/dist/runtime/server/utils/storage.d.ts +19 -2
- package/dist/runtime/server/utils/storage.mjs +36 -7
- package/dist/runtime/server/utils/tenant.mjs +3 -1
- package/dist/runtime/server/utils/turnstile.d.ts +3 -5
- package/dist/runtime/server/utils/vapid.d.ts +5 -8
- package/dist/runtime/server/utils/vapid.mjs +26 -13
- package/dist/runtime/service.d.ts +13 -13
- package/dist/runtime/service.mjs +4 -2
- package/dist/runtime/test-utils.d.ts +20 -30
- package/dist/runtime/test-utils.mjs +5 -4
- package/dist/runtime/types/auth-globals.d.ts +14 -14
- package/dist/runtime/types/imports.d.ts +82 -82
- package/dist/runtime/types/index.d.ts +2 -2
- package/dist/runtime/types/r2.d.ts +5 -0
- package/dist/runtime/types/service.d.ts +11 -18
- package/dist/types.d.ts +100 -107
- package/dist/utils/auth-schema.d.ts +2 -2
- package/dist/utils/cms-sources.d.ts +3 -3
- package/dist/utils/local-db.d.ts +3 -3
- package/dist/utils/notifications-schema.d.ts +1 -3
- package/dist/utils/pkg.d.ts +7 -0
- package/dist/utils/queue.d.ts +3 -3
- package/dist/utils/tasks.d.ts +3 -2
- package/package.json +11 -8
|
@@ -1,716 +1,716 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import { computed, nextTick, onMounted, ref, watch } from "vue"
|
|
5
|
-
|
|
6
|
-
const route = useRoute()
|
|
7
|
-
|
|
8
|
-
const {
|
|
9
|
-
data: agentsData,
|
|
10
|
-
status: agentsStatus,
|
|
11
|
-
pending: agentsPending,
|
|
12
|
-
execute: executeLoadAgents,
|
|
13
|
-
} = useFetch<any>("/_qarpeo/api/agents/list", {
|
|
14
|
-
immediate: false,
|
|
15
|
-
lazy: true,
|
|
16
|
-
default: () => ({ agents: [] }),
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
const agentsLoading = computed(
|
|
20
|
-
() => agentsPending.value || agentsStatus.value === "idle" || agentsStatus.value === "pending",
|
|
21
|
-
)
|
|
22
|
-
const agents = computed(() => agentsData.value?.agents || [])
|
|
23
|
-
const agentSearch = ref("")
|
|
24
|
-
|
|
25
|
-
const inputMessage = ref("")
|
|
26
|
-
const chatRunning = ref(false)
|
|
27
|
-
const historyLoading = ref(false)
|
|
28
|
-
const clearingChat = ref(false)
|
|
29
|
-
const showClearModal = ref(false)
|
|
30
|
-
const chatScrollRef = ref<HTMLElement | null>(null)
|
|
31
|
-
|
|
32
|
-
// Create Agent modal state
|
|
33
|
-
const showCreateModal = ref(false)
|
|
34
|
-
const creatingAgent = ref(false)
|
|
35
|
-
const newAgentName = ref("")
|
|
36
|
-
const newAgentDesc = ref("")
|
|
37
|
-
const newAgentModel = ref("@cf/meta/llama-3.3-70b-instruct")
|
|
38
|
-
const newAgentSystem = ref(
|
|
39
|
-
"You are an autonomous AI agent running on Cloudflare Workers edge runtime.",
|
|
40
|
-
)
|
|
41
|
-
const newAgentTools = ref("searchDocs, fetchContext")
|
|
42
|
-
|
|
43
|
-
// Model options
|
|
44
|
-
const availableModels = [
|
|
45
|
-
{ label: "Llama 3.3 70B (Recommended)", value: "@cf/meta/llama-3.3-70b-instruct" },
|
|
46
|
-
{ label: "Llama 3.1 8B (Fast / Lightweight)", value: "@cf/meta/llama-3.1-8b-instruct" },
|
|
47
|
-
{ label: "Mistral 7B Instruct v0.2", value: "@cf/mistral/mistral-7b-instruct-v0.2" },
|
|
48
|
-
{ label: "Qwen 2.5 Coder 32B (Coding)", value: "@cf/qwen/qwen2.5-coder-32b-instruct" },
|
|
49
|
-
]
|
|
50
|
-
|
|
51
|
-
const selectedModelOverride = ref("")
|
|
52
|
-
|
|
53
|
-
// Copy feedback state
|
|
54
|
-
const copiedMsgIndex = ref<number | null>(null)
|
|
55
|
-
|
|
56
|
-
interface ChatMessage {
|
|
57
|
-
id?: string
|
|
58
|
-
role: "user" | "assistant" | "system"
|
|
59
|
-
content: string
|
|
60
|
-
timestamp?: string
|
|
61
|
-
model?: string
|
|
62
|
-
latencyMs?: number
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const messages = ref<ChatMessage[]>([])
|
|
66
|
-
|
|
67
|
-
// selectedAgentId is derived from the ?agent= query param
|
|
68
|
-
const selectedAgentId = computed({
|
|
69
|
-
get: () => (route.query.agent as string) || (agents.value[0]?.id ?? null),
|
|
70
|
-
set: (val: string | null) => {
|
|
71
|
-
navigateTo({ query: { ...route.query, agent: val ?? undefined } })
|
|
72
|
-
},
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
const selectedAgent = computed(
|
|
76
|
-
() => agents.value.find((a) => a.id === selectedAgentId.value) || null,
|
|
77
|
-
)
|
|
78
|
-
|
|
79
|
-
const defaultPrompts = [
|
|
80
|
-
"Hello! What can you help me with?",
|
|
81
|
-
"What tools and context do you have access to?",
|
|
82
|
-
"Give me an example of an edge agent query in Qarpeo.",
|
|
83
|
-
]
|
|
84
|
-
|
|
85
|
-
const filteredAgents = computed(() => {
|
|
86
|
-
if (!agentSearch.value.trim()) return agents.value
|
|
87
|
-
const q = agentSearch.value.toLowerCase()
|
|
88
|
-
return agents.value.filter(
|
|
89
|
-
(a) =>
|
|
90
|
-
a.name?.toLowerCase().includes(q) ||
|
|
91
|
-
a.id?.toLowerCase().includes(q) ||
|
|
92
|
-
a.description?.toLowerCase().includes(q),
|
|
93
|
-
)
|
|
94
|
-
})
|
|
95
|
-
|
|
96
|
-
const agentNavItems = computed<NavigationMenuItem[]>(() =>
|
|
97
|
-
filteredAgents.value.map((a) => ({
|
|
98
|
-
label: a.name || a.id,
|
|
99
|
-
icon: "i-lucide-bot",
|
|
100
|
-
value: a.id,
|
|
101
|
-
badge: {
|
|
102
|
-
label: a.status || "idle",
|
|
103
|
-
size: "xs" as const,
|
|
104
|
-
color: a.status === "busy" ? ("warning" as const) : ("success" as const),
|
|
105
|
-
variant: "subtle" as const,
|
|
106
|
-
},
|
|
107
|
-
class: "text-xs",
|
|
108
|
-
to: { query: { ...route.query, agent: a.id } },
|
|
109
|
-
active: selectedAgentId.value === a.id,
|
|
110
|
-
})),
|
|
111
|
-
)
|
|
112
|
-
|
|
113
|
-
function scrollToBottom() {
|
|
114
|
-
nextTick(() => {
|
|
115
|
-
if (chatScrollRef.value) {
|
|
116
|
-
chatScrollRef.value.scrollTop = chatScrollRef.value.scrollHeight
|
|
117
|
-
}
|
|
118
|
-
})
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
async function loadAgents() {
|
|
122
|
-
await executeLoadAgents()
|
|
123
|
-
if (selectedAgentId.value) {
|
|
124
|
-
loadHistory(selectedAgentId.value)
|
|
125
|
-
} else if (agents.value[0]?.id) {
|
|
126
|
-
selectedAgentId.value = agents.value[0].id
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
async function loadHistory(agentId: string | null) {
|
|
131
|
-
if (!agentId) {
|
|
132
|
-
messages.value = []
|
|
133
|
-
return
|
|
134
|
-
}
|
|
135
|
-
historyLoading.value = true
|
|
136
|
-
try {
|
|
137
|
-
const res = await $fetch<any>("/_qarpeo/api/agents/history", {
|
|
138
|
-
query: { agent: agentId },
|
|
139
|
-
}).catch(() => null)
|
|
140
|
-
|
|
141
|
-
if (res?.messages && Array.isArray(res.messages)) {
|
|
142
|
-
messages.value = res.messages.map((m: any) => ({
|
|
143
|
-
id: m.id,
|
|
144
|
-
role: m.role || "assistant",
|
|
145
|
-
content: m.content || m.text || "",
|
|
146
|
-
model: m.model,
|
|
147
|
-
latencyMs: m.latencyMs,
|
|
148
|
-
timestamp: m.timestamp
|
|
149
|
-
? new Date(m.timestamp).toLocaleTimeString([], {
|
|
150
|
-
hour: "2-digit",
|
|
151
|
-
minute: "2-digit",
|
|
152
|
-
})
|
|
153
|
-
: undefined,
|
|
154
|
-
}))
|
|
155
|
-
} else {
|
|
156
|
-
messages.value = []
|
|
157
|
-
}
|
|
158
|
-
} finally {
|
|
159
|
-
historyLoading.value = false
|
|
160
|
-
scrollToBottom()
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
watch(selectedAgentId, (newId) => {
|
|
165
|
-
if (newId) {
|
|
166
|
-
loadHistory(newId)
|
|
167
|
-
selectedModelOverride.value = ""
|
|
168
|
-
}
|
|
169
|
-
})
|
|
170
|
-
|
|
171
|
-
async function sendMessage() {
|
|
172
|
-
const text = inputMessage.value.trim()
|
|
173
|
-
const agentId = selectedAgentId.value
|
|
174
|
-
if (!text || !agentId || chatRunning.value) return
|
|
175
|
-
|
|
176
|
-
inputMessage.value = ""
|
|
177
|
-
messages.value.push({
|
|
178
|
-
role: "user",
|
|
179
|
-
content: text,
|
|
180
|
-
timestamp: new Date().toLocaleTimeString([], {
|
|
181
|
-
hour: "2-digit",
|
|
182
|
-
minute: "2-digit",
|
|
183
|
-
}),
|
|
184
|
-
})
|
|
185
|
-
scrollToBottom()
|
|
186
|
-
|
|
187
|
-
chatRunning.value = true
|
|
188
|
-
try {
|
|
189
|
-
const res = await $fetch<any>("/_qarpeo/api/agents/chat", {
|
|
190
|
-
method: "POST",
|
|
191
|
-
body: {
|
|
192
|
-
agent: agentId,
|
|
193
|
-
message: text,
|
|
194
|
-
model: selectedModelOverride.value || undefined,
|
|
195
|
-
},
|
|
196
|
-
})
|
|
197
|
-
|
|
198
|
-
messages.value.push({
|
|
199
|
-
id: res.id,
|
|
200
|
-
role: "assistant",
|
|
201
|
-
content: res.reply || res.message || "",
|
|
202
|
-
model: res.model,
|
|
203
|
-
latencyMs: res.latencyMs,
|
|
204
|
-
timestamp: new Date().toLocaleTimeString([], {
|
|
205
|
-
hour: "2-digit",
|
|
206
|
-
minute: "2-digit",
|
|
207
|
-
}),
|
|
208
|
-
})
|
|
209
|
-
} catch (err: any) {
|
|
210
|
-
messages.value.push({
|
|
211
|
-
role: "assistant",
|
|
212
|
-
content: `Error: ${err?.message || "Failed to reach agent"}`,
|
|
213
|
-
timestamp: new Date().toLocaleTimeString([], {
|
|
214
|
-
hour: "2-digit",
|
|
215
|
-
minute: "2-digit",
|
|
216
|
-
}),
|
|
217
|
-
})
|
|
218
|
-
} finally {
|
|
219
|
-
chatRunning.value = false
|
|
220
|
-
scrollToBottom()
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
async function handleClearConversation() {
|
|
225
|
-
const agentId = selectedAgentId.value
|
|
226
|
-
if (!agentId) return
|
|
227
|
-
clearingChat.value = true
|
|
228
|
-
try {
|
|
229
|
-
await $fetch("/_qarpeo/api/agents/clear", {
|
|
230
|
-
method: "POST",
|
|
231
|
-
body: { agent: agentId },
|
|
232
|
-
}).catch(() => {})
|
|
233
|
-
messages.value = []
|
|
234
|
-
showClearModal.value = false
|
|
235
|
-
} finally {
|
|
236
|
-
clearingChat.value = false
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
async function handleCreateAgent() {
|
|
241
|
-
if (!newAgentName.value.trim()) return
|
|
242
|
-
creatingAgent.value = true
|
|
243
|
-
try {
|
|
244
|
-
const tools = newAgentTools.value
|
|
245
|
-
.split(",")
|
|
246
|
-
.map((t) => t.trim())
|
|
247
|
-
.filter(Boolean)
|
|
248
|
-
|
|
249
|
-
const res = await $fetch<any>("/_qarpeo/api/agents/create", {
|
|
250
|
-
method: "POST",
|
|
251
|
-
body: {
|
|
252
|
-
name: newAgentName.value.trim(),
|
|
253
|
-
description: newAgentDesc.value.trim() || undefined,
|
|
254
|
-
model: newAgentModel.value,
|
|
255
|
-
systemPrompt: newAgentSystem.value.trim(),
|
|
256
|
-
tools,
|
|
257
|
-
},
|
|
258
|
-
})
|
|
259
|
-
|
|
260
|
-
showCreateModal.value = false
|
|
261
|
-
newAgentName.value = ""
|
|
262
|
-
newAgentDesc.value = ""
|
|
263
|
-
await loadAgents()
|
|
264
|
-
if (res?.agent?.id) {
|
|
265
|
-
selectedAgentId.value = res.agent.id
|
|
266
|
-
}
|
|
267
|
-
} catch (err) {
|
|
268
|
-
console.error("Create agent failed", err)
|
|
269
|
-
} finally {
|
|
270
|
-
creatingAgent.value = false
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
function copyMessageContent(content: string, index: number) {
|
|
275
|
-
if (typeof navigator !== "undefined") {
|
|
276
|
-
navigator.clipboard?.writeText(content)
|
|
277
|
-
copiedMsgIndex.value = index
|
|
278
|
-
setTimeout(() => {
|
|
279
|
-
copiedMsgIndex.value = null
|
|
280
|
-
}, 1500)
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
function selectPrompt(prompt: string) {
|
|
285
|
-
inputMessage.value = prompt
|
|
286
|
-
sendMessage()
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
onMounted(() => {
|
|
290
|
-
loadAgents()
|
|
291
|
-
})
|
|
292
|
-
</script>
|
|
293
|
-
|
|
294
|
-
<template>
|
|
295
|
-
<!-- ── Panel 1: Agent List ─────────────────────────────────────────── -->
|
|
296
|
-
<UDashboardPanel id="agents-list" :default-size="25" :min-size="20" :max-size="40" resizable>
|
|
297
|
-
<template #header>
|
|
298
|
-
<UDashboardNavbar>
|
|
299
|
-
<template #title>
|
|
300
|
-
<div class="flex items-center gap-2">
|
|
301
|
-
<UIcon name="i-lucide-bot" class="w-4 h-4 text-primary" />
|
|
302
|
-
<span class="font-bold text-sm text-highlighted">Edge Agents</span>
|
|
303
|
-
<UBadge size="xs" color="neutral" variant="subtle">
|
|
304
|
-
{{ filteredAgents.length }}
|
|
305
|
-
</UBadge>
|
|
306
|
-
</div>
|
|
307
|
-
</template>
|
|
308
|
-
<template #right>
|
|
309
|
-
<div class="flex items-center gap-1.5">
|
|
310
|
-
<UButton
|
|
311
|
-
icon="i-lucide-plus"
|
|
312
|
-
label="New Agent"
|
|
313
|
-
size="xs"
|
|
314
|
-
color="primary"
|
|
315
|
-
@click="showCreateModal = true"
|
|
316
|
-
/>
|
|
317
|
-
<UButton
|
|
318
|
-
icon="i-lucide-refresh-cw"
|
|
319
|
-
size="xs"
|
|
320
|
-
color="neutral"
|
|
321
|
-
variant="ghost"
|
|
322
|
-
title="Refresh agents"
|
|
323
|
-
:loading="agentsLoading"
|
|
324
|
-
@click="loadAgents"
|
|
325
|
-
/>
|
|
326
|
-
</div>
|
|
327
|
-
</template>
|
|
328
|
-
</UDashboardNavbar>
|
|
329
|
-
|
|
330
|
-
<UDashboardToolbar>
|
|
331
|
-
<UInput
|
|
332
|
-
v-model="agentSearch"
|
|
333
|
-
icon="i-lucide-search"
|
|
334
|
-
placeholder="Filter agents…"
|
|
335
|
-
class="w-full"
|
|
336
|
-
/>
|
|
337
|
-
</UDashboardToolbar>
|
|
338
|
-
</template>
|
|
339
|
-
|
|
340
|
-
<template #body>
|
|
341
|
-
<!-- Loading Skeleton/State -->
|
|
342
|
-
<div v-if="agentsLoading" class="p-3 space-y-2">
|
|
343
|
-
<div
|
|
344
|
-
v-for="i in 4"
|
|
345
|
-
:key="i"
|
|
346
|
-
class="h-8 rounded bg-muted/60 animate-pulse flex items-center justify-between px-3"
|
|
347
|
-
>
|
|
348
|
-
<div class="flex items-center gap-2">
|
|
349
|
-
<div class="h-3.5 w-3.5 rounded bg-muted/40"></div>
|
|
350
|
-
<div class="h-3 w-24 rounded bg-muted/40"></div>
|
|
351
|
-
</div>
|
|
352
|
-
<div class="h-3 w-8 rounded-full bg-muted/40"></div>
|
|
353
|
-
</div>
|
|
354
|
-
</div>
|
|
355
|
-
|
|
356
|
-
<template v-else>
|
|
357
|
-
<UNavigationMenu
|
|
358
|
-
v-model="selectedAgentId"
|
|
359
|
-
:items="agentNavItems"
|
|
360
|
-
orientation="vertical"
|
|
361
|
-
variant="pill"
|
|
362
|
-
/>
|
|
363
|
-
|
|
364
|
-
<div v-if="!filteredAgents.length" class="text-xs text-muted p-6 text-center">
|
|
365
|
-
No agents found
|
|
366
|
-
</div>
|
|
367
|
-
</template>
|
|
368
|
-
</template>
|
|
369
|
-
</UDashboardPanel>
|
|
370
|
-
|
|
371
|
-
<!-- ── Panel 2: Agent Chat Console ─────────────────────────────────── -->
|
|
372
|
-
<UDashboardPanel id="agent-chat" class="hidden lg:flex flex-1">
|
|
373
|
-
<template #header>
|
|
374
|
-
<UDashboardNavbar>
|
|
375
|
-
<template #title>
|
|
376
|
-
<div v-if="selectedAgent" class="flex items-center gap-2.5 min-w-0">
|
|
377
|
-
<div class="relative">
|
|
378
|
-
<UIcon name="i-lucide-bot" class="w-4 h-4 text-primary shrink-0" />
|
|
379
|
-
<span
|
|
380
|
-
class="absolute -top-0.5 -right-0.5 w-1.5 h-1.5 rounded-full"
|
|
381
|
-
:class="selectedAgent.status === 'busy' ? 'bg-warning' : 'bg-success'"
|
|
382
|
-
></span>
|
|
383
|
-
</div>
|
|
384
|
-
<span class="font-bold text-sm text-highlighted truncate">{{
|
|
385
|
-
selectedAgent.name || selectedAgent.id
|
|
386
|
-
}}</span>
|
|
387
|
-
<UBadge size="xs" color="neutral" variant="subtle">
|
|
388
|
-
{{ selectedAgent.id }}
|
|
389
|
-
</UBadge>
|
|
390
|
-
</div>
|
|
391
|
-
<span v-else class="text-sm font-semibold text-muted">Select an agent</span>
|
|
392
|
-
</template>
|
|
393
|
-
|
|
394
|
-
<template #right>
|
|
395
|
-
<div v-if="selectedAgent" class="flex items-center gap-2">
|
|
396
|
-
<!-- Model Selector Dropdown -->
|
|
397
|
-
<USelect
|
|
398
|
-
v-model="selectedModelOverride"
|
|
399
|
-
:items="[
|
|
400
|
-
{
|
|
401
|
-
label: `Default: ${selectedAgent.model?.split('/').pop() || 'Llama 3.3'}`,
|
|
402
|
-
value: '',
|
|
403
|
-
},
|
|
404
|
-
...availableModels,
|
|
405
|
-
]"
|
|
406
|
-
size="xs"
|
|
407
|
-
class="font-mono text-[11px]"
|
|
408
|
-
/>
|
|
409
|
-
|
|
410
|
-
<UButton
|
|
411
|
-
label="Clear Chat"
|
|
412
|
-
icon="i-lucide-trash"
|
|
413
|
-
size="xs"
|
|
414
|
-
color="error"
|
|
415
|
-
variant="subtle"
|
|
416
|
-
@click="showClearModal = true"
|
|
417
|
-
/>
|
|
418
|
-
<UButton
|
|
419
|
-
icon="i-lucide-refresh-cw"
|
|
420
|
-
size="xs"
|
|
421
|
-
color="neutral"
|
|
422
|
-
variant="ghost"
|
|
423
|
-
title="Refresh conversation"
|
|
424
|
-
:loading="historyLoading"
|
|
425
|
-
@click="loadHistory(selectedAgent.id)"
|
|
426
|
-
/>
|
|
427
|
-
</div>
|
|
428
|
-
</template>
|
|
429
|
-
</UDashboardNavbar>
|
|
430
|
-
</template>
|
|
431
|
-
|
|
432
|
-
<template #body>
|
|
433
|
-
<div v-if="selectedAgent" class="flex flex-col h-full overflow-hidden">
|
|
434
|
-
<!-- Messages Area -->
|
|
435
|
-
<div ref="chatScrollRef" class="flex-1 overflow-y-auto p-6 space-y-4">
|
|
436
|
-
<!-- Agent Info Header in Chat -->
|
|
437
|
-
<div class="p-4 bg-muted/30 border border-default rounded-lg text-xs space-y-2">
|
|
438
|
-
<div class="flex items-center justify-between">
|
|
439
|
-
<div class="flex items-center gap-2 font-semibold text-highlighted">
|
|
440
|
-
<UIcon name="i-lucide-sparkles" class="w-3.5 h-3.5 text-primary" />
|
|
441
|
-
{{ selectedAgent.name || selectedAgent.id }}
|
|
442
|
-
</div>
|
|
443
|
-
<UBadge size="xs" color="neutral" variant="subtle" class="font-mono">
|
|
444
|
-
{{ selectedAgent.model || "@cf/meta/llama-3.3-70b-instruct" }}
|
|
445
|
-
</UBadge>
|
|
446
|
-
</div>
|
|
447
|
-
<div class="text-muted">{{ selectedAgent.description }}</div>
|
|
448
|
-
<div
|
|
449
|
-
v-if="selectedAgent.systemPrompt"
|
|
450
|
-
class="bg-elevated/40 border border-default/60 rounded p-2 text-[11px] font-mono text-muted"
|
|
451
|
-
>
|
|
452
|
-
<span class="text-primary font-semibold">System:</span>
|
|
453
|
-
{{ selectedAgent.systemPrompt }}
|
|
454
|
-
</div>
|
|
455
|
-
</div>
|
|
456
|
-
|
|
457
|
-
<!-- Conversation Message List -->
|
|
458
|
-
<div v-if="messages.length" class="space-y-4">
|
|
459
|
-
<div
|
|
460
|
-
v-for="(msg, idx) in messages"
|
|
461
|
-
:key="idx"
|
|
462
|
-
class="flex gap-3 text-xs group"
|
|
463
|
-
:class="msg.role === 'user' ? 'justify-end' : 'justify-start'"
|
|
464
|
-
>
|
|
465
|
-
<!-- Agent Icon (if assistant) -->
|
|
466
|
-
<div
|
|
467
|
-
v-if="msg.role !== 'user'"
|
|
468
|
-
class="w-7 h-7 rounded-full bg-primary/10 border border-primary/20 flex items-center justify-center shrink-0 text-primary mt-0.5"
|
|
469
|
-
>
|
|
470
|
-
<UIcon name="i-lucide-bot" class="w-4 h-4" />
|
|
471
|
-
</div>
|
|
472
|
-
|
|
473
|
-
<!-- Bubble -->
|
|
474
|
-
<div
|
|
475
|
-
class="max-w-[75%] rounded-2xl p-3.5 space-y-1 relative"
|
|
476
|
-
:class="
|
|
477
|
-
msg.role === 'user'
|
|
478
|
-
? 'bg-primary text-inverted rounded-tr-xs'
|
|
479
|
-
: 'bg-elevated border border-default text-default rounded-tl-xs shadow-xs'
|
|
480
|
-
"
|
|
481
|
-
>
|
|
482
|
-
<div class="whitespace-pre-wrap break-words leading-relaxed">
|
|
483
|
-
{{ msg.content }}
|
|
484
|
-
</div>
|
|
485
|
-
<div
|
|
486
|
-
class="flex items-center justify-between gap-2 text-[10px] opacity-70 select-none pt-1"
|
|
487
|
-
>
|
|
488
|
-
<div class="flex items-center gap-1.5 font-mono">
|
|
489
|
-
<span v-if="msg.model" class="truncate max-w-[140px]">{{
|
|
490
|
-
msg.model.split("/").pop()
|
|
491
|
-
}}</span>
|
|
492
|
-
<span v-if="msg.latencyMs" class="text-primary font-semibold"
|
|
493
|
-
>{{ msg.latencyMs }}ms</span
|
|
494
|
-
>
|
|
495
|
-
</div>
|
|
496
|
-
<div class="flex items-center gap-1">
|
|
497
|
-
<UButton
|
|
498
|
-
:icon="copiedMsgIndex === idx ? 'i-lucide-check' : 'i-lucide-copy'"
|
|
499
|
-
:color="copiedMsgIndex === idx ? 'success' : 'neutral'"
|
|
500
|
-
variant="ghost"
|
|
501
|
-
size="xs"
|
|
502
|
-
title="Copy message"
|
|
503
|
-
class="opacity-0 group-hover:opacity-100 transition-opacity"
|
|
504
|
-
@click="copyMessageContent(msg.content, idx)"
|
|
505
|
-
/>
|
|
506
|
-
<span v-if="msg.timestamp">{{ msg.timestamp }}</span>
|
|
507
|
-
</div>
|
|
508
|
-
</div>
|
|
509
|
-
</div>
|
|
510
|
-
|
|
511
|
-
<!-- User Icon (if user) -->
|
|
512
|
-
<div
|
|
513
|
-
v-if="msg.role === 'user'"
|
|
514
|
-
class="w-7 h-7 rounded-full bg-muted border border-default flex items-center justify-center shrink-0 text-muted mt-0.5"
|
|
515
|
-
>
|
|
516
|
-
<UIcon name="i-lucide-user" class="w-4 h-4" />
|
|
517
|
-
</div>
|
|
518
|
-
</div>
|
|
519
|
-
</div>
|
|
520
|
-
|
|
521
|
-
<!-- Empty Conversation / Suggested Prompts -->
|
|
522
|
-
<div v-else-if="!historyLoading" class="py-8 text-center space-y-4">
|
|
523
|
-
<div
|
|
524
|
-
class="w-12 h-12 rounded-full bg-primary/10 border border-primary/20 flex items-center justify-center text-primary mx-auto"
|
|
525
|
-
>
|
|
526
|
-
<UIcon name="i-lucide-message-square" class="w-6 h-6" />
|
|
527
|
-
</div>
|
|
528
|
-
<div>
|
|
529
|
-
<div class="font-bold text-sm text-highlighted">No messages yet</div>
|
|
530
|
-
<div class="text-xs text-muted mt-1">
|
|
531
|
-
Start a live conversation with this edge agent below.
|
|
532
|
-
</div>
|
|
533
|
-
</div>
|
|
534
|
-
|
|
535
|
-
<div class="flex flex-wrap justify-center gap-2 max-w-md mx-auto pt-2">
|
|
536
|
-
<UButton
|
|
537
|
-
v-for="(p, i) in defaultPrompts"
|
|
538
|
-
:key="i"
|
|
539
|
-
:label="p"
|
|
540
|
-
size="xs"
|
|
541
|
-
color="neutral"
|
|
542
|
-
variant="subtle"
|
|
543
|
-
class="text-left"
|
|
544
|
-
@click="selectPrompt(p)"
|
|
545
|
-
/>
|
|
546
|
-
</div>
|
|
547
|
-
</div>
|
|
548
|
-
|
|
549
|
-
<!-- Typing / Running Indicator -->
|
|
550
|
-
<div v-if="chatRunning" class="flex items-center gap-3 text-xs">
|
|
551
|
-
<div
|
|
552
|
-
class="w-7 h-7 rounded-full bg-primary/10 border border-primary/20 flex items-center justify-center shrink-0 text-primary"
|
|
553
|
-
>
|
|
554
|
-
<UIcon name="i-lucide-bot" class="w-4 h-4" />
|
|
555
|
-
</div>
|
|
556
|
-
<div
|
|
557
|
-
class="bg-elevated border border-default rounded-2xl rounded-tl-xs px-4 py-2 text-muted flex items-center gap-2"
|
|
558
|
-
>
|
|
559
|
-
<UIcon name="i-lucide-loader-2" class="w-3.5 h-3.5 animate-spin text-primary" />
|
|
560
|
-
<span
|
|
561
|
-
>Thinking with
|
|
562
|
-
{{
|
|
563
|
-
selectedModelOverride.split("/").pop() ||
|
|
564
|
-
selectedAgent.model?.split("/").pop() ||
|
|
565
|
-
"Edge AI"
|
|
566
|
-
}}…</span
|
|
567
|
-
>
|
|
568
|
-
</div>
|
|
569
|
-
</div>
|
|
570
|
-
</div>
|
|
571
|
-
|
|
572
|
-
<!-- Chat Input Bar -->
|
|
573
|
-
<div class="p-3 border-t border-default bg-elevated/40">
|
|
574
|
-
<form class="flex items-center gap-2" @submit.prevent="sendMessage">
|
|
575
|
-
<UInput
|
|
576
|
-
v-model="inputMessage"
|
|
577
|
-
placeholder="Type a message… (Press Enter to send)"
|
|
578
|
-
class="flex-1 text-xs"
|
|
579
|
-
:disabled="chatRunning"
|
|
580
|
-
@keydown.enter.prevent="sendMessage"
|
|
581
|
-
/>
|
|
582
|
-
<UButton
|
|
583
|
-
type="submit"
|
|
584
|
-
icon="i-lucide-send"
|
|
585
|
-
color="primary"
|
|
586
|
-
size="sm"
|
|
587
|
-
:loading="chatRunning"
|
|
588
|
-
:disabled="!inputMessage.trim()"
|
|
589
|
-
/>
|
|
590
|
-
</form>
|
|
591
|
-
</div>
|
|
592
|
-
</div>
|
|
593
|
-
|
|
594
|
-
<div
|
|
595
|
-
v-else
|
|
596
|
-
class="flex-1 flex flex-col items-center justify-center text-muted text-xs p-12 text-center"
|
|
597
|
-
>
|
|
598
|
-
<UIcon name="i-lucide-bot" class="w-8 h-8 mb-2 opacity-50 text-muted" />
|
|
599
|
-
Select an agent from the list to start a conversation.
|
|
600
|
-
</div>
|
|
601
|
-
</template>
|
|
602
|
-
</UDashboardPanel>
|
|
603
|
-
|
|
604
|
-
<!-- Clear Conversation Modal -->
|
|
605
|
-
<UModal v-model:open="showClearModal" title="Clear Conversation">
|
|
606
|
-
<template #body>
|
|
607
|
-
<div class="space-y-3">
|
|
608
|
-
<p class="text-xs text-default">
|
|
609
|
-
Are you sure you want to clear conversation history for
|
|
610
|
-
<span class="font-bold text-highlighted">{{
|
|
611
|
-
selectedAgent?.name || selectedAgent?.id
|
|
612
|
-
}}</span
|
|
613
|
-
>?
|
|
614
|
-
</p>
|
|
615
|
-
<p class="text-xs text-muted">
|
|
616
|
-
All stored messages in this agent's stateful memory will be wiped.
|
|
617
|
-
</p>
|
|
618
|
-
</div>
|
|
619
|
-
</template>
|
|
620
|
-
<template #footer>
|
|
621
|
-
<div class="flex justify-end gap-2">
|
|
622
|
-
<UButton
|
|
623
|
-
label="Cancel"
|
|
624
|
-
color="neutral"
|
|
625
|
-
variant="ghost"
|
|
626
|
-
size="xs"
|
|
627
|
-
@click="showClearModal = false"
|
|
628
|
-
/>
|
|
629
|
-
<UButton
|
|
630
|
-
label="Clear History"
|
|
631
|
-
color="error"
|
|
632
|
-
size="xs"
|
|
633
|
-
icon="i-lucide-trash"
|
|
634
|
-
:loading="clearingChat"
|
|
635
|
-
@click="handleClearConversation"
|
|
636
|
-
/>
|
|
637
|
-
</div>
|
|
638
|
-
</template>
|
|
639
|
-
</UModal>
|
|
640
|
-
|
|
641
|
-
<!-- Create New Agent Modal -->
|
|
642
|
-
<UModal v-model:open="showCreateModal" title="Create Edge Agent">
|
|
643
|
-
<template #body>
|
|
644
|
-
<div class="space-y-3 text-xs">
|
|
645
|
-
<div>
|
|
646
|
-
<div class="text-muted mb-1 font-medium">Agent Name</div>
|
|
647
|
-
<UInput
|
|
648
|
-
v-model="newAgentName"
|
|
649
|
-
placeholder="e.g. Code Reviewer"
|
|
650
|
-
class="w-full font-sans"
|
|
651
|
-
/>
|
|
652
|
-
</div>
|
|
653
|
-
|
|
654
|
-
<div>
|
|
655
|
-
<div class="text-muted mb-1 font-medium">Description</div>
|
|
656
|
-
<UInput
|
|
657
|
-
v-model="newAgentDesc"
|
|
658
|
-
placeholder="Brief summary of agent role"
|
|
659
|
-
class="w-full font-sans"
|
|
660
|
-
/>
|
|
661
|
-
</div>
|
|
662
|
-
|
|
663
|
-
<div>
|
|
664
|
-
<div class="text-muted mb-1 font-medium">Model</div>
|
|
665
|
-
<USelect
|
|
666
|
-
v-model="newAgentModel"
|
|
667
|
-
:items="
|
|
668
|
-
availableModels.map((m) => ({ label: `${m.label} (${m.value})`, value: m.value }))
|
|
669
|
-
"
|
|
670
|
-
size="xs"
|
|
671
|
-
class="w-full font-mono text-xs"
|
|
672
|
-
/>
|
|
673
|
-
</div>
|
|
674
|
-
|
|
675
|
-
<div>
|
|
676
|
-
<div class="text-muted mb-1 font-medium">System Instructions</div>
|
|
677
|
-
<UTextarea
|
|
678
|
-
v-model="newAgentSystem"
|
|
679
|
-
placeholder="You are an autonomous AI agent..."
|
|
680
|
-
:rows="3"
|
|
681
|
-
class="w-full font-mono text-xs"
|
|
682
|
-
/>
|
|
683
|
-
</div>
|
|
684
|
-
|
|
685
|
-
<div>
|
|
686
|
-
<div class="text-muted mb-1 font-medium">Tools (Comma-separated)</div>
|
|
687
|
-
<UInput
|
|
688
|
-
v-model="newAgentTools"
|
|
689
|
-
placeholder="e.g. searchDocs, runQuery"
|
|
690
|
-
class="w-full font-mono text-xs"
|
|
691
|
-
/>
|
|
692
|
-
</div>
|
|
693
|
-
</div>
|
|
694
|
-
</template>
|
|
695
|
-
<template #footer>
|
|
696
|
-
<div class="flex justify-end gap-2">
|
|
697
|
-
<UButton
|
|
698
|
-
label="Cancel"
|
|
699
|
-
color="neutral"
|
|
700
|
-
variant="ghost"
|
|
701
|
-
size="xs"
|
|
702
|
-
@click="showCreateModal = false"
|
|
703
|
-
/>
|
|
704
|
-
<UButton
|
|
705
|
-
label="Create Agent"
|
|
706
|
-
color="primary"
|
|
707
|
-
size="xs"
|
|
708
|
-
icon="i-lucide-plus"
|
|
709
|
-
:loading="creatingAgent"
|
|
710
|
-
:disabled="!newAgentName.trim()"
|
|
711
|
-
@click="handleCreateAgent"
|
|
712
|
-
/>
|
|
713
|
-
</div>
|
|
714
|
-
</template>
|
|
715
|
-
</UModal>
|
|
716
|
-
</template>
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { NavigationMenuItem } from "@nuxt/ui"
|
|
3
|
+
import { useRoute, useFetch, navigateTo } from "nuxt/app"
|
|
4
|
+
import { computed, nextTick, onMounted, ref, watch } from "vue"
|
|
5
|
+
|
|
6
|
+
const route = useRoute()
|
|
7
|
+
|
|
8
|
+
const {
|
|
9
|
+
data: agentsData,
|
|
10
|
+
status: agentsStatus,
|
|
11
|
+
pending: agentsPending,
|
|
12
|
+
execute: executeLoadAgents,
|
|
13
|
+
} = useFetch<any>("/_qarpeo/api/agents/list", {
|
|
14
|
+
immediate: false,
|
|
15
|
+
lazy: true,
|
|
16
|
+
default: () => ({ agents: [] }),
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
const agentsLoading = computed(
|
|
20
|
+
() => agentsPending.value || agentsStatus.value === "idle" || agentsStatus.value === "pending",
|
|
21
|
+
)
|
|
22
|
+
const agents = computed(() => agentsData.value?.agents || [])
|
|
23
|
+
const agentSearch = ref("")
|
|
24
|
+
|
|
25
|
+
const inputMessage = ref("")
|
|
26
|
+
const chatRunning = ref(false)
|
|
27
|
+
const historyLoading = ref(false)
|
|
28
|
+
const clearingChat = ref(false)
|
|
29
|
+
const showClearModal = ref(false)
|
|
30
|
+
const chatScrollRef = ref<HTMLElement | null>(null)
|
|
31
|
+
|
|
32
|
+
// Create Agent modal state
|
|
33
|
+
const showCreateModal = ref(false)
|
|
34
|
+
const creatingAgent = ref(false)
|
|
35
|
+
const newAgentName = ref("")
|
|
36
|
+
const newAgentDesc = ref("")
|
|
37
|
+
const newAgentModel = ref("@cf/meta/llama-3.3-70b-instruct")
|
|
38
|
+
const newAgentSystem = ref(
|
|
39
|
+
"You are an autonomous AI agent running on Cloudflare Workers edge runtime.",
|
|
40
|
+
)
|
|
41
|
+
const newAgentTools = ref("searchDocs, fetchContext")
|
|
42
|
+
|
|
43
|
+
// Model options
|
|
44
|
+
const availableModels = [
|
|
45
|
+
{ label: "Llama 3.3 70B (Recommended)", value: "@cf/meta/llama-3.3-70b-instruct" },
|
|
46
|
+
{ label: "Llama 3.1 8B (Fast / Lightweight)", value: "@cf/meta/llama-3.1-8b-instruct" },
|
|
47
|
+
{ label: "Mistral 7B Instruct v0.2", value: "@cf/mistral/mistral-7b-instruct-v0.2" },
|
|
48
|
+
{ label: "Qwen 2.5 Coder 32B (Coding)", value: "@cf/qwen/qwen2.5-coder-32b-instruct" },
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
const selectedModelOverride = ref("")
|
|
52
|
+
|
|
53
|
+
// Copy feedback state
|
|
54
|
+
const copiedMsgIndex = ref<number | null>(null)
|
|
55
|
+
|
|
56
|
+
interface ChatMessage {
|
|
57
|
+
id?: string
|
|
58
|
+
role: "user" | "assistant" | "system"
|
|
59
|
+
content: string
|
|
60
|
+
timestamp?: string
|
|
61
|
+
model?: string
|
|
62
|
+
latencyMs?: number
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const messages = ref<ChatMessage[]>([])
|
|
66
|
+
|
|
67
|
+
// selectedAgentId is derived from the ?agent= query param
|
|
68
|
+
const selectedAgentId = computed({
|
|
69
|
+
get: () => (route.query.agent as string) || (agents.value[0]?.id ?? null),
|
|
70
|
+
set: (val: string | null) => {
|
|
71
|
+
navigateTo({ query: { ...route.query, agent: val ?? undefined } })
|
|
72
|
+
},
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
const selectedAgent = computed(
|
|
76
|
+
() => agents.value.find((a) => a.id === selectedAgentId.value) || null,
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
const defaultPrompts = [
|
|
80
|
+
"Hello! What can you help me with?",
|
|
81
|
+
"What tools and context do you have access to?",
|
|
82
|
+
"Give me an example of an edge agent query in Qarpeo.",
|
|
83
|
+
]
|
|
84
|
+
|
|
85
|
+
const filteredAgents = computed(() => {
|
|
86
|
+
if (!agentSearch.value.trim()) return agents.value
|
|
87
|
+
const q = agentSearch.value.toLowerCase()
|
|
88
|
+
return agents.value.filter(
|
|
89
|
+
(a) =>
|
|
90
|
+
a.name?.toLowerCase().includes(q) ||
|
|
91
|
+
a.id?.toLowerCase().includes(q) ||
|
|
92
|
+
a.description?.toLowerCase().includes(q),
|
|
93
|
+
)
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
const agentNavItems = computed<NavigationMenuItem[]>(() =>
|
|
97
|
+
filteredAgents.value.map((a) => ({
|
|
98
|
+
label: a.name || a.id,
|
|
99
|
+
icon: "i-lucide-bot",
|
|
100
|
+
value: a.id,
|
|
101
|
+
badge: {
|
|
102
|
+
label: a.status || "idle",
|
|
103
|
+
size: "xs" as const,
|
|
104
|
+
color: a.status === "busy" ? ("warning" as const) : ("success" as const),
|
|
105
|
+
variant: "subtle" as const,
|
|
106
|
+
},
|
|
107
|
+
class: "text-xs",
|
|
108
|
+
to: { query: { ...route.query, agent: a.id } },
|
|
109
|
+
active: selectedAgentId.value === a.id,
|
|
110
|
+
})),
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
function scrollToBottom() {
|
|
114
|
+
nextTick(() => {
|
|
115
|
+
if (chatScrollRef.value) {
|
|
116
|
+
chatScrollRef.value.scrollTop = chatScrollRef.value.scrollHeight
|
|
117
|
+
}
|
|
118
|
+
})
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
async function loadAgents() {
|
|
122
|
+
await executeLoadAgents()
|
|
123
|
+
if (selectedAgentId.value) {
|
|
124
|
+
loadHistory(selectedAgentId.value)
|
|
125
|
+
} else if (agents.value[0]?.id) {
|
|
126
|
+
selectedAgentId.value = agents.value[0].id
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
async function loadHistory(agentId: string | null) {
|
|
131
|
+
if (!agentId) {
|
|
132
|
+
messages.value = []
|
|
133
|
+
return
|
|
134
|
+
}
|
|
135
|
+
historyLoading.value = true
|
|
136
|
+
try {
|
|
137
|
+
const res = await $fetch<any>("/_qarpeo/api/agents/history", {
|
|
138
|
+
query: { agent: agentId },
|
|
139
|
+
}).catch(() => null)
|
|
140
|
+
|
|
141
|
+
if (res?.messages && Array.isArray(res.messages)) {
|
|
142
|
+
messages.value = res.messages.map((m: any) => ({
|
|
143
|
+
id: m.id,
|
|
144
|
+
role: m.role || "assistant",
|
|
145
|
+
content: m.content || m.text || "",
|
|
146
|
+
model: m.model,
|
|
147
|
+
latencyMs: m.latencyMs,
|
|
148
|
+
timestamp: m.timestamp
|
|
149
|
+
? new Date(m.timestamp).toLocaleTimeString([], {
|
|
150
|
+
hour: "2-digit",
|
|
151
|
+
minute: "2-digit",
|
|
152
|
+
})
|
|
153
|
+
: undefined,
|
|
154
|
+
}))
|
|
155
|
+
} else {
|
|
156
|
+
messages.value = []
|
|
157
|
+
}
|
|
158
|
+
} finally {
|
|
159
|
+
historyLoading.value = false
|
|
160
|
+
scrollToBottom()
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
watch(selectedAgentId, (newId) => {
|
|
165
|
+
if (newId) {
|
|
166
|
+
loadHistory(newId)
|
|
167
|
+
selectedModelOverride.value = ""
|
|
168
|
+
}
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
async function sendMessage() {
|
|
172
|
+
const text = inputMessage.value.trim()
|
|
173
|
+
const agentId = selectedAgentId.value
|
|
174
|
+
if (!text || !agentId || chatRunning.value) return
|
|
175
|
+
|
|
176
|
+
inputMessage.value = ""
|
|
177
|
+
messages.value.push({
|
|
178
|
+
role: "user",
|
|
179
|
+
content: text,
|
|
180
|
+
timestamp: new Date().toLocaleTimeString([], {
|
|
181
|
+
hour: "2-digit",
|
|
182
|
+
minute: "2-digit",
|
|
183
|
+
}),
|
|
184
|
+
})
|
|
185
|
+
scrollToBottom()
|
|
186
|
+
|
|
187
|
+
chatRunning.value = true
|
|
188
|
+
try {
|
|
189
|
+
const res = await $fetch<any>("/_qarpeo/api/agents/chat", {
|
|
190
|
+
method: "POST",
|
|
191
|
+
body: {
|
|
192
|
+
agent: agentId,
|
|
193
|
+
message: text,
|
|
194
|
+
model: selectedModelOverride.value || undefined,
|
|
195
|
+
},
|
|
196
|
+
})
|
|
197
|
+
|
|
198
|
+
messages.value.push({
|
|
199
|
+
id: res.id,
|
|
200
|
+
role: "assistant",
|
|
201
|
+
content: res.reply || res.message || "",
|
|
202
|
+
model: res.model,
|
|
203
|
+
latencyMs: res.latencyMs,
|
|
204
|
+
timestamp: new Date().toLocaleTimeString([], {
|
|
205
|
+
hour: "2-digit",
|
|
206
|
+
minute: "2-digit",
|
|
207
|
+
}),
|
|
208
|
+
})
|
|
209
|
+
} catch (err: any) {
|
|
210
|
+
messages.value.push({
|
|
211
|
+
role: "assistant",
|
|
212
|
+
content: `Error: ${err?.message || "Failed to reach agent"}`,
|
|
213
|
+
timestamp: new Date().toLocaleTimeString([], {
|
|
214
|
+
hour: "2-digit",
|
|
215
|
+
minute: "2-digit",
|
|
216
|
+
}),
|
|
217
|
+
})
|
|
218
|
+
} finally {
|
|
219
|
+
chatRunning.value = false
|
|
220
|
+
scrollToBottom()
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
async function handleClearConversation() {
|
|
225
|
+
const agentId = selectedAgentId.value
|
|
226
|
+
if (!agentId) return
|
|
227
|
+
clearingChat.value = true
|
|
228
|
+
try {
|
|
229
|
+
await $fetch("/_qarpeo/api/agents/clear", {
|
|
230
|
+
method: "POST",
|
|
231
|
+
body: { agent: agentId },
|
|
232
|
+
}).catch(() => {})
|
|
233
|
+
messages.value = []
|
|
234
|
+
showClearModal.value = false
|
|
235
|
+
} finally {
|
|
236
|
+
clearingChat.value = false
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
async function handleCreateAgent() {
|
|
241
|
+
if (!newAgentName.value.trim()) return
|
|
242
|
+
creatingAgent.value = true
|
|
243
|
+
try {
|
|
244
|
+
const tools = newAgentTools.value
|
|
245
|
+
.split(",")
|
|
246
|
+
.map((t) => t.trim())
|
|
247
|
+
.filter(Boolean)
|
|
248
|
+
|
|
249
|
+
const res = await $fetch<any>("/_qarpeo/api/agents/create", {
|
|
250
|
+
method: "POST",
|
|
251
|
+
body: {
|
|
252
|
+
name: newAgentName.value.trim(),
|
|
253
|
+
description: newAgentDesc.value.trim() || undefined,
|
|
254
|
+
model: newAgentModel.value,
|
|
255
|
+
systemPrompt: newAgentSystem.value.trim(),
|
|
256
|
+
tools,
|
|
257
|
+
},
|
|
258
|
+
})
|
|
259
|
+
|
|
260
|
+
showCreateModal.value = false
|
|
261
|
+
newAgentName.value = ""
|
|
262
|
+
newAgentDesc.value = ""
|
|
263
|
+
await loadAgents()
|
|
264
|
+
if (res?.agent?.id) {
|
|
265
|
+
selectedAgentId.value = res.agent.id
|
|
266
|
+
}
|
|
267
|
+
} catch (err) {
|
|
268
|
+
console.error("Create agent failed", err)
|
|
269
|
+
} finally {
|
|
270
|
+
creatingAgent.value = false
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function copyMessageContent(content: string, index: number) {
|
|
275
|
+
if (typeof navigator !== "undefined") {
|
|
276
|
+
navigator.clipboard?.writeText(content)
|
|
277
|
+
copiedMsgIndex.value = index
|
|
278
|
+
setTimeout(() => {
|
|
279
|
+
copiedMsgIndex.value = null
|
|
280
|
+
}, 1500)
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
function selectPrompt(prompt: string) {
|
|
285
|
+
inputMessage.value = prompt
|
|
286
|
+
sendMessage()
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
onMounted(() => {
|
|
290
|
+
loadAgents()
|
|
291
|
+
})
|
|
292
|
+
</script>
|
|
293
|
+
|
|
294
|
+
<template>
|
|
295
|
+
<!-- ── Panel 1: Agent List ─────────────────────────────────────────── -->
|
|
296
|
+
<UDashboardPanel id="agents-list" :default-size="25" :min-size="20" :max-size="40" resizable>
|
|
297
|
+
<template #header>
|
|
298
|
+
<UDashboardNavbar>
|
|
299
|
+
<template #title>
|
|
300
|
+
<div class="flex items-center gap-2">
|
|
301
|
+
<UIcon name="i-lucide-bot" class="w-4 h-4 text-primary" />
|
|
302
|
+
<span class="font-bold text-sm text-highlighted">Edge Agents</span>
|
|
303
|
+
<UBadge size="xs" color="neutral" variant="subtle">
|
|
304
|
+
{{ filteredAgents.length }}
|
|
305
|
+
</UBadge>
|
|
306
|
+
</div>
|
|
307
|
+
</template>
|
|
308
|
+
<template #right>
|
|
309
|
+
<div class="flex items-center gap-1.5">
|
|
310
|
+
<UButton
|
|
311
|
+
icon="i-lucide-plus"
|
|
312
|
+
label="New Agent"
|
|
313
|
+
size="xs"
|
|
314
|
+
color="primary"
|
|
315
|
+
@click="showCreateModal = true"
|
|
316
|
+
/>
|
|
317
|
+
<UButton
|
|
318
|
+
icon="i-lucide-refresh-cw"
|
|
319
|
+
size="xs"
|
|
320
|
+
color="neutral"
|
|
321
|
+
variant="ghost"
|
|
322
|
+
title="Refresh agents"
|
|
323
|
+
:loading="agentsLoading"
|
|
324
|
+
@click="loadAgents"
|
|
325
|
+
/>
|
|
326
|
+
</div>
|
|
327
|
+
</template>
|
|
328
|
+
</UDashboardNavbar>
|
|
329
|
+
|
|
330
|
+
<UDashboardToolbar>
|
|
331
|
+
<UInput
|
|
332
|
+
v-model="agentSearch"
|
|
333
|
+
icon="i-lucide-search"
|
|
334
|
+
placeholder="Filter agents…"
|
|
335
|
+
class="w-full"
|
|
336
|
+
/>
|
|
337
|
+
</UDashboardToolbar>
|
|
338
|
+
</template>
|
|
339
|
+
|
|
340
|
+
<template #body>
|
|
341
|
+
<!-- Loading Skeleton/State -->
|
|
342
|
+
<div v-if="agentsLoading" class="p-3 space-y-2">
|
|
343
|
+
<div
|
|
344
|
+
v-for="i in 4"
|
|
345
|
+
:key="i"
|
|
346
|
+
class="h-8 rounded bg-muted/60 animate-pulse flex items-center justify-between px-3"
|
|
347
|
+
>
|
|
348
|
+
<div class="flex items-center gap-2">
|
|
349
|
+
<div class="h-3.5 w-3.5 rounded bg-muted/40"></div>
|
|
350
|
+
<div class="h-3 w-24 rounded bg-muted/40"></div>
|
|
351
|
+
</div>
|
|
352
|
+
<div class="h-3 w-8 rounded-full bg-muted/40"></div>
|
|
353
|
+
</div>
|
|
354
|
+
</div>
|
|
355
|
+
|
|
356
|
+
<template v-else>
|
|
357
|
+
<UNavigationMenu
|
|
358
|
+
v-model="selectedAgentId"
|
|
359
|
+
:items="agentNavItems"
|
|
360
|
+
orientation="vertical"
|
|
361
|
+
variant="pill"
|
|
362
|
+
/>
|
|
363
|
+
|
|
364
|
+
<div v-if="!filteredAgents.length" class="text-xs text-muted p-6 text-center">
|
|
365
|
+
No agents found
|
|
366
|
+
</div>
|
|
367
|
+
</template>
|
|
368
|
+
</template>
|
|
369
|
+
</UDashboardPanel>
|
|
370
|
+
|
|
371
|
+
<!-- ── Panel 2: Agent Chat Console ─────────────────────────────────── -->
|
|
372
|
+
<UDashboardPanel id="agent-chat" class="hidden lg:flex flex-1">
|
|
373
|
+
<template #header>
|
|
374
|
+
<UDashboardNavbar>
|
|
375
|
+
<template #title>
|
|
376
|
+
<div v-if="selectedAgent" class="flex items-center gap-2.5 min-w-0">
|
|
377
|
+
<div class="relative">
|
|
378
|
+
<UIcon name="i-lucide-bot" class="w-4 h-4 text-primary shrink-0" />
|
|
379
|
+
<span
|
|
380
|
+
class="absolute -top-0.5 -right-0.5 w-1.5 h-1.5 rounded-full"
|
|
381
|
+
:class="selectedAgent.status === 'busy' ? 'bg-warning' : 'bg-success'"
|
|
382
|
+
></span>
|
|
383
|
+
</div>
|
|
384
|
+
<span class="font-bold text-sm text-highlighted truncate">{{
|
|
385
|
+
selectedAgent.name || selectedAgent.id
|
|
386
|
+
}}</span>
|
|
387
|
+
<UBadge size="xs" color="neutral" variant="subtle">
|
|
388
|
+
{{ selectedAgent.id }}
|
|
389
|
+
</UBadge>
|
|
390
|
+
</div>
|
|
391
|
+
<span v-else class="text-sm font-semibold text-muted">Select an agent</span>
|
|
392
|
+
</template>
|
|
393
|
+
|
|
394
|
+
<template #right>
|
|
395
|
+
<div v-if="selectedAgent" class="flex items-center gap-2">
|
|
396
|
+
<!-- Model Selector Dropdown -->
|
|
397
|
+
<USelect
|
|
398
|
+
v-model="selectedModelOverride"
|
|
399
|
+
:items="[
|
|
400
|
+
{
|
|
401
|
+
label: `Default: ${selectedAgent.model?.split('/').pop() || 'Llama 3.3'}`,
|
|
402
|
+
value: '',
|
|
403
|
+
},
|
|
404
|
+
...availableModels,
|
|
405
|
+
]"
|
|
406
|
+
size="xs"
|
|
407
|
+
class="font-mono text-[11px]"
|
|
408
|
+
/>
|
|
409
|
+
|
|
410
|
+
<UButton
|
|
411
|
+
label="Clear Chat"
|
|
412
|
+
icon="i-lucide-trash"
|
|
413
|
+
size="xs"
|
|
414
|
+
color="error"
|
|
415
|
+
variant="subtle"
|
|
416
|
+
@click="showClearModal = true"
|
|
417
|
+
/>
|
|
418
|
+
<UButton
|
|
419
|
+
icon="i-lucide-refresh-cw"
|
|
420
|
+
size="xs"
|
|
421
|
+
color="neutral"
|
|
422
|
+
variant="ghost"
|
|
423
|
+
title="Refresh conversation"
|
|
424
|
+
:loading="historyLoading"
|
|
425
|
+
@click="loadHistory(selectedAgent.id)"
|
|
426
|
+
/>
|
|
427
|
+
</div>
|
|
428
|
+
</template>
|
|
429
|
+
</UDashboardNavbar>
|
|
430
|
+
</template>
|
|
431
|
+
|
|
432
|
+
<template #body>
|
|
433
|
+
<div v-if="selectedAgent" class="flex flex-col h-full overflow-hidden">
|
|
434
|
+
<!-- Messages Area -->
|
|
435
|
+
<div ref="chatScrollRef" class="flex-1 overflow-y-auto p-6 space-y-4">
|
|
436
|
+
<!-- Agent Info Header in Chat -->
|
|
437
|
+
<div class="p-4 bg-muted/30 border border-default rounded-lg text-xs space-y-2">
|
|
438
|
+
<div class="flex items-center justify-between">
|
|
439
|
+
<div class="flex items-center gap-2 font-semibold text-highlighted">
|
|
440
|
+
<UIcon name="i-lucide-sparkles" class="w-3.5 h-3.5 text-primary" />
|
|
441
|
+
{{ selectedAgent.name || selectedAgent.id }}
|
|
442
|
+
</div>
|
|
443
|
+
<UBadge size="xs" color="neutral" variant="subtle" class="font-mono">
|
|
444
|
+
{{ selectedAgent.model || "@cf/meta/llama-3.3-70b-instruct" }}
|
|
445
|
+
</UBadge>
|
|
446
|
+
</div>
|
|
447
|
+
<div class="text-muted">{{ selectedAgent.description }}</div>
|
|
448
|
+
<div
|
|
449
|
+
v-if="selectedAgent.systemPrompt"
|
|
450
|
+
class="bg-elevated/40 border border-default/60 rounded p-2 text-[11px] font-mono text-muted"
|
|
451
|
+
>
|
|
452
|
+
<span class="text-primary font-semibold">System:</span>
|
|
453
|
+
{{ selectedAgent.systemPrompt }}
|
|
454
|
+
</div>
|
|
455
|
+
</div>
|
|
456
|
+
|
|
457
|
+
<!-- Conversation Message List -->
|
|
458
|
+
<div v-if="messages.length" class="space-y-4">
|
|
459
|
+
<div
|
|
460
|
+
v-for="(msg, idx) in messages"
|
|
461
|
+
:key="idx"
|
|
462
|
+
class="flex gap-3 text-xs group"
|
|
463
|
+
:class="msg.role === 'user' ? 'justify-end' : 'justify-start'"
|
|
464
|
+
>
|
|
465
|
+
<!-- Agent Icon (if assistant) -->
|
|
466
|
+
<div
|
|
467
|
+
v-if="msg.role !== 'user'"
|
|
468
|
+
class="w-7 h-7 rounded-full bg-primary/10 border border-primary/20 flex items-center justify-center shrink-0 text-primary mt-0.5"
|
|
469
|
+
>
|
|
470
|
+
<UIcon name="i-lucide-bot" class="w-4 h-4" />
|
|
471
|
+
</div>
|
|
472
|
+
|
|
473
|
+
<!-- Bubble -->
|
|
474
|
+
<div
|
|
475
|
+
class="max-w-[75%] rounded-2xl p-3.5 space-y-1 relative"
|
|
476
|
+
:class="
|
|
477
|
+
msg.role === 'user'
|
|
478
|
+
? 'bg-primary text-inverted rounded-tr-xs'
|
|
479
|
+
: 'bg-elevated border border-default text-default rounded-tl-xs shadow-xs'
|
|
480
|
+
"
|
|
481
|
+
>
|
|
482
|
+
<div class="whitespace-pre-wrap break-words leading-relaxed">
|
|
483
|
+
{{ msg.content }}
|
|
484
|
+
</div>
|
|
485
|
+
<div
|
|
486
|
+
class="flex items-center justify-between gap-2 text-[10px] opacity-70 select-none pt-1"
|
|
487
|
+
>
|
|
488
|
+
<div class="flex items-center gap-1.5 font-mono">
|
|
489
|
+
<span v-if="msg.model" class="truncate max-w-[140px]">{{
|
|
490
|
+
msg.model.split("/").pop()
|
|
491
|
+
}}</span>
|
|
492
|
+
<span v-if="msg.latencyMs" class="text-primary font-semibold"
|
|
493
|
+
>{{ msg.latencyMs }}ms</span
|
|
494
|
+
>
|
|
495
|
+
</div>
|
|
496
|
+
<div class="flex items-center gap-1">
|
|
497
|
+
<UButton
|
|
498
|
+
:icon="copiedMsgIndex === idx ? 'i-lucide-check' : 'i-lucide-copy'"
|
|
499
|
+
:color="copiedMsgIndex === idx ? 'success' : 'neutral'"
|
|
500
|
+
variant="ghost"
|
|
501
|
+
size="xs"
|
|
502
|
+
title="Copy message"
|
|
503
|
+
class="opacity-0 group-hover:opacity-100 transition-opacity"
|
|
504
|
+
@click="copyMessageContent(msg.content, idx)"
|
|
505
|
+
/>
|
|
506
|
+
<span v-if="msg.timestamp">{{ msg.timestamp }}</span>
|
|
507
|
+
</div>
|
|
508
|
+
</div>
|
|
509
|
+
</div>
|
|
510
|
+
|
|
511
|
+
<!-- User Icon (if user) -->
|
|
512
|
+
<div
|
|
513
|
+
v-if="msg.role === 'user'"
|
|
514
|
+
class="w-7 h-7 rounded-full bg-muted border border-default flex items-center justify-center shrink-0 text-muted mt-0.5"
|
|
515
|
+
>
|
|
516
|
+
<UIcon name="i-lucide-user" class="w-4 h-4" />
|
|
517
|
+
</div>
|
|
518
|
+
</div>
|
|
519
|
+
</div>
|
|
520
|
+
|
|
521
|
+
<!-- Empty Conversation / Suggested Prompts -->
|
|
522
|
+
<div v-else-if="!historyLoading" class="py-8 text-center space-y-4">
|
|
523
|
+
<div
|
|
524
|
+
class="w-12 h-12 rounded-full bg-primary/10 border border-primary/20 flex items-center justify-center text-primary mx-auto"
|
|
525
|
+
>
|
|
526
|
+
<UIcon name="i-lucide-message-square" class="w-6 h-6" />
|
|
527
|
+
</div>
|
|
528
|
+
<div>
|
|
529
|
+
<div class="font-bold text-sm text-highlighted">No messages yet</div>
|
|
530
|
+
<div class="text-xs text-muted mt-1">
|
|
531
|
+
Start a live conversation with this edge agent below.
|
|
532
|
+
</div>
|
|
533
|
+
</div>
|
|
534
|
+
|
|
535
|
+
<div class="flex flex-wrap justify-center gap-2 max-w-md mx-auto pt-2">
|
|
536
|
+
<UButton
|
|
537
|
+
v-for="(p, i) in defaultPrompts"
|
|
538
|
+
:key="i"
|
|
539
|
+
:label="p"
|
|
540
|
+
size="xs"
|
|
541
|
+
color="neutral"
|
|
542
|
+
variant="subtle"
|
|
543
|
+
class="text-left"
|
|
544
|
+
@click="selectPrompt(p)"
|
|
545
|
+
/>
|
|
546
|
+
</div>
|
|
547
|
+
</div>
|
|
548
|
+
|
|
549
|
+
<!-- Typing / Running Indicator -->
|
|
550
|
+
<div v-if="chatRunning" class="flex items-center gap-3 text-xs">
|
|
551
|
+
<div
|
|
552
|
+
class="w-7 h-7 rounded-full bg-primary/10 border border-primary/20 flex items-center justify-center shrink-0 text-primary"
|
|
553
|
+
>
|
|
554
|
+
<UIcon name="i-lucide-bot" class="w-4 h-4" />
|
|
555
|
+
</div>
|
|
556
|
+
<div
|
|
557
|
+
class="bg-elevated border border-default rounded-2xl rounded-tl-xs px-4 py-2 text-muted flex items-center gap-2"
|
|
558
|
+
>
|
|
559
|
+
<UIcon name="i-lucide-loader-2" class="w-3.5 h-3.5 animate-spin text-primary" />
|
|
560
|
+
<span
|
|
561
|
+
>Thinking with
|
|
562
|
+
{{
|
|
563
|
+
selectedModelOverride.split("/").pop() ||
|
|
564
|
+
selectedAgent.model?.split("/").pop() ||
|
|
565
|
+
"Edge AI"
|
|
566
|
+
}}…</span
|
|
567
|
+
>
|
|
568
|
+
</div>
|
|
569
|
+
</div>
|
|
570
|
+
</div>
|
|
571
|
+
|
|
572
|
+
<!-- Chat Input Bar -->
|
|
573
|
+
<div class="p-3 border-t border-default bg-elevated/40">
|
|
574
|
+
<form class="flex items-center gap-2" @submit.prevent="sendMessage">
|
|
575
|
+
<UInput
|
|
576
|
+
v-model="inputMessage"
|
|
577
|
+
placeholder="Type a message… (Press Enter to send)"
|
|
578
|
+
class="flex-1 text-xs"
|
|
579
|
+
:disabled="chatRunning"
|
|
580
|
+
@keydown.enter.prevent="sendMessage"
|
|
581
|
+
/>
|
|
582
|
+
<UButton
|
|
583
|
+
type="submit"
|
|
584
|
+
icon="i-lucide-send"
|
|
585
|
+
color="primary"
|
|
586
|
+
size="sm"
|
|
587
|
+
:loading="chatRunning"
|
|
588
|
+
:disabled="!inputMessage.trim()"
|
|
589
|
+
/>
|
|
590
|
+
</form>
|
|
591
|
+
</div>
|
|
592
|
+
</div>
|
|
593
|
+
|
|
594
|
+
<div
|
|
595
|
+
v-else
|
|
596
|
+
class="flex-1 flex flex-col items-center justify-center text-muted text-xs p-12 text-center"
|
|
597
|
+
>
|
|
598
|
+
<UIcon name="i-lucide-bot" class="w-8 h-8 mb-2 opacity-50 text-muted" />
|
|
599
|
+
Select an agent from the list to start a conversation.
|
|
600
|
+
</div>
|
|
601
|
+
</template>
|
|
602
|
+
</UDashboardPanel>
|
|
603
|
+
|
|
604
|
+
<!-- Clear Conversation Modal -->
|
|
605
|
+
<UModal v-model:open="showClearModal" title="Clear Conversation">
|
|
606
|
+
<template #body>
|
|
607
|
+
<div class="space-y-3">
|
|
608
|
+
<p class="text-xs text-default">
|
|
609
|
+
Are you sure you want to clear conversation history for
|
|
610
|
+
<span class="font-bold text-highlighted">{{
|
|
611
|
+
selectedAgent?.name || selectedAgent?.id
|
|
612
|
+
}}</span
|
|
613
|
+
>?
|
|
614
|
+
</p>
|
|
615
|
+
<p class="text-xs text-muted">
|
|
616
|
+
All stored messages in this agent's stateful memory will be wiped.
|
|
617
|
+
</p>
|
|
618
|
+
</div>
|
|
619
|
+
</template>
|
|
620
|
+
<template #footer>
|
|
621
|
+
<div class="flex justify-end gap-2">
|
|
622
|
+
<UButton
|
|
623
|
+
label="Cancel"
|
|
624
|
+
color="neutral"
|
|
625
|
+
variant="ghost"
|
|
626
|
+
size="xs"
|
|
627
|
+
@click="showClearModal = false"
|
|
628
|
+
/>
|
|
629
|
+
<UButton
|
|
630
|
+
label="Clear History"
|
|
631
|
+
color="error"
|
|
632
|
+
size="xs"
|
|
633
|
+
icon="i-lucide-trash"
|
|
634
|
+
:loading="clearingChat"
|
|
635
|
+
@click="handleClearConversation"
|
|
636
|
+
/>
|
|
637
|
+
</div>
|
|
638
|
+
</template>
|
|
639
|
+
</UModal>
|
|
640
|
+
|
|
641
|
+
<!-- Create New Agent Modal -->
|
|
642
|
+
<UModal v-model:open="showCreateModal" title="Create Edge Agent">
|
|
643
|
+
<template #body>
|
|
644
|
+
<div class="space-y-3 text-xs">
|
|
645
|
+
<div>
|
|
646
|
+
<div class="text-muted mb-1 font-medium">Agent Name</div>
|
|
647
|
+
<UInput
|
|
648
|
+
v-model="newAgentName"
|
|
649
|
+
placeholder="e.g. Code Reviewer"
|
|
650
|
+
class="w-full font-sans"
|
|
651
|
+
/>
|
|
652
|
+
</div>
|
|
653
|
+
|
|
654
|
+
<div>
|
|
655
|
+
<div class="text-muted mb-1 font-medium">Description</div>
|
|
656
|
+
<UInput
|
|
657
|
+
v-model="newAgentDesc"
|
|
658
|
+
placeholder="Brief summary of agent role"
|
|
659
|
+
class="w-full font-sans"
|
|
660
|
+
/>
|
|
661
|
+
</div>
|
|
662
|
+
|
|
663
|
+
<div>
|
|
664
|
+
<div class="text-muted mb-1 font-medium">Model</div>
|
|
665
|
+
<USelect
|
|
666
|
+
v-model="newAgentModel"
|
|
667
|
+
:items="
|
|
668
|
+
availableModels.map((m) => ({ label: `${m.label} (${m.value})`, value: m.value }))
|
|
669
|
+
"
|
|
670
|
+
size="xs"
|
|
671
|
+
class="w-full font-mono text-xs"
|
|
672
|
+
/>
|
|
673
|
+
</div>
|
|
674
|
+
|
|
675
|
+
<div>
|
|
676
|
+
<div class="text-muted mb-1 font-medium">System Instructions</div>
|
|
677
|
+
<UTextarea
|
|
678
|
+
v-model="newAgentSystem"
|
|
679
|
+
placeholder="You are an autonomous AI agent..."
|
|
680
|
+
:rows="3"
|
|
681
|
+
class="w-full font-mono text-xs"
|
|
682
|
+
/>
|
|
683
|
+
</div>
|
|
684
|
+
|
|
685
|
+
<div>
|
|
686
|
+
<div class="text-muted mb-1 font-medium">Tools (Comma-separated)</div>
|
|
687
|
+
<UInput
|
|
688
|
+
v-model="newAgentTools"
|
|
689
|
+
placeholder="e.g. searchDocs, runQuery"
|
|
690
|
+
class="w-full font-mono text-xs"
|
|
691
|
+
/>
|
|
692
|
+
</div>
|
|
693
|
+
</div>
|
|
694
|
+
</template>
|
|
695
|
+
<template #footer>
|
|
696
|
+
<div class="flex justify-end gap-2">
|
|
697
|
+
<UButton
|
|
698
|
+
label="Cancel"
|
|
699
|
+
color="neutral"
|
|
700
|
+
variant="ghost"
|
|
701
|
+
size="xs"
|
|
702
|
+
@click="showCreateModal = false"
|
|
703
|
+
/>
|
|
704
|
+
<UButton
|
|
705
|
+
label="Create Agent"
|
|
706
|
+
color="primary"
|
|
707
|
+
size="xs"
|
|
708
|
+
icon="i-lucide-plus"
|
|
709
|
+
:loading="creatingAgent"
|
|
710
|
+
:disabled="!newAgentName.trim()"
|
|
711
|
+
@click="handleCreateAgent"
|
|
712
|
+
/>
|
|
713
|
+
</div>
|
|
714
|
+
</template>
|
|
715
|
+
</UModal>
|
|
716
|
+
</template>
|