@copilotkit/vue 2.0.0-rc.0 → 2.0.0-rc.2
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/PARITY.md +13 -12
- package/README.md +1 -2
- package/dist/components/copilot-provider/CopilotKit.vue.d.ts +3 -1
- package/dist/components/copilot-provider/CopilotKit.vue.d.ts.map +1 -1
- package/dist/index.cjs +43 -46
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +10170 -7506
- package/dist/index.mjs.map +1 -1
- package/dist/v2/components/A2UIMessageRenderer.d.ts +7 -0
- package/dist/v2/components/A2UIMessageRenderer.d.ts.map +1 -1
- package/dist/v2/components/A2UISurfaceActivityRenderer.vue.d.ts.map +1 -1
- package/dist/v2/components/a2ui/A2UIBuiltInToolCallRenderer.d.ts +11 -2
- package/dist/v2/components/a2ui/A2UIBuiltInToolCallRenderer.d.ts.map +1 -1
- package/dist/v2/components/a2ui/A2UIRecoveryStates.d.ts +136 -0
- package/dist/v2/components/a2ui/A2UIRecoveryStates.d.ts.map +1 -0
- package/dist/v2/components/chat/BasicMarkdown.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChat.vue.d.ts +1 -0
- package/dist/v2/components/chat/CopilotChat.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatAssistantMessage.vue.d.ts +3 -1
- package/dist/v2/components/chat/CopilotChatAssistantMessage.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatAssistantToolbarButton.vue.d.ts +16 -0
- package/dist/v2/components/chat/CopilotChatAssistantToolbarButton.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatAttachmentQueue.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatAttachmentRenderer.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatAudioRecorder.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatFeedbackCommentPopover.vue.d.ts +22 -0
- package/dist/v2/components/chat/CopilotChatFeedbackCommentPopover.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatInput.vue.d.ts +69 -16
- package/dist/v2/components/chat/CopilotChatInput.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatInspectorButton.vue.d.ts +12 -0
- package/dist/v2/components/chat/CopilotChatInspectorButton.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatLightbox.vue.d.ts +22 -0
- package/dist/v2/components/chat/CopilotChatLightbox.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatMessageView.vue.d.ts +20 -0
- package/dist/v2/components/chat/CopilotChatMessageView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatReasoningMessage.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatSuggestionPill.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatSuggestionView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatToggleButton.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatToolCallGroup.vue.d.ts +32 -0
- package/dist/v2/components/chat/CopilotChatToolCallGroup.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatToolCallItem.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatToolCallsView.vue.d.ts +11 -1
- package/dist/v2/components/chat/CopilotChatToolCallsView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatUserMessage.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatView.vue.d.ts +1 -0
- package/dist/v2/components/chat/CopilotChatView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatWorkSummary.vue.d.ts +5 -0
- package/dist/v2/components/chat/CopilotChatWorkSummary.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotModalHeader.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotModalHeaderCloseButton.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotModalHeaderTitle.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotPopup.vue.d.ts +1 -0
- package/dist/v2/components/chat/CopilotPopup.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotPopupView.vue.d.ts +1 -0
- package/dist/v2/components/chat/CopilotPopupView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotPopupViewInternal.vue.d.ts +1 -0
- package/dist/v2/components/chat/CopilotPopupViewInternal.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotPopupWelcomeScreen.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotSidebar.vue.d.ts +2 -0
- package/dist/v2/components/chat/CopilotSidebar.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotSidebarView.vue.d.ts +2 -0
- package/dist/v2/components/chat/CopilotSidebarView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts +2 -0
- package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotSidebarWelcomeScreen.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/StreamingMarkdownDefault.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/index.d.ts +17 -0
- package/dist/v2/components/chat/index.d.ts.map +1 -1
- package/dist/v2/components/chat/inspector-shortcuts.d.ts +12 -0
- package/dist/v2/components/chat/inspector-shortcuts.d.ts.map +1 -0
- package/dist/v2/components/chat/message-feedback.d.ts +89 -0
- package/dist/v2/components/chat/message-feedback.d.ts.map +1 -0
- package/dist/v2/components/chat/tool-call-capture.d.ts +39 -0
- package/dist/v2/components/chat/tool-call-capture.d.ts.map +1 -0
- package/dist/v2/components/chat/tool-call-display-context.d.ts +39 -0
- package/dist/v2/components/chat/tool-call-display-context.d.ts.map +1 -0
- package/dist/v2/components/chat/tool-call-group-parts.d.ts +144 -0
- package/dist/v2/components/chat/tool-call-group-parts.d.ts.map +1 -0
- package/dist/v2/components/chat/tool-call-layout.d.ts +115 -0
- package/dist/v2/components/chat/tool-call-layout.d.ts.map +1 -0
- package/dist/v2/components/chat/turn-work.d.ts +35 -0
- package/dist/v2/components/chat/turn-work.d.ts.map +1 -0
- package/dist/v2/components/chat/types.d.ts +104 -4
- package/dist/v2/components/chat/types.d.ts.map +1 -1
- package/dist/v2/components/chat/use-lightbox.d.ts +18 -0
- package/dist/v2/components/chat/use-lightbox.d.ts.map +1 -0
- package/dist/v2/components/icons/index.d.ts +1 -1
- package/dist/v2/components/icons/index.d.ts.map +1 -1
- package/dist/v2/components/ui/CopilotDropdownMenuContent.vue.d.ts +55 -0
- package/dist/v2/components/ui/CopilotDropdownMenuContent.vue.d.ts.map +1 -0
- package/dist/v2/components/ui/CopilotPopover.vue.d.ts +40 -0
- package/dist/v2/components/ui/CopilotPopover.vue.d.ts.map +1 -0
- package/dist/v2/components/ui/CopilotTooltip.vue.d.ts +37 -0
- package/dist/v2/components/ui/CopilotTooltip.vue.d.ts.map +1 -0
- package/dist/v2/components/ui/dropdown-menu.d.ts +14 -0
- package/dist/v2/components/ui/dropdown-menu.d.ts.map +1 -0
- package/dist/v2/components/ui/floating.d.ts +84 -0
- package/dist/v2/components/ui/floating.d.ts.map +1 -0
- package/dist/v2/components/ui/presence.d.ts +9 -0
- package/dist/v2/components/ui/presence.d.ts.map +1 -0
- package/dist/v2/components/ui/use-id.d.ts +9 -0
- package/dist/v2/components/ui/use-id.d.ts.map +1 -0
- package/dist/v2/hooks/use-default-render-tool.d.ts +6 -0
- package/dist/v2/hooks/use-default-render-tool.d.ts.map +1 -1
- package/dist/v2/hooks/use-render-tool.d.ts +4 -0
- package/dist/v2/hooks/use-render-tool.d.ts.map +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.d.cts +3 -0
- package/dist/v2/index.d.mts +3 -0
- package/dist/v2/index.d.ts +3 -0
- package/dist/v2/index.d.ts.map +1 -1
- package/dist/v2/index.mjs +165 -162
- package/dist/v2/lib/message-feedback.d.ts +33 -0
- package/dist/v2/lib/message-feedback.d.ts.map +1 -0
- package/dist/v2/providers/CopilotChatConfigurationProvider.vue.d.ts.map +1 -1
- package/dist/v2/providers/CopilotKitProvider.types.d.ts +56 -1
- package/dist/v2/providers/CopilotKitProvider.types.d.ts.map +1 -1
- package/dist/v2/providers/CopilotKitProvider.vue.d.ts +5 -1
- package/dist/v2/providers/CopilotKitProvider.vue.d.ts.map +1 -1
- package/dist/v2/providers/index.d.ts +1 -1
- package/dist/v2/providers/index.d.ts.map +1 -1
- package/dist/v2/providers/keys.d.ts +8 -0
- package/dist/v2/providers/keys.d.ts.map +1 -1
- package/dist/v2/providers/types.d.ts +9 -0
- package/dist/v2/providers/types.d.ts.map +1 -1
- package/dist/v2/styles/CopilotKitStyles.d.ts +18 -0
- package/dist/v2/styles/CopilotKitStyles.d.ts.map +1 -0
- package/dist/v2/types/defineToolCallRenderer.d.ts +2 -0
- package/dist/v2/types/defineToolCallRenderer.d.ts.map +1 -1
- package/dist/v2/types/vue-tool-call-renderer.d.ts +7 -0
- package/dist/v2/types/vue-tool-call-renderer.d.ts.map +1 -1
- package/package.json +11 -23
- package/src/components/copilot-provider/CopilotKit.vue +4 -1
- package/src/v2/__tests__/exports.test.ts +4 -2
- package/src/v2/components/A2UIMessageRenderer.ts +55 -67
- package/src/v2/components/A2UISurfaceActivityRenderer.vue +11 -23
- package/src/v2/components/__tests__/A2UIBasicCatalogColors.test.ts +8 -9
- package/src/v2/components/__tests__/A2UIMessageRenderer.test.ts +63 -36
- package/src/v2/components/a2ui/A2UIBuiltInToolCallRenderer.ts +14 -257
- package/src/v2/components/a2ui/A2UIRecoveryStates.ts +444 -0
- package/src/v2/components/a2ui/__tests__/A2UIRecoveryStates.test.ts +175 -0
- package/src/v2/components/chat/BasicMarkdown.vue +8 -6
- package/src/v2/components/chat/CopilotChat.vue +7 -0
- package/src/v2/components/chat/CopilotChatAssistantMessage.vue +267 -67
- package/src/v2/components/chat/CopilotChatAssistantToolbarButton.vue +46 -0
- package/src/v2/components/chat/CopilotChatAttachmentQueue.vue +141 -168
- package/src/v2/components/chat/CopilotChatAttachmentRenderer.vue +67 -18
- package/src/v2/components/chat/CopilotChatAudioRecorder.vue +2 -2
- package/src/v2/components/chat/CopilotChatFeedbackCommentPopover.vue +240 -0
- package/src/v2/components/chat/CopilotChatInput.vue +210 -161
- package/src/v2/components/chat/CopilotChatInspectorButton.vue +331 -0
- package/src/v2/components/chat/CopilotChatLightbox.vue +105 -0
- package/src/v2/components/chat/CopilotChatMessageView.vue +261 -18
- package/src/v2/components/chat/CopilotChatReasoningMessage.vue +21 -22
- package/src/v2/components/chat/CopilotChatSuggestionPill.vue +5 -14
- package/src/v2/components/chat/CopilotChatSuggestionView.vue +1 -4
- package/src/v2/components/chat/CopilotChatToggleButton.vue +3 -9
- package/src/v2/components/chat/CopilotChatToggleButtonCloseIcon.ts +1 -1
- package/src/v2/components/chat/CopilotChatToggleButtonOpenIcon.ts +1 -1
- package/src/v2/components/chat/CopilotChatToolCallGroup.vue +330 -0
- package/src/v2/components/chat/CopilotChatToolCallItem.vue +21 -11
- package/src/v2/components/chat/CopilotChatToolCallsView.vue +192 -21
- package/src/v2/components/chat/CopilotChatUserMessage.vue +105 -42
- package/src/v2/components/chat/CopilotChatView.vue +33 -38
- package/src/v2/components/chat/CopilotChatWorkSummary.vue +85 -0
- package/src/v2/components/chat/CopilotModalHeader.vue +10 -8
- package/src/v2/components/chat/CopilotModalHeaderCloseButton.ts +7 -6
- package/src/v2/components/chat/CopilotModalHeaderTitle.ts +1 -4
- package/src/v2/components/chat/CopilotPopup.vue +3 -0
- package/src/v2/components/chat/CopilotPopupView.vue +1 -0
- package/src/v2/components/chat/CopilotPopupViewInternal.vue +9 -19
- package/src/v2/components/chat/CopilotPopupWelcomeScreen.vue +5 -8
- package/src/v2/components/chat/CopilotSidebar.vue +5 -0
- package/src/v2/components/chat/CopilotSidebarView.vue +2 -0
- package/src/v2/components/chat/CopilotSidebarViewInternal.vue +24 -17
- package/src/v2/components/chat/CopilotSidebarWelcomeScreen.vue +7 -10
- package/src/v2/components/chat/StreamingMarkdownDefault.vue +3 -5
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.inspector.test.ts +269 -0
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.learningFeedback.test.ts +760 -0
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.slots.e2e.test.ts +3 -5
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.test.ts +2 -2
- package/src/v2/components/chat/__tests__/CopilotChatInput.addMenu.test.ts +328 -0
- package/src/v2/components/chat/__tests__/CopilotChatInput.slots.e2e.test.ts +6 -3
- package/src/v2/components/chat/__tests__/CopilotChatInput.test.ts +22 -13
- package/src/v2/components/chat/__tests__/CopilotChatLightbox.test.ts +160 -0
- package/src/v2/components/chat/__tests__/CopilotChatMessageView.toolCallDisplay.test.ts +735 -0
- package/src/v2/components/chat/__tests__/CopilotChatSuggestionPill.test.ts +1 -1
- package/src/v2/components/chat/__tests__/CopilotChatSuggestionView.slots.e2e.test.ts +3 -1
- package/src/v2/components/chat/__tests__/CopilotChatToolCallsView.learning.test.ts +75 -0
- package/src/v2/components/chat/__tests__/CopilotChatUserMessage.attachments.test.ts +143 -0
- package/src/v2/components/chat/__tests__/CopilotChatView.inputOverlay.test.ts +5 -4
- package/src/v2/components/chat/__tests__/CopilotChatView.rootWidth.test.ts +7 -33
- package/src/v2/components/chat/__tests__/CopilotModalHeader.slots.e2e.test.ts +1 -1
- package/src/v2/components/chat/__tests__/CopilotPopupView.slots.e2e.test.ts +3 -3
- package/src/v2/components/chat/__tests__/CopilotSidebarView.position.test.ts +126 -0
- package/src/v2/components/chat/__tests__/messageFeedbackDefaults.test.ts +33 -0
- package/src/v2/components/chat/__tests__/modalChatDisplayProps.test.ts +44 -0
- package/src/v2/components/chat/index.ts +2 -0
- package/src/v2/components/chat/inspector-shortcuts.ts +34 -0
- package/src/v2/components/chat/message-feedback.ts +291 -0
- package/src/v2/components/chat/tool-call-capture.ts +55 -0
- package/src/v2/components/chat/tool-call-display-context.ts +49 -0
- package/src/v2/components/chat/tool-call-group-parts.ts +292 -0
- package/src/v2/components/chat/tool-call-layout.ts +304 -0
- package/src/v2/components/chat/turn-work.ts +61 -0
- package/src/v2/components/chat/types.ts +113 -3
- package/src/v2/components/chat/use-lightbox.ts +64 -0
- package/src/v2/components/icons/index.ts +4 -0
- package/src/v2/components/ui/CopilotDropdownMenuContent.vue +465 -0
- package/src/v2/components/ui/CopilotPopover.vue +138 -0
- package/src/v2/components/ui/CopilotTooltip.vue +237 -0
- package/src/v2/components/ui/__tests__/CopilotTooltip.test.ts +168 -0
- package/src/v2/components/ui/dropdown-menu.ts +15 -0
- package/src/v2/components/ui/floating.ts +321 -0
- package/src/v2/components/ui/presence.ts +54 -0
- package/src/v2/components/ui/use-id.ts +16 -0
- package/src/v2/hooks/use-default-render-tool.ts +123 -62
- package/src/v2/hooks/use-render-tool.ts +8 -0
- package/src/v2/index.ts +3 -0
- package/src/v2/lib/__tests__/message-feedback.test.ts +152 -0
- package/src/v2/lib/message-feedback.ts +120 -0
- package/src/v2/providers/CopilotChatConfigurationProvider.vue +29 -2
- package/src/v2/providers/CopilotKitProvider.types.ts +57 -0
- package/src/v2/providers/CopilotKitProvider.vue +125 -3
- package/src/v2/providers/__tests__/CopilotChatConfigurationProvider.openThread.test.ts +69 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.learning.test.ts +534 -0
- package/src/v2/providers/index.ts +4 -1
- package/src/v2/providers/keys.ts +12 -0
- package/src/v2/providers/types.ts +11 -0
- package/src/v2/styles/CopilotKitStyles.ts +95 -0
- package/src/v2/styles/__tests__/CopilotKitStyles.client.test.ts +149 -0
- package/src/v2/styles/__tests__/CopilotKitStyles.ssr.test.ts +71 -0
- package/src/v2/types/defineToolCallRenderer.ts +4 -0
- package/src/v2/types/vue-tool-call-renderer.ts +7 -0
- package/vite.config.ts +2 -1
- package/dist/styles.css +0 -2
- package/scripts/scope-preflight.mjs +0 -100
- package/src/styles/globals.css +0 -233
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { watch } from "vue";
|
|
2
2
|
import type { ShallowRef } from "vue";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
-
import type { ToolCallStatus } from "@copilotkit/core";
|
|
5
4
|
import type { CopilotKitCoreVue } from "../../lib/vue-core";
|
|
6
5
|
import { defineToolCallRenderer } from "../../types/defineToolCallRenderer";
|
|
7
6
|
|
|
@@ -12,8 +11,17 @@ import { defineToolCallRenderer } from "../../types/defineToolCallRenderer";
|
|
|
12
11
|
export const RENDER_A2UI_TOOL_NAME = "render_a2ui";
|
|
13
12
|
|
|
14
13
|
/**
|
|
15
|
-
* Registers
|
|
16
|
-
*
|
|
14
|
+
* Registers a no-op renderer for the `render_a2ui` tool call so its raw
|
|
15
|
+
* streamed args are never surfaced in the transcript, as React does.
|
|
16
|
+
*
|
|
17
|
+
* The generation skeleton / retry / failure UX is not owned here: the A2UI
|
|
18
|
+
* middleware drives the whole lifecycle on the `a2ui-surface` activity (one
|
|
19
|
+
* stable messageId, building → retrying → failed → painted), rendered in place
|
|
20
|
+
* by `createA2UIMessageRenderer`. A skeleton per tool call would duplicate on
|
|
21
|
+
* retries and multi-call generations and linger after the surface painted.
|
|
22
|
+
*
|
|
23
|
+
* The renderer is registered via the props-based `setRenderToolCalls`
|
|
24
|
+
* mechanism (not `useRenderTool`).
|
|
17
25
|
*
|
|
18
26
|
* This ensures user-registered `useRenderTool({ name: "render_a2ui", ... })`
|
|
19
27
|
* hooks automatically override the built-in, since the merge logic in
|
|
@@ -33,23 +41,8 @@ export function registerA2UIBuiltInToolCallRenderer(
|
|
|
33
41
|
const renderer = defineToolCallRenderer({
|
|
34
42
|
name: RENDER_A2UI_TOOL_NAME,
|
|
35
43
|
args: z.any(),
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
args: parameters,
|
|
39
|
-
}: {
|
|
40
|
-
status: ToolCallStatus;
|
|
41
|
-
args: unknown;
|
|
42
|
-
[key: string]: unknown;
|
|
43
|
-
}): VNodeChild => {
|
|
44
|
-
if (status === "complete") return null;
|
|
45
|
-
const params = parameters as Record<string, unknown>;
|
|
46
|
-
// Hide skeleton once the A2UI surface has enough data to render.
|
|
47
|
-
const items = params?.items;
|
|
48
|
-
if (Array.isArray(items) && items.length > 0) return null;
|
|
49
|
-
const components = params?.components;
|
|
50
|
-
if (Array.isArray(components) && components.length > 2) return null;
|
|
51
|
-
return renderA2UIProgressIndicator(parameters);
|
|
52
|
-
},
|
|
44
|
+
// Render nothing: the a2ui-surface activity owns all generation UX.
|
|
45
|
+
render: () => null,
|
|
53
46
|
});
|
|
54
47
|
|
|
55
48
|
// Register via props-based mechanism so useRenderTool hooks take priority
|
|
@@ -64,244 +57,8 @@ export function registerA2UIBuiltInToolCallRenderer(
|
|
|
64
57
|
core.setRenderToolCalls(
|
|
65
58
|
current.filter((rc) => rc.name !== RENDER_A2UI_TOOL_NAME),
|
|
66
59
|
);
|
|
67
|
-
progressState.clear();
|
|
68
60
|
});
|
|
69
61
|
},
|
|
70
62
|
{ immediate: true },
|
|
71
63
|
);
|
|
72
64
|
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Vue render-function equivalent of the React A2UIProgressIndicator.
|
|
76
|
-
* Shows a skeleton wireframe that progressively reveals as tokens stream in.
|
|
77
|
-
*/
|
|
78
|
-
const progressState = new Map<
|
|
79
|
-
string,
|
|
80
|
-
{ lastTime: number; lastTokens: number }
|
|
81
|
-
>();
|
|
82
|
-
|
|
83
|
-
function renderA2UIProgressIndicator(parameters: unknown): VNodeChild {
|
|
84
|
-
const params = parameters as Record<string, unknown> | null | undefined;
|
|
85
|
-
const key = typeof params?.name === "string" ? params.name : "__default__";
|
|
86
|
-
let state = progressState.get(key);
|
|
87
|
-
if (!state) {
|
|
88
|
-
state = { lastTime: 0, lastTokens: 0 };
|
|
89
|
-
progressState.set(key, state);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const now = Date.now();
|
|
93
|
-
let tokens = state.lastTokens;
|
|
94
|
-
if (now - state.lastTime > 200) {
|
|
95
|
-
const chars = JSON.stringify(parameters ?? {}).length;
|
|
96
|
-
tokens = Math.round(chars / 4);
|
|
97
|
-
state.lastTime = now;
|
|
98
|
-
state.lastTokens = tokens;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const phase = tokens < 50 ? 0 : tokens < 200 ? 1 : tokens < 400 ? 2 : 3;
|
|
102
|
-
|
|
103
|
-
const dot = () =>
|
|
104
|
-
h("div", {
|
|
105
|
-
style: {
|
|
106
|
-
width: "7px",
|
|
107
|
-
height: "7px",
|
|
108
|
-
borderRadius: "50%",
|
|
109
|
-
backgroundColor: "#d4d4d8",
|
|
110
|
-
flexShrink: 0,
|
|
111
|
-
},
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
const spacer = () => h("div", { style: { width: "12px" } });
|
|
115
|
-
|
|
116
|
-
const bar = (
|
|
117
|
-
w: number,
|
|
118
|
-
ht: number,
|
|
119
|
-
bg: string,
|
|
120
|
-
anim?: number,
|
|
121
|
-
opacity?: number,
|
|
122
|
-
transition?: string,
|
|
123
|
-
) =>
|
|
124
|
-
h("div", {
|
|
125
|
-
style: {
|
|
126
|
-
width: `${w}px`,
|
|
127
|
-
height: `${ht}px`,
|
|
128
|
-
borderRadius: "9999px",
|
|
129
|
-
backgroundColor: bg,
|
|
130
|
-
...(anim !== undefined
|
|
131
|
-
? {
|
|
132
|
-
animation: `cpk-a2ui-fade 2.4s ease-in-out ${anim}s infinite`,
|
|
133
|
-
}
|
|
134
|
-
: {}),
|
|
135
|
-
...(opacity !== undefined ? { opacity } : {}),
|
|
136
|
-
...(transition ? { transition } : {}),
|
|
137
|
-
},
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
const row = (show: boolean, delay: number, children: VNodeChild[]) =>
|
|
141
|
-
h(
|
|
142
|
-
"div",
|
|
143
|
-
{
|
|
144
|
-
style: {
|
|
145
|
-
display: "flex",
|
|
146
|
-
alignItems: "center",
|
|
147
|
-
gap: "6px",
|
|
148
|
-
opacity: show ? 1 : 0,
|
|
149
|
-
transition: `opacity 0.4s ${delay}s`,
|
|
150
|
-
},
|
|
151
|
-
},
|
|
152
|
-
children,
|
|
153
|
-
);
|
|
154
|
-
|
|
155
|
-
return h("div", { style: { margin: "12px 0", maxWidth: "320px" } }, [
|
|
156
|
-
h(
|
|
157
|
-
"div",
|
|
158
|
-
{
|
|
159
|
-
style: {
|
|
160
|
-
position: "relative",
|
|
161
|
-
overflow: "hidden",
|
|
162
|
-
borderRadius: "12px",
|
|
163
|
-
border: "1px solid rgba(228,228,231,0.8)",
|
|
164
|
-
backgroundColor: "#fff",
|
|
165
|
-
boxShadow: "0 1px 2px rgba(0,0,0,0.04)",
|
|
166
|
-
padding: "16px 18px 14px",
|
|
167
|
-
},
|
|
168
|
-
},
|
|
169
|
-
[
|
|
170
|
-
// Top bar
|
|
171
|
-
h(
|
|
172
|
-
"div",
|
|
173
|
-
{
|
|
174
|
-
style: {
|
|
175
|
-
display: "flex",
|
|
176
|
-
alignItems: "center",
|
|
177
|
-
gap: "8px",
|
|
178
|
-
marginBottom: "12px",
|
|
179
|
-
},
|
|
180
|
-
},
|
|
181
|
-
[
|
|
182
|
-
h("div", { style: { display: "flex", gap: "4px" } }, [
|
|
183
|
-
dot(),
|
|
184
|
-
dot(),
|
|
185
|
-
dot(),
|
|
186
|
-
]),
|
|
187
|
-
bar(
|
|
188
|
-
64,
|
|
189
|
-
6,
|
|
190
|
-
"#e4e4e7",
|
|
191
|
-
undefined,
|
|
192
|
-
phase >= 1 ? 1 : 0.4,
|
|
193
|
-
"opacity 0.5s",
|
|
194
|
-
),
|
|
195
|
-
],
|
|
196
|
-
),
|
|
197
|
-
// Skeleton lines
|
|
198
|
-
h("div", { style: { display: "grid", gap: "7px" } }, [
|
|
199
|
-
row(phase >= 0, 0, [
|
|
200
|
-
bar(36, 7, "rgba(147,197,253,0.7)", 0),
|
|
201
|
-
bar(80, 7, "rgba(219,234,254,0.8)", 0.2),
|
|
202
|
-
]),
|
|
203
|
-
row(phase >= 0, 0.1, [
|
|
204
|
-
spacer(),
|
|
205
|
-
dot(),
|
|
206
|
-
bar(100, 7, "rgba(24,24,27,0.2)", 0.3),
|
|
207
|
-
]),
|
|
208
|
-
row(phase >= 1, 0.15, [
|
|
209
|
-
spacer(),
|
|
210
|
-
bar(48, 7, "rgba(24,24,27,0.15)", 0.1),
|
|
211
|
-
bar(40, 7, "rgba(153,246,228,0.6)", 0.5),
|
|
212
|
-
bar(56, 7, "rgba(147,197,253,0.6)", 0.3),
|
|
213
|
-
]),
|
|
214
|
-
row(phase >= 1, 0.2, [
|
|
215
|
-
spacer(),
|
|
216
|
-
dot(),
|
|
217
|
-
bar(60, 7, "rgba(24,24,27,0.15)", 0.4),
|
|
218
|
-
]),
|
|
219
|
-
row(phase >= 2, 0.25, [
|
|
220
|
-
bar(40, 7, "rgba(153,246,228,0.5)", 0.2),
|
|
221
|
-
dot(),
|
|
222
|
-
bar(48, 7, "rgba(24,24,27,0.15)", 0.6),
|
|
223
|
-
bar(64, 7, "rgba(147,197,253,0.5)", 0.1),
|
|
224
|
-
]),
|
|
225
|
-
row(phase >= 2, 0.3, [
|
|
226
|
-
bar(36, 7, "rgba(147,197,253,0.6)", 0.5),
|
|
227
|
-
bar(36, 7, "rgba(24,24,27,0.12)", 0.7),
|
|
228
|
-
]),
|
|
229
|
-
row(phase >= 3, 0.35, [
|
|
230
|
-
dot(),
|
|
231
|
-
bar(44, 7, "rgba(24,24,27,0.18)", 0.3),
|
|
232
|
-
dot(),
|
|
233
|
-
bar(56, 7, "rgba(153,246,228,0.5)", 0.8),
|
|
234
|
-
bar(48, 7, "rgba(147,197,253,0.5)", 0.4),
|
|
235
|
-
]),
|
|
236
|
-
]),
|
|
237
|
-
// Shimmer
|
|
238
|
-
h("div", {
|
|
239
|
-
style: {
|
|
240
|
-
pointerEvents: "none",
|
|
241
|
-
position: "absolute",
|
|
242
|
-
inset: "0",
|
|
243
|
-
background:
|
|
244
|
-
"linear-gradient(105deg, transparent 0%, transparent 40%, rgba(255,255,255,0.6) 50%, transparent 60%, transparent 100%)",
|
|
245
|
-
backgroundSize: "250% 100%",
|
|
246
|
-
animation: "cpk-a2ui-sweep 3s ease-in-out infinite",
|
|
247
|
-
},
|
|
248
|
-
}),
|
|
249
|
-
],
|
|
250
|
-
),
|
|
251
|
-
// Label
|
|
252
|
-
h(
|
|
253
|
-
"div",
|
|
254
|
-
{
|
|
255
|
-
style: {
|
|
256
|
-
display: "flex",
|
|
257
|
-
alignItems: "center",
|
|
258
|
-
justifyContent: "center",
|
|
259
|
-
gap: "8px",
|
|
260
|
-
marginTop: "8px",
|
|
261
|
-
},
|
|
262
|
-
},
|
|
263
|
-
[
|
|
264
|
-
h(
|
|
265
|
-
"span",
|
|
266
|
-
{
|
|
267
|
-
style: {
|
|
268
|
-
fontSize: "12px",
|
|
269
|
-
color: "#a1a1aa",
|
|
270
|
-
letterSpacing: "0.025em",
|
|
271
|
-
},
|
|
272
|
-
},
|
|
273
|
-
"Building interface",
|
|
274
|
-
),
|
|
275
|
-
...(tokens > 0
|
|
276
|
-
? [
|
|
277
|
-
h(
|
|
278
|
-
"span",
|
|
279
|
-
{
|
|
280
|
-
style: {
|
|
281
|
-
fontSize: "11px",
|
|
282
|
-
color: "#d4d4d8",
|
|
283
|
-
fontVariantNumeric: "tabular-nums",
|
|
284
|
-
},
|
|
285
|
-
},
|
|
286
|
-
`~${tokens.toLocaleString()} tokens`,
|
|
287
|
-
),
|
|
288
|
-
]
|
|
289
|
-
: []),
|
|
290
|
-
],
|
|
291
|
-
),
|
|
292
|
-
// Keyframe styles
|
|
293
|
-
h(
|
|
294
|
-
"style",
|
|
295
|
-
`
|
|
296
|
-
@keyframes cpk-a2ui-fade {
|
|
297
|
-
0%, 100% { opacity: 1; }
|
|
298
|
-
50% { opacity: 0.5; }
|
|
299
|
-
}
|
|
300
|
-
@keyframes cpk-a2ui-sweep {
|
|
301
|
-
0% { background-position: 250% 0; }
|
|
302
|
-
100% { background-position: -250% 0; }
|
|
303
|
-
}
|
|
304
|
-
`,
|
|
305
|
-
),
|
|
306
|
-
]);
|
|
307
|
-
}
|