@antelopejs/dms-ai 0.1.4 → 0.1.6
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 +55 -29
- package/dist/channels/bridge.d.ts +2 -8
- package/dist/channels/bridge.js +26 -42
- package/dist/channels/bridge.js.map +1 -1
- package/dist/channels/channel-service.d.ts +2 -2
- package/dist/channels/channel-service.js +12 -31
- package/dist/channels/channel-service.js.map +1 -1
- package/dist/channels/registry.d.ts +2 -2
- package/dist/channels/registry.js +7 -7
- package/dist/channels/registry.js.map +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.js +8 -1
- package/dist/config.js.map +1 -1
- package/dist/constants/channels.d.ts +5 -10
- package/dist/constants/channels.js +6 -10
- package/dist/constants/channels.js.map +1 -1
- package/dist/constants/sidecar.d.ts +5 -1
- package/dist/constants/sidecar.js +6 -2
- package/dist/constants/sidecar.js.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/lifecycle/build-id.d.ts +1 -0
- package/dist/lifecycle/build-id.js +32 -0
- package/dist/lifecycle/build-id.js.map +1 -0
- package/dist/lifecycle/sidecar-owner.d.ts +13 -0
- package/dist/lifecycle/sidecar-owner.js +89 -0
- package/dist/lifecycle/sidecar-owner.js.map +1 -0
- package/dist/lifecycle/sidecar-socket.d.ts +1 -1
- package/dist/lifecycle/sidecar-socket.js +2 -2
- package/dist/lifecycle/sidecar-socket.js.map +1 -1
- package/dist/lifecycle/spawn-sidecar.d.ts +0 -1
- package/dist/lifecycle/spawn-sidecar.js +51 -159
- package/dist/lifecycle/spawn-sidecar.js.map +1 -1
- package/dist/lifecycle/terminate-process.d.ts +1 -0
- package/dist/lifecycle/terminate-process.js +34 -0
- package/dist/lifecycle/terminate-process.js.map +1 -0
- package/dist/routes/channels.d.ts +3 -3
- package/dist/routes/channels.js +11 -12
- package/dist/routes/channels.js.map +1 -1
- package/dist/routes/index.d.ts +0 -1
- package/dist/routes/index.js +0 -1
- package/dist/routes/index.js.map +1 -1
- package/frontend-vue/.prettierignore +3 -0
- package/frontend-vue/.prettierrc +10 -0
- package/frontend-vue/app/chat/components/ChatView.vue +582 -0
- package/frontend-vue/app/chat/components/ComposerInput.vue +742 -0
- package/frontend-vue/app/chat/components/ConnectionBanner.vue +105 -0
- package/frontend-vue/app/chat/components/ConversationDrawer.vue +266 -0
- package/frontend-vue/app/chat/components/MarkdownContent.vue +196 -0
- package/frontend-vue/app/chat/components/MessageList.vue +474 -0
- package/frontend-vue/app/chat/components/PermissionRequests.vue +323 -0
- package/frontend-vue/app/chat/components/QuestionPrompt.vue +275 -0
- package/frontend-vue/app/chat/components/QueuedMessages.vue +109 -0
- package/frontend-vue/app/chat/components/TodoList.vue +291 -0
- package/frontend-vue/app/chat/components/ToolCallEntry.vue +218 -0
- package/frontend-vue/app/chat/components/ToolCluster.vue +282 -0
- package/frontend-vue/app/chat/composables/useChatChannel.ts +116 -0
- package/frontend-vue/app/chat/composables/useConversation.ts +838 -0
- package/frontend-vue/app/chat/composables/useConversationId.ts +34 -0
- package/frontend-vue/app/chat/composables/useConversationList.ts +56 -0
- package/frontend-vue/app/chat/composables/usePermissionQueue.ts +59 -0
- package/frontend-vue/app/chat/composables/useQuestionQueue.ts +50 -0
- package/frontend-vue/app/chat/composables/useRunClock.ts +28 -0
- package/frontend-vue/app/chat/composables/useSettings.ts +67 -0
- package/frontend-vue/app/chat/constants/attachments.ts +16 -0
- package/frontend-vue/app/chat/constants/connection-banner.ts +7 -0
- package/frontend-vue/app/chat/constants/conversation-drawer.ts +13 -0
- package/frontend-vue/app/chat/constants/conversation.ts +75 -0
- package/frontend-vue/app/chat/constants/permissions.ts +50 -0
- package/frontend-vue/app/chat/constants/protocol.ts +48 -0
- package/frontend-vue/app/chat/constants/run-status.ts +50 -0
- package/frontend-vue/app/chat/constants/settings.ts +60 -0
- package/frontend-vue/app/chat/types/conversation.ts +87 -0
- package/frontend-vue/app/chat/types/permission.ts +7 -0
- package/frontend-vue/app/chat/types/question.ts +17 -0
- package/frontend-vue/app/chat/types/settings.ts +27 -0
- package/frontend-vue/app/chat/utils/attachments.ts +62 -0
- package/frontend-vue/app/chat/utils/format.ts +14 -0
- package/frontend-vue/app/chat/utils/ids.ts +34 -0
- package/frontend-vue/app/chat/utils/markdown.ts +188 -0
- package/frontend-vue/app/chat/utils/run-status.ts +90 -0
- package/frontend-vue/app/chat/utils/todos.ts +64 -0
- package/frontend-vue/app/chat/utils/tool-summary.ts +53 -0
- package/frontend-vue/app/components/ActivityView.vue +34 -34
- package/frontend-vue/app/components/ChatPanel.vue +276 -0
- package/frontend-vue/app/components/SettingsView.vue +120 -112
- package/frontend-vue/app/components/SkillsView.vue +55 -53
- package/frontend-vue/app/plugins/ai.client.ts +145 -129
- package/frontend-vue/app/runtime/assistant-session.ts +21 -0
- package/frontend-vue/app/runtime/backoff.ts +11 -14
- package/frontend-vue/app/runtime/channel-client.ts +130 -141
- package/frontend-vue/app/runtime/chat-transport.ts +25 -55
- package/frontend-vue/app/runtime/constants.ts +69 -59
- package/frontend-vue/app/runtime/current-page.ts +49 -15
- package/frontend-vue/app/runtime/event-stream.ts +35 -35
- package/frontend-vue/app/runtime/frame-router.ts +30 -0
- package/frontend-vue/app/runtime/header-action.ts +18 -18
- package/frontend-vue/app/runtime/host-commands.ts +57 -56
- package/frontend-vue/app/runtime/listeners.ts +31 -0
- package/frontend-vue/app/runtime/navigation-complete.ts +7 -7
- package/frontend-vue/app/runtime/overlay-prefs.ts +36 -36
- package/frontend-vue/app/runtime/panel-state.ts +88 -0
- package/frontend-vue/app/runtime/session-gate.ts +8 -8
- package/frontend-vue/app/runtime/shortcuts.ts +12 -12
- package/frontend-vue/app/runtime/sidecar-status.ts +61 -61
- package/frontend-vue/app/runtime/typed-message.ts +11 -0
- package/frontend-vue/dms.frontend.ts +12 -12
- package/frontend-vue/eslint.config.mjs +13 -13
- package/frontend-vue/package.json +11 -4
- package/frontend-vue/pnpm-lock.yaml +298 -96
- package/frontend-vue/tests/backoff.test.ts +26 -30
- package/frontend-vue/tests/channel-client.test.ts +187 -188
- package/frontend-vue/tests/chat/markdown.test.ts +271 -0
- package/frontend-vue/tests/chat/useChatChannel.test.ts +124 -0
- package/frontend-vue/tests/chat/useConversation.test.ts +283 -0
- package/frontend-vue/tests/chat-panel.test.ts +354 -0
- package/frontend-vue/tests/chat-transport.test.ts +84 -57
- package/frontend-vue/tests/host-commands.test.ts +126 -87
- package/frontend-vue/tests/navigation.test.ts +65 -34
- package/frontend-vue/tests/overlay-prefs.test.ts +49 -49
- package/frontend-vue/tests/panel-state.test.ts +58 -0
- package/frontend-vue/tests/session-gate.test.ts +33 -33
- package/frontend-vue/tests/sidecar-guest.test.ts +46 -46
- package/frontend-vue/tests/sidecar-status.test.ts +29 -29
- package/frontend-vue/tsconfig.chat.json +16 -0
- package/frontend-vue/vitest.config.ts +6 -4
- package/package.json +6 -5
- package/sidecar/dist/agent/effective-mode.d.ts +2 -2
- package/sidecar/dist/agent/effective-mode.js +1 -1
- package/sidecar/dist/agent/effective-mode.js.map +1 -1
- package/sidecar/dist/agent/host-context.js +7 -9
- package/sidecar/dist/agent/host-context.js.map +1 -1
- package/sidecar/dist/agent/permission-bus.d.ts +1 -1
- package/sidecar/dist/agent/permission-bus.js +2 -2
- package/sidecar/dist/agent/permission-bus.js.map +1 -1
- package/sidecar/dist/agent/provider.d.ts +2 -2
- package/sidecar/dist/agent/question-bus.d.ts +1 -1
- package/sidecar/dist/agent/question-bus.js +2 -2
- package/sidecar/dist/agent/question-bus.js.map +1 -1
- package/sidecar/dist/agent/runner.d.ts +2 -2
- package/sidecar/dist/agent/runner.js +24 -8
- package/sidecar/dist/agent/runner.js.map +1 -1
- package/sidecar/dist/agent/session.d.ts +2 -2
- package/sidecar/dist/agent/session.js +49 -9
- package/sidecar/dist/agent/session.js.map +1 -1
- package/sidecar/dist/agent/switching-runner.js +10 -5
- package/sidecar/dist/agent/switching-runner.js.map +1 -1
- package/sidecar/dist/agent/turn-end-reasons.d.ts +2 -0
- package/sidecar/dist/agent/turn-end-reasons.js +6 -1
- package/sidecar/dist/agent/turn-end-reasons.js.map +1 -1
- package/sidecar/dist/constants/agent.d.ts +4 -1
- package/sidecar/dist/constants/agent.js +4 -1
- package/sidecar/dist/constants/agent.js.map +1 -1
- package/sidecar/dist/constants/cli.d.ts +0 -1
- package/sidecar/dist/constants/cli.js +0 -1
- package/sidecar/dist/constants/cli.js.map +1 -1
- package/sidecar/dist/constants/codex.d.ts +5 -2
- package/sidecar/dist/constants/codex.js +5 -2
- package/sidecar/dist/constants/codex.js.map +1 -1
- package/sidecar/dist/constants/http.d.ts +0 -9
- package/sidecar/dist/constants/http.js +0 -19
- package/sidecar/dist/constants/http.js.map +1 -1
- package/sidecar/dist/constants/mcp.d.ts +1 -1
- package/sidecar/dist/constants/mcp.js +1 -1
- package/sidecar/dist/constants/mcp.js.map +1 -1
- package/sidecar/dist/constants/paths.d.ts +0 -1
- package/sidecar/dist/constants/paths.js +0 -1
- package/sidecar/dist/constants/paths.js.map +1 -1
- package/sidecar/dist/constants/ws.d.ts +3 -4
- package/sidecar/dist/constants/ws.js +3 -4
- package/sidecar/dist/constants/ws.js.map +1 -1
- package/sidecar/dist/index.d.ts +4 -1
- package/sidecar/dist/index.js +13 -13
- package/sidecar/dist/index.js.map +1 -1
- package/sidecar/dist/mcp/tools/find-pages-using.js +5 -10
- package/sidecar/dist/mcp/tools/find-pages-using.js.map +1 -1
- package/sidecar/dist/mcp/types.d.ts +1 -1
- package/sidecar/dist/pages/page-filepath.d.ts +4 -0
- package/sidecar/dist/pages/page-filepath.js +28 -0
- package/sidecar/dist/pages/page-filepath.js.map +1 -0
- package/sidecar/dist/prompts/agent.d.ts +1 -1
- package/sidecar/dist/prompts/agent.js +1 -1
- package/sidecar/dist/prompts/agent.js.map +1 -1
- package/sidecar/dist/protocol/events.js +2 -2
- package/sidecar/dist/protocol/events.js.map +1 -1
- package/sidecar/dist/protocol/messages.d.ts +4 -15
- package/sidecar/dist/protocol/messages.js +4 -11
- package/sidecar/dist/protocol/messages.js.map +1 -1
- package/sidecar/dist/providers/claude/config.d.ts +2 -2
- package/sidecar/dist/providers/claude/config.js +2 -2
- package/sidecar/dist/providers/claude/config.js.map +1 -1
- package/sidecar/dist/providers/claude/provider.js +1 -1
- package/sidecar/dist/providers/claude/provider.js.map +1 -1
- package/sidecar/dist/providers/codex/config.d.ts +3 -2
- package/sidecar/dist/providers/codex/config.js +3 -3
- package/sidecar/dist/providers/codex/config.js.map +1 -1
- package/sidecar/dist/providers/codex/process.js +107 -74
- package/sidecar/dist/providers/codex/process.js.map +1 -1
- package/sidecar/dist/providers/codex/provider.js +68 -31
- package/sidecar/dist/providers/codex/provider.js.map +1 -1
- package/sidecar/dist/providers/codex/skills.d.ts +1 -0
- package/sidecar/dist/providers/codex/skills.js +4 -1
- package/sidecar/dist/providers/codex/skills.js.map +1 -1
- package/sidecar/dist/providers/codex/stop.d.ts +4 -0
- package/sidecar/dist/providers/codex/stop.js +71 -0
- package/sidecar/dist/providers/codex/stop.js.map +1 -0
- package/sidecar/dist/server/{iframe-socket-registry.d.ts → chat-socket-registry.d.ts} +3 -2
- package/sidecar/dist/server/{iframe-socket-registry.js → chat-socket-registry.js} +4 -3
- package/sidecar/dist/server/chat-socket-registry.js.map +1 -0
- package/sidecar/dist/server/client-auth.js +2 -14
- package/sidecar/dist/server/client-auth.js.map +1 -1
- package/sidecar/dist/server/host-command-router.d.ts +5 -0
- package/sidecar/dist/server/host-command-router.js +4 -0
- package/sidecar/dist/server/host-command-router.js.map +1 -0
- package/sidecar/dist/server/host-socket-registry.d.ts +1 -1
- package/sidecar/dist/server/host-socket-registry.js +16 -13
- package/sidecar/dist/server/host-socket-registry.js.map +1 -1
- package/sidecar/dist/server/http.d.ts +0 -1
- package/sidecar/dist/server/http.js +1 -44
- package/sidecar/dist/server/http.js.map +1 -1
- package/sidecar/dist/server/routing.d.ts +5 -6
- package/sidecar/dist/server/routing.js +18 -28
- package/sidecar/dist/server/routing.js.map +1 -1
- package/sidecar/dist/server/ws.d.ts +2 -2
- package/sidecar/dist/server/ws.js +41 -39
- package/sidecar/dist/server/ws.js.map +1 -1
- package/sidecar/dist/state/host-state.d.ts +10 -2
- package/sidecar/dist/state/host-state.js +13 -3
- package/sidecar/dist/state/host-state.js.map +1 -1
- package/sidecar/dist/state/settings-store.js +2 -2
- package/sidecar/dist/state/settings-store.js.map +1 -1
- package/sidecar/dist/state/settings-types.d.ts +3 -3
- package/sidecar/dist/state/settings-types.js +1 -1
- package/sidecar/dist/state/settings-types.js.map +1 -1
- package/sidecar/package.json +3 -5
- package/dist/chatbox/passthrough.d.ts +0 -3
- package/dist/chatbox/passthrough.js +0 -53
- package/dist/chatbox/passthrough.js.map +0 -1
- package/dist/constants/chatbox.d.ts +0 -10
- package/dist/constants/chatbox.js +0 -35
- package/dist/constants/chatbox.js.map +0 -1
- package/dist/routes/chatbox.d.ts +0 -7
- package/dist/routes/chatbox.js +0 -47
- package/dist/routes/chatbox.js.map +0 -1
- package/frontend-vue/app/runtime/overlay.ts +0 -400
- package/frontend-vue/app/runtime/theme-bridge.ts +0 -189
- package/sidecar/chatbox/dist/assets/index-C8u7mkHn.css +0 -1
- package/sidecar/chatbox/dist/assets/index-tdZvY7ee.js +0 -52
- package/sidecar/chatbox/dist/index.html +0 -13
- package/sidecar/dist/server/iframe-socket-registry.js.map +0 -1
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, onUnmounted, ref, watch } from "vue";
|
|
3
|
+
import {
|
|
4
|
+
TOOL_CLUSTER_COLLAPSE_LINGER_MS,
|
|
5
|
+
TOOL_CLUSTER_LABEL,
|
|
6
|
+
TOOL_CLUSTER_VISIBLE_LIMIT,
|
|
7
|
+
TOOL_STATUS,
|
|
8
|
+
} from "../constants/conversation";
|
|
9
|
+
import type { ToolCallMessage, ToolStatus } from "../types/conversation";
|
|
10
|
+
import { toolSummary } from "../utils/tool-summary";
|
|
11
|
+
import ToolCallEntry from "./ToolCallEntry.vue";
|
|
12
|
+
|
|
13
|
+
interface Props {
|
|
14
|
+
tools: ToolCallMessage[];
|
|
15
|
+
/** True while this is the trailing tool activity of a running turn. */
|
|
16
|
+
live: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const props = defineProps<Props>();
|
|
20
|
+
|
|
21
|
+
const override = ref<boolean | null>(null);
|
|
22
|
+
const showAll = ref(false);
|
|
23
|
+
|
|
24
|
+
const lingering = ref(false);
|
|
25
|
+
let lingerTimer: ReturnType<typeof setTimeout> | null = null;
|
|
26
|
+
|
|
27
|
+
watch(
|
|
28
|
+
() => props.live,
|
|
29
|
+
(isLive, wasLive) => {
|
|
30
|
+
if (isLive) {
|
|
31
|
+
lingering.value = false;
|
|
32
|
+
if (lingerTimer !== null) clearTimeout(lingerTimer);
|
|
33
|
+
lingerTimer = null;
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (!wasLive) return;
|
|
37
|
+
lingering.value = true;
|
|
38
|
+
if (lingerTimer !== null) clearTimeout(lingerTimer);
|
|
39
|
+
lingerTimer = setTimeout(() => {
|
|
40
|
+
lingering.value = false;
|
|
41
|
+
lingerTimer = null;
|
|
42
|
+
}, TOOL_CLUSTER_COLLAPSE_LINGER_MS);
|
|
43
|
+
},
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
onUnmounted(() => {
|
|
47
|
+
if (lingerTimer !== null) clearTimeout(lingerTimer);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const rollupStatus = computed<ToolStatus>(() => {
|
|
51
|
+
if (props.tools.some((t) => t.status === TOOL_STATUS.PENDING)) {
|
|
52
|
+
return TOOL_STATUS.PENDING;
|
|
53
|
+
}
|
|
54
|
+
if (props.tools.some((t) => t.status === TOOL_STATUS.ERROR)) {
|
|
55
|
+
return TOOL_STATUS.ERROR;
|
|
56
|
+
}
|
|
57
|
+
return TOOL_STATUS.SUCCESS;
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const hasError = computed<boolean>(() =>
|
|
61
|
+
props.tools.some((t) => t.status === TOOL_STATUS.ERROR),
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
const autoOpen = computed<boolean>(
|
|
65
|
+
() => props.live || lingering.value || hasError.value,
|
|
66
|
+
);
|
|
67
|
+
const isOpen = computed<boolean>(() =>
|
|
68
|
+
override.value !== null ? override.value : autoOpen.value,
|
|
69
|
+
);
|
|
70
|
+
const isFull = computed<boolean>(
|
|
71
|
+
() => override.value === true || showAll.value,
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
const visibleTools = computed<ToolCallMessage[]>(() =>
|
|
75
|
+
isFull.value ? props.tools : props.tools.slice(-TOOL_CLUSTER_VISIBLE_LIMIT),
|
|
76
|
+
);
|
|
77
|
+
const hiddenCount = computed<number>(
|
|
78
|
+
() => props.tools.length - visibleTools.value.length,
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
const glyphStatus = computed<ToolStatus>(() =>
|
|
82
|
+
props.live ? TOOL_STATUS.PENDING : rollupStatus.value,
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
const headline = computed<string>(() => {
|
|
86
|
+
const active =
|
|
87
|
+
props.tools.find((t) => t.status === TOOL_STATUS.PENDING) ??
|
|
88
|
+
props.tools.at(-1);
|
|
89
|
+
if (active === undefined) return "";
|
|
90
|
+
return toolSummary(active.toolName, active.args);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
const countLabel = computed<string>(
|
|
94
|
+
() => `${TOOL_CLUSTER_LABEL} ${props.tools.length} tools`,
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
function toggle(): void {
|
|
98
|
+
override.value = !isOpen.value;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function revealEarlier(): void {
|
|
102
|
+
showAll.value = true;
|
|
103
|
+
}
|
|
104
|
+
</script>
|
|
105
|
+
|
|
106
|
+
<template>
|
|
107
|
+
<section class="tool-cluster" :data-status="rollupStatus">
|
|
108
|
+
<button
|
|
109
|
+
type="button"
|
|
110
|
+
class="cluster-header"
|
|
111
|
+
:aria-expanded="isOpen"
|
|
112
|
+
@click="toggle"
|
|
113
|
+
>
|
|
114
|
+
<span class="cluster-toggle">{{ isOpen ? "▾" : "▸" }}</span>
|
|
115
|
+
<span class="cluster-glyph" :data-status="glyphStatus" aria-hidden="true">
|
|
116
|
+
<svg
|
|
117
|
+
v-if="glyphStatus === 'pending'"
|
|
118
|
+
class="cluster-spin"
|
|
119
|
+
viewBox="0 0 24 24"
|
|
120
|
+
width="13"
|
|
121
|
+
height="13"
|
|
122
|
+
fill="none"
|
|
123
|
+
stroke="currentColor"
|
|
124
|
+
stroke-width="2.5"
|
|
125
|
+
stroke-linecap="round"
|
|
126
|
+
>
|
|
127
|
+
<path d="M21 12a9 9 0 1 1-6.2-8.6" />
|
|
128
|
+
</svg>
|
|
129
|
+
<svg
|
|
130
|
+
v-else-if="glyphStatus === 'error'"
|
|
131
|
+
viewBox="0 0 24 24"
|
|
132
|
+
width="13"
|
|
133
|
+
height="13"
|
|
134
|
+
fill="none"
|
|
135
|
+
stroke="currentColor"
|
|
136
|
+
stroke-width="2.5"
|
|
137
|
+
stroke-linecap="round"
|
|
138
|
+
stroke-linejoin="round"
|
|
139
|
+
>
|
|
140
|
+
<path d="M18 6 6 18M6 6l12 12" />
|
|
141
|
+
</svg>
|
|
142
|
+
<svg
|
|
143
|
+
v-else
|
|
144
|
+
viewBox="0 0 24 24"
|
|
145
|
+
width="13"
|
|
146
|
+
height="13"
|
|
147
|
+
fill="none"
|
|
148
|
+
stroke="currentColor"
|
|
149
|
+
stroke-width="2.5"
|
|
150
|
+
stroke-linecap="round"
|
|
151
|
+
stroke-linejoin="round"
|
|
152
|
+
>
|
|
153
|
+
<path d="M20 6 9 17l-5-5" />
|
|
154
|
+
</svg>
|
|
155
|
+
</span>
|
|
156
|
+
<span class="cluster-count">{{ countLabel }}</span>
|
|
157
|
+
<span v-if="!isOpen && headline.length > 0" class="cluster-headline">
|
|
158
|
+
{{ headline }}
|
|
159
|
+
</span>
|
|
160
|
+
</button>
|
|
161
|
+
<div v-if="isOpen" class="cluster-body">
|
|
162
|
+
<button
|
|
163
|
+
v-if="hiddenCount > 0"
|
|
164
|
+
type="button"
|
|
165
|
+
class="cluster-earlier"
|
|
166
|
+
@click="revealEarlier"
|
|
167
|
+
>
|
|
168
|
+
▴ {{ hiddenCount }} earlier
|
|
169
|
+
</button>
|
|
170
|
+
<ToolCallEntry
|
|
171
|
+
v-for="tool in visibleTools"
|
|
172
|
+
:key="tool.id"
|
|
173
|
+
:message="tool"
|
|
174
|
+
/>
|
|
175
|
+
</div>
|
|
176
|
+
</section>
|
|
177
|
+
</template>
|
|
178
|
+
|
|
179
|
+
<style scoped>
|
|
180
|
+
.tool-cluster {
|
|
181
|
+
border: 1px solid var(--hair);
|
|
182
|
+
border-radius: var(--corner-md);
|
|
183
|
+
background: var(--surface-card);
|
|
184
|
+
overflow: hidden;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.cluster-header {
|
|
188
|
+
display: flex;
|
|
189
|
+
align-items: center;
|
|
190
|
+
gap: 8px;
|
|
191
|
+
width: 100%;
|
|
192
|
+
padding: 8px 10px;
|
|
193
|
+
background: transparent;
|
|
194
|
+
border: none;
|
|
195
|
+
cursor: pointer;
|
|
196
|
+
font: inherit;
|
|
197
|
+
text-align: left;
|
|
198
|
+
color: var(--fg);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.cluster-header:hover {
|
|
202
|
+
background: var(--surface-card-2);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.cluster-toggle {
|
|
206
|
+
color: var(--fg-tertiary);
|
|
207
|
+
font-size: 11px;
|
|
208
|
+
flex: 0 0 auto;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.cluster-glyph {
|
|
212
|
+
width: 20px;
|
|
213
|
+
height: 20px;
|
|
214
|
+
flex: 0 0 auto;
|
|
215
|
+
display: grid;
|
|
216
|
+
place-items: center;
|
|
217
|
+
border-radius: 6px;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.cluster-glyph[data-status="pending"] {
|
|
221
|
+
color: var(--warning-400);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.cluster-glyph[data-status="success"] {
|
|
225
|
+
color: var(--success-400);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.cluster-glyph[data-status="error"] {
|
|
229
|
+
color: var(--danger-400);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
.cluster-spin {
|
|
233
|
+
animation: cluster-spin 0.9s linear infinite;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
@keyframes cluster-spin {
|
|
237
|
+
to {
|
|
238
|
+
transform: rotate(360deg);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
.cluster-count {
|
|
243
|
+
font-weight: 600;
|
|
244
|
+
font-size: 12.5px;
|
|
245
|
+
flex: 0 0 auto;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
.cluster-headline {
|
|
249
|
+
font-family: var(--font-code);
|
|
250
|
+
font-size: 11px;
|
|
251
|
+
color: var(--fg-tertiary);
|
|
252
|
+
white-space: nowrap;
|
|
253
|
+
overflow: hidden;
|
|
254
|
+
text-overflow: ellipsis;
|
|
255
|
+
min-width: 0;
|
|
256
|
+
flex: 1;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.cluster-body {
|
|
260
|
+
display: flex;
|
|
261
|
+
flex-direction: column;
|
|
262
|
+
gap: 6px;
|
|
263
|
+
padding: 6px;
|
|
264
|
+
border-top: 1px solid var(--hair);
|
|
265
|
+
background: var(--surface-inset);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.cluster-earlier {
|
|
269
|
+
align-self: flex-start;
|
|
270
|
+
background: none;
|
|
271
|
+
border: none;
|
|
272
|
+
padding: 2px 2px 0;
|
|
273
|
+
font: inherit;
|
|
274
|
+
font-size: 11px;
|
|
275
|
+
color: var(--fg-tertiary);
|
|
276
|
+
cursor: pointer;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
.cluster-earlier:hover {
|
|
280
|
+
color: var(--accent);
|
|
281
|
+
}
|
|
282
|
+
</style>
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { onBeforeUnmount, onMounted, type Ref, ref } from "vue";
|
|
2
|
+
import type { ChatTransport } from "../../runtime/chat-transport";
|
|
3
|
+
import { createListeners } from "../../runtime/listeners";
|
|
4
|
+
import {
|
|
5
|
+
CHAT_ROLE,
|
|
6
|
+
CLIENT_MESSAGE_TYPES,
|
|
7
|
+
CONNECTION_STATUSES,
|
|
8
|
+
type ConnectionStatus,
|
|
9
|
+
} from "../constants/protocol";
|
|
10
|
+
|
|
11
|
+
export interface UseChatChannelOptions {
|
|
12
|
+
transport: ChatTransport;
|
|
13
|
+
getConversationId: () => string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type ChannelMessageHandler = (msg: unknown) => void;
|
|
17
|
+
|
|
18
|
+
export interface UseChatChannelResult {
|
|
19
|
+
/** False when the message was dropped: the stream is not connected. */
|
|
20
|
+
send: (msg: object) => boolean;
|
|
21
|
+
onMessage: (handler: ChannelMessageHandler) => () => void;
|
|
22
|
+
reconnect: () => void;
|
|
23
|
+
reidentify: () => void;
|
|
24
|
+
isConnected: Ref<boolean>;
|
|
25
|
+
connectionStatus: Ref<ConnectionStatus>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface ChannelState {
|
|
29
|
+
options: UseChatChannelOptions;
|
|
30
|
+
dispatch: ChannelMessageHandler;
|
|
31
|
+
isConnected: Ref<boolean>;
|
|
32
|
+
connectionStatus: Ref<ConnectionStatus>;
|
|
33
|
+
isAttached: boolean;
|
|
34
|
+
detachers: Array<() => void>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const KNOWN_STATUSES = new Set<string>(Object.values(CONNECTION_STATUSES));
|
|
38
|
+
|
|
39
|
+
function setStatus(state: ChannelState, status: string): void {
|
|
40
|
+
if (!KNOWN_STATUSES.has(status)) return;
|
|
41
|
+
state.connectionStatus.value = status as ConnectionStatus;
|
|
42
|
+
state.isConnected.value = status === CONNECTION_STATUSES.CONNECTED;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function sendHello(state: ChannelState): void {
|
|
46
|
+
state.options.transport.send({
|
|
47
|
+
type: CLIENT_MESSAGE_TYPES.HELLO,
|
|
48
|
+
role: CHAT_ROLE,
|
|
49
|
+
conversationId: state.options.getConversationId(),
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function attach(state: ChannelState): void {
|
|
54
|
+
const { transport } = state.options;
|
|
55
|
+
state.isAttached = true;
|
|
56
|
+
state.detachers = [
|
|
57
|
+
transport.onMessage(state.dispatch),
|
|
58
|
+
transport.onReady(() => sendHello(state)),
|
|
59
|
+
transport.onStatus((status) => setStatus(state, status)),
|
|
60
|
+
];
|
|
61
|
+
setStatus(state, transport.getStatus());
|
|
62
|
+
if (state.isConnected.value) sendHello(state);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function detach(state: ChannelState): void {
|
|
66
|
+
state.isAttached = false;
|
|
67
|
+
for (const stop of state.detachers) stop();
|
|
68
|
+
state.detachers = [];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface ChatChannel {
|
|
72
|
+
result: UseChatChannelResult;
|
|
73
|
+
/** Listens to the dashboard's stream and says hello once it is connected. */
|
|
74
|
+
start: () => void;
|
|
75
|
+
/** Stops listening: no message reaches the chat after this. */
|
|
76
|
+
stop: () => void;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** The chat's channel without the component lifecycle, which `useChatChannel` adds. */
|
|
80
|
+
export function createChatChannel(options: UseChatChannelOptions): ChatChannel {
|
|
81
|
+
const subscribers = createListeners<unknown>();
|
|
82
|
+
const state: ChannelState = {
|
|
83
|
+
options,
|
|
84
|
+
dispatch: subscribers.emit,
|
|
85
|
+
isConnected: ref(false),
|
|
86
|
+
connectionStatus: ref<ConnectionStatus>(CONNECTION_STATUSES.CONNECTING),
|
|
87
|
+
isAttached: false,
|
|
88
|
+
detachers: [],
|
|
89
|
+
};
|
|
90
|
+
return {
|
|
91
|
+
result: {
|
|
92
|
+
send: (msg) => state.isAttached && options.transport.send(msg),
|
|
93
|
+
onMessage: subscribers.add,
|
|
94
|
+
reconnect: () => options.transport.reconnect(),
|
|
95
|
+
reidentify: () => sendHello(state),
|
|
96
|
+
isConnected: state.isConnected,
|
|
97
|
+
connectionStatus: state.connectionStatus,
|
|
98
|
+
},
|
|
99
|
+
start: () => attach(state),
|
|
100
|
+
stop: () => detach(state),
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The chat's channel to the sidecar: its side of the dashboard's one stream per
|
|
106
|
+
* tab. A `hello` with the conversation goes out on every (re)connection, and
|
|
107
|
+
* the chat stops listening when it unmounts.
|
|
108
|
+
*/
|
|
109
|
+
export function useChatChannel(
|
|
110
|
+
options: UseChatChannelOptions,
|
|
111
|
+
): UseChatChannelResult {
|
|
112
|
+
const channel = createChatChannel(options);
|
|
113
|
+
onMounted(channel.start);
|
|
114
|
+
onBeforeUnmount(channel.stop);
|
|
115
|
+
return channel.result;
|
|
116
|
+
}
|