remotion-claude-agent-demo 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/README.md +160 -0
  2. package/apps/web/README.md +36 -0
  3. package/apps/web/env.example +20 -0
  4. package/apps/web/eslint.config.mjs +18 -0
  5. package/apps/web/next.config.ts +7 -0
  6. package/apps/web/package-lock.json +10348 -0
  7. package/apps/web/package.json +35 -0
  8. package/apps/web/postcss.config.mjs +7 -0
  9. package/apps/web/public/file.svg +1 -0
  10. package/apps/web/public/globe.svg +1 -0
  11. package/apps/web/public/next.svg +1 -0
  12. package/apps/web/public/vercel.svg +1 -0
  13. package/apps/web/public/window.svg +1 -0
  14. package/apps/web/src/app/.well-known/agent-card.json/route.ts +50 -0
  15. package/apps/web/src/app/background-tasks/[jobId]/cancel/route.ts +29 -0
  16. package/apps/web/src/app/events/stream/route.ts +58 -0
  17. package/apps/web/src/app/favicon.ico +0 -0
  18. package/apps/web/src/app/globals.css +174 -0
  19. package/apps/web/src/app/layout.tsx +34 -0
  20. package/apps/web/src/app/messages/answer/route.ts +57 -0
  21. package/apps/web/src/app/messages/stream/route.ts +381 -0
  22. package/apps/web/src/app/page.tsx +358 -0
  23. package/apps/web/src/app/tasks/[taskId]/cancel/route.ts +24 -0
  24. package/apps/web/src/app/tasks/[taskId]/route.ts +24 -0
  25. package/apps/web/src/app/tasks/route.ts +13 -0
  26. package/apps/web/src/components/chat/agent-blocks.tsx +111 -0
  27. package/apps/web/src/components/chat/ask-user-question-panel.tsx +172 -0
  28. package/apps/web/src/components/chat/session-sidebar.tsx +222 -0
  29. package/apps/web/src/components/chat/subagent-activity-sidebar.tsx +248 -0
  30. package/apps/web/src/components/chat/tool-blocks.tsx +550 -0
  31. package/apps/web/src/lib/a2a/activity-store.ts +150 -0
  32. package/apps/web/src/lib/a2a/client.ts +357 -0
  33. package/apps/web/src/lib/a2a/sse.ts +19 -0
  34. package/apps/web/src/lib/a2a/task-store.ts +111 -0
  35. package/apps/web/src/lib/a2a/types.ts +216 -0
  36. package/apps/web/src/lib/agent/answer-store.ts +109 -0
  37. package/apps/web/src/lib/agent/background-delivery.ts +343 -0
  38. package/apps/web/src/lib/agent/background-tool.ts +78 -0
  39. package/apps/web/src/lib/agent/background.ts +452 -0
  40. package/apps/web/src/lib/agent/chat.ts +543 -0
  41. package/apps/web/src/lib/agent/session-store.ts +26 -0
  42. package/apps/web/src/lib/chat/types.ts +44 -0
  43. package/apps/web/src/lib/env.ts +31 -0
  44. package/apps/web/src/lib/hooks/useA2AChat.ts +863 -0
  45. package/apps/web/src/lib/state/chat-atoms.ts +52 -0
  46. package/apps/web/src/lib/workspace.ts +9 -0
  47. package/apps/web/tsconfig.json +35 -0
  48. package/bin/remotion-agent.js +451 -0
  49. package/package.json +34 -0
  50. package/templates/.claude/CLAUDE.md +95 -0
  51. package/templates/.claude/README.md +129 -0
  52. package/templates/.claude/agents/composer-agent.md +188 -0
  53. package/templates/.claude/agents/crafter.md +181 -0
  54. package/templates/.claude/agents/creator.md +134 -0
  55. package/templates/.claude/agents/perceiver.md +92 -0
  56. package/templates/.claude/settings.json +36 -0
  57. package/templates/.claude/settings.local.json +39 -0
  58. package/templates/.claude/skills/agent-browser/SKILL.md +349 -0
  59. package/templates/.claude/skills/agent-browser/references/authentication.md +188 -0
  60. package/templates/.claude/skills/agent-browser/references/proxy-support.md +175 -0
  61. package/templates/.claude/skills/agent-browser/references/session-management.md +181 -0
  62. package/templates/.claude/skills/agent-browser/references/snapshot-refs.md +186 -0
  63. package/templates/.claude/skills/agent-browser/references/video-recording.md +162 -0
  64. package/templates/.claude/skills/agent-browser/templates/authenticated-session.sh +91 -0
  65. package/templates/.claude/skills/agent-browser/templates/capture-workflow.sh +68 -0
  66. package/templates/.claude/skills/agent-browser/templates/form-automation.sh +64 -0
  67. package/templates/.claude/skills/algorithmic-art/LICENSE.txt +202 -0
  68. package/templates/.claude/skills/algorithmic-art/SKILL.md +405 -0
  69. package/templates/.claude/skills/algorithmic-art/templates/generator_template.js +223 -0
  70. package/templates/.claude/skills/algorithmic-art/templates/viewer.html +599 -0
  71. package/templates/.claude/skills/asset-validator/SKILL.md +376 -0
  72. package/templates/.claude/skills/audio-video-sync/SKILL.md +219 -0
  73. package/templates/.claude/skills/bgm-manager/SKILL.md +334 -0
  74. package/templates/.claude/skills/remotion-best-practices/SKILL.md +45 -0
  75. package/templates/.claude/skills/remotion-best-practices/rules/3d.md +86 -0
  76. package/templates/.claude/skills/remotion-best-practices/rules/animations.md +29 -0
  77. package/templates/.claude/skills/remotion-best-practices/rules/assets/charts-bar-chart.tsx +173 -0
  78. package/templates/.claude/skills/remotion-best-practices/rules/assets/text-animations-typewriter.tsx +100 -0
  79. package/templates/.claude/skills/remotion-best-practices/rules/assets/text-animations-word-highlight.tsx +108 -0
  80. package/templates/.claude/skills/remotion-best-practices/rules/assets.md +78 -0
  81. package/templates/.claude/skills/remotion-best-practices/rules/audio.md +172 -0
  82. package/templates/.claude/skills/remotion-best-practices/rules/calculate-metadata.md +104 -0
  83. package/templates/.claude/skills/remotion-best-practices/rules/can-decode.md +75 -0
  84. package/templates/.claude/skills/remotion-best-practices/rules/charts.md +58 -0
  85. package/templates/.claude/skills/remotion-best-practices/rules/compositions.md +141 -0
  86. package/templates/.claude/skills/remotion-best-practices/rules/display-captions.md +126 -0
  87. package/templates/.claude/skills/remotion-best-practices/rules/extract-frames.md +229 -0
  88. package/templates/.claude/skills/remotion-best-practices/rules/fonts.md +152 -0
  89. package/templates/.claude/skills/remotion-best-practices/rules/get-audio-duration.md +58 -0
  90. package/templates/.claude/skills/remotion-best-practices/rules/get-video-dimensions.md +68 -0
  91. package/templates/.claude/skills/remotion-best-practices/rules/get-video-duration.md +58 -0
  92. package/templates/.claude/skills/remotion-best-practices/rules/gifs.md +138 -0
  93. package/templates/.claude/skills/remotion-best-practices/rules/images.md +130 -0
  94. package/templates/.claude/skills/remotion-best-practices/rules/import-srt-captions.md +67 -0
  95. package/templates/.claude/skills/remotion-best-practices/rules/lottie.md +68 -0
  96. package/templates/.claude/skills/remotion-best-practices/rules/maps.md +403 -0
  97. package/templates/.claude/skills/remotion-best-practices/rules/measuring-dom-nodes.md +35 -0
  98. package/templates/.claude/skills/remotion-best-practices/rules/measuring-text.md +143 -0
  99. package/templates/.claude/skills/remotion-best-practices/rules/parameters.md +98 -0
  100. package/templates/.claude/skills/remotion-best-practices/rules/sequencing.md +118 -0
  101. package/templates/.claude/skills/remotion-best-practices/rules/tailwind.md +11 -0
  102. package/templates/.claude/skills/remotion-best-practices/rules/text-animations.md +20 -0
  103. package/templates/.claude/skills/remotion-best-practices/rules/timing.md +179 -0
  104. package/templates/.claude/skills/remotion-best-practices/rules/transcribe-captions.md +19 -0
  105. package/templates/.claude/skills/remotion-best-practices/rules/transitions.md +122 -0
  106. package/templates/.claude/skills/remotion-best-practices/rules/trimming.md +53 -0
  107. package/templates/.claude/skills/remotion-best-practices/rules/videos.md +171 -0
  108. package/templates/.claude/skills/remotion-components/SKILL.md +453 -0
  109. package/templates/.claude/skills/render-config/SKILL.md +290 -0
  110. package/templates/.claude/skills/script-writer/SKILL.md +59 -0
  111. package/templates/.claude/skills/style-director/script-writer/SKILL.md +82 -0
  112. package/templates/.claude/skills/style-director/style-director/SKILL.md +287 -0
  113. package/templates/.claude/skills/style-director/style-director/references/audience-and-scenarios.md +43 -0
  114. package/templates/.claude/skills/style-director/style-director/references/interaction-innovation.md +26 -0
  115. package/templates/.claude/skills/style-director/style-director/references/motion-grammar.md +66 -0
  116. package/templates/.claude/skills/style-director/style-director/references/quality-checklist.md +29 -0
  117. package/templates/.claude/skills/style-director/style-director/references/scene-recipes.md +38 -0
  118. package/templates/.claude/skills/style-director/style-director/references/visual-style-system.md +148 -0
  119. package/templates/.claude/skills/subtitle-composer/SKILL.md +304 -0
  120. package/templates/.claude/skills/subtitle-processor/SKILL.md +308 -0
  121. package/templates/.claude/skills/timeline-generator/SKILL.md +253 -0
  122. package/templates/.claude/skills/video-preflight-check/SKILL.md +353 -0
  123. package/templates/.claude/skills/voice-synthesizer/SKILL.md +296 -0
  124. package/templates/.claude/skills/voice-synthesizer/scripts/synthesize_voice.py +315 -0
  125. package/templates/.claude/skills/voice-synthesizer/scripts/tts_cli.py +142 -0
  126. package/templates/.claude/skills/web-design-guidelines/SKILL.md +36 -0
  127. package/templates/.claude/skills/youtube-downloader/SKILL.md +99 -0
  128. package/templates/.claude/skills/youtube-downloader/scripts/download_video.py +145 -0
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "web",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "scripts": {
6
+ "dev": "next dev",
7
+ "build": "next build",
8
+ "start": "next start",
9
+ "lint": "eslint"
10
+ },
11
+ "dependencies": {
12
+ "@anthropic-ai/claude-agent-sdk": "^0.2.19",
13
+ "@streamdown/cjk": "^1.0.1",
14
+ "@streamdown/code": "^1.0.1",
15
+ "@streamdown/math": "^1.0.1",
16
+ "@streamdown/mermaid": "^1.0.1",
17
+ "jotai": "^2.10.0",
18
+ "lucide-react": "^0.475.0",
19
+ "next": "16.1.4",
20
+ "react": "19.2.3",
21
+ "react-dom": "19.2.3",
22
+ "streamdown": "^2.1.0",
23
+ "zod": "^4.3.6"
24
+ },
25
+ "devDependencies": {
26
+ "@tailwindcss/postcss": "^4",
27
+ "@types/node": "^20",
28
+ "@types/react": "^19",
29
+ "@types/react-dom": "^19",
30
+ "eslint": "^9",
31
+ "eslint-config-next": "16.1.4",
32
+ "tailwindcss": "^4",
33
+ "typescript": "^5"
34
+ }
35
+ }
@@ -0,0 +1,7 @@
1
+ const config = {
2
+ plugins: {
3
+ "@tailwindcss/postcss": {},
4
+ },
5
+ };
6
+
7
+ export default config;
@@ -0,0 +1 @@
1
+ <svg fill="none" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M14.5 13.5V5.41a1 1 0 0 0-.3-.7L9.8.29A1 1 0 0 0 9.08 0H1.5v13.5A2.5 2.5 0 0 0 4 16h8a2.5 2.5 0 0 0 2.5-2.5m-1.5 0v-7H8v-5H3v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1M9.5 5V2.12L12.38 5zM5.13 5h-.62v1.25h2.12V5zm-.62 3h7.12v1.25H4.5zm.62 3h-.62v1.25h7.12V11z" clip-rule="evenodd" fill="#666" fill-rule="evenodd"/></svg>
@@ -0,0 +1 @@
1
+ <svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><g clip-path="url(#a)"><path fill-rule="evenodd" clip-rule="evenodd" d="M10.27 14.1a6.5 6.5 0 0 0 3.67-3.45q-1.24.21-2.7.34-.31 1.83-.97 3.1M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16m.48-1.52a7 7 0 0 1-.96 0H7.5a4 4 0 0 1-.84-1.32q-.38-.89-.63-2.08a40 40 0 0 0 3.92 0q-.25 1.2-.63 2.08a4 4 0 0 1-.84 1.31zm2.94-4.76q1.66-.15 2.95-.43a7 7 0 0 0 0-2.58q-1.3-.27-2.95-.43a18 18 0 0 1 0 3.44m-1.27-3.54a17 17 0 0 1 0 3.64 39 39 0 0 1-4.3 0 17 17 0 0 1 0-3.64 39 39 0 0 1 4.3 0m1.1-1.17q1.45.13 2.69.34a6.5 6.5 0 0 0-3.67-3.44q.65 1.26.98 3.1M8.48 1.5l.01.02q.41.37.84 1.31.38.89.63 2.08a40 40 0 0 0-3.92 0q.25-1.2.63-2.08a4 4 0 0 1 .85-1.32 7 7 0 0 1 .96 0m-2.75.4a6.5 6.5 0 0 0-3.67 3.44 29 29 0 0 1 2.7-.34q.31-1.83.97-3.1M4.58 6.28q-1.66.16-2.95.43a7 7 0 0 0 0 2.58q1.3.27 2.95.43a18 18 0 0 1 0-3.44m.17 4.71q-1.45-.12-2.69-.34a6.5 6.5 0 0 0 3.67 3.44q-.65-1.27-.98-3.1" fill="#666"/></g><defs><clipPath id="a"><path fill="#fff" d="M0 0h16v16H0z"/></clipPath></defs></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 394 80"><path fill="#000" d="M262 0h68.5v12.7h-27.2v66.6h-13.6V12.7H262V0ZM149 0v12.7H94v20.4h44.3v12.6H94v21h55v12.6H80.5V0h68.7zm34.3 0h-17.8l63.8 79.4h17.9l-32-39.7 32-39.6h-17.9l-23 28.6-23-28.6zm18.3 56.7-9-11-27.1 33.7h17.8l18.3-22.7z"/><path fill="#000" d="M81 79.3 17 0H0v79.3h13.6V17l50.2 62.3H81Zm252.6-.4c-1 0-1.8-.4-2.5-1s-1.1-1.6-1.1-2.6.3-1.8 1-2.5 1.6-1 2.6-1 1.8.3 2.5 1a3.4 3.4 0 0 1 .6 4.3 3.7 3.7 0 0 1-3 1.8zm23.2-33.5h6v23.3c0 2.1-.4 4-1.3 5.5a9.1 9.1 0 0 1-3.8 3.5c-1.6.8-3.5 1.3-5.7 1.3-2 0-3.7-.4-5.3-1s-2.8-1.8-3.7-3.2c-.9-1.3-1.4-3-1.4-5h6c.1.8.3 1.6.7 2.2s1 1.2 1.6 1.5c.7.4 1.5.5 2.4.5 1 0 1.8-.2 2.4-.6a4 4 0 0 0 1.6-1.8c.3-.8.5-1.8.5-3V45.5zm30.9 9.1a4.4 4.4 0 0 0-2-3.3 7.5 7.5 0 0 0-4.3-1.1c-1.3 0-2.4.2-3.3.5-.9.4-1.6 1-2 1.6a3.5 3.5 0 0 0-.3 4c.3.5.7.9 1.3 1.2l1.8 1 2 .5 3.2.8c1.3.3 2.5.7 3.7 1.2a13 13 0 0 1 3.2 1.8 8.1 8.1 0 0 1 3 6.5c0 2-.5 3.7-1.5 5.1a10 10 0 0 1-4.4 3.5c-1.8.8-4.1 1.2-6.8 1.2-2.6 0-4.9-.4-6.8-1.2-2-.8-3.4-2-4.5-3.5a10 10 0 0 1-1.7-5.6h6a5 5 0 0 0 3.5 4.6c1 .4 2.2.6 3.4.6 1.3 0 2.5-.2 3.5-.6 1-.4 1.8-1 2.4-1.7a4 4 0 0 0 .8-2.4c0-.9-.2-1.6-.7-2.2a11 11 0 0 0-2.1-1.4l-3.2-1-3.8-1c-2.8-.7-5-1.7-6.6-3.2a7.2 7.2 0 0 1-2.4-5.7 8 8 0 0 1 1.7-5 10 10 0 0 1 4.3-3.5c2-.8 4-1.2 6.4-1.2 2.3 0 4.4.4 6.2 1.2 1.8.8 3.2 2 4.3 3.4 1 1.4 1.5 3 1.5 5h-5.8z"/></svg>
@@ -0,0 +1 @@
1
+ <svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1155 1000"><path d="m577.3 0 577.4 1000H0z" fill="#fff"/></svg>
@@ -0,0 +1 @@
1
+ <svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill-rule="evenodd" clip-rule="evenodd" d="M1.5 2.5h13v10a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1zM0 1h16v11.5a2.5 2.5 0 0 1-2.5 2.5h-11A2.5 2.5 0 0 1 0 12.5zm3.75 4.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5M7 4.75a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0m1.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5" fill="#666"/></svg>
@@ -0,0 +1,50 @@
1
+ import { NextResponse } from "next/server";
2
+
3
+ import { getEnv } from "@/lib/env";
4
+
5
+ export const runtime = "nodejs";
6
+
7
+ export async function GET(request: Request) {
8
+ const env = getEnv();
9
+ const url = new URL(request.url);
10
+ const baseUrl = `${url.protocol}//${url.host}`;
11
+
12
+ return NextResponse.json(
13
+ {
14
+ name: env.a2aAgentName,
15
+ description: env.a2aAgentDescription,
16
+ protocolVersion: env.a2aVersion,
17
+ version: "0.1.0",
18
+ url: `${baseUrl}/messages/stream`,
19
+ capabilities: {
20
+ streaming: true,
21
+ pushNotifications: false,
22
+ extendedAgentCard: false,
23
+ },
24
+ defaultInputModes: ["text"],
25
+ defaultOutputModes: ["text"],
26
+ skills: [
27
+ {
28
+ id: "chat",
29
+ name: "Chat",
30
+ description: "Simple chat with streaming response",
31
+ tags: ["chat"],
32
+ inputModes: ["text"],
33
+ outputModes: ["text"],
34
+ },
35
+ ],
36
+ additionalInterfaces: [
37
+ {
38
+ transport: "HTTP+JSON",
39
+ url: baseUrl,
40
+ },
41
+ ],
42
+ },
43
+ {
44
+ headers: {
45
+ "A2A-Version": env.a2aVersion,
46
+ "Content-Type": "application/a2a+json",
47
+ },
48
+ },
49
+ );
50
+ }
@@ -0,0 +1,29 @@
1
+ import { NextResponse } from "next/server";
2
+
3
+ import type { A2aError } from "@/lib/a2a/types";
4
+ import { cancelBackgroundTask } from "@/lib/agent/background";
5
+ import { getEnv } from "@/lib/env";
6
+
7
+ export const runtime = "nodejs";
8
+
9
+ export async function POST(_req: Request, ctx: { params: Promise<{ jobId: string }> }) {
10
+ const env = getEnv();
11
+ const { jobId } = await ctx.params;
12
+
13
+ const cancelled = cancelBackgroundTask(jobId);
14
+
15
+ if (!cancelled) {
16
+ return NextResponse.json(
17
+ { error: { code: "BackgroundTaskNotFound", message: "Task not found" } } satisfies A2aError,
18
+ {
19
+ status: 404,
20
+ headers: { "Content-Type": "application/a2a+json", "A2A-Version": env.a2aVersion },
21
+ },
22
+ );
23
+ }
24
+
25
+ return NextResponse.json(
26
+ { jobId, cancelled: true },
27
+ { headers: { "Content-Type": "application/a2a+json", "A2A-Version": env.a2aVersion } },
28
+ );
29
+ }
@@ -0,0 +1,58 @@
1
+ import { NextResponse } from "next/server";
2
+
3
+ import type { A2aActivityStreamResponse, A2aError } from "@/lib/a2a/types";
4
+ import { listActivityEvents, subscribeActivityEvents } from "@/lib/a2a/activity-store";
5
+ import { sseHeaders } from "@/lib/a2a/sse";
6
+ import { getEnv } from "@/lib/env";
7
+
8
+ export const runtime = "nodejs";
9
+
10
+ const encoder = new TextEncoder();
11
+
12
+ function sseActivity(payload: A2aActivityStreamResponse): Uint8Array {
13
+ return encoder.encode(`id: ${payload.activity.id}\ndata: ${JSON.stringify(payload)}\n\n`);
14
+ }
15
+
16
+ export async function GET(request: Request) {
17
+ const env = getEnv();
18
+ const url = new URL(request.url);
19
+ const contextId = url.searchParams.get("contextId");
20
+ if (!contextId) {
21
+ return NextResponse.json(
22
+ { error: { code: "ValidationError", message: "Missing contextId" } } satisfies A2aError,
23
+ { status: 400, headers: { "Content-Type": "application/a2a+json" } },
24
+ );
25
+ }
26
+
27
+ const sinceParam =
28
+ request.headers.get("Last-Event-ID") ?? url.searchParams.get("since") ?? "0";
29
+ const sinceId = Number(sinceParam) || 0;
30
+
31
+ const stream = new ReadableStream<Uint8Array>({
32
+ start(controller) {
33
+ const history = listActivityEvents({ contextId, sinceId });
34
+ for (const activity of history) {
35
+ controller.enqueue(sseActivity({ kind: "activity", activity }));
36
+ }
37
+
38
+ const unsubscribe = subscribeActivityEvents(contextId, (activity) => {
39
+ controller.enqueue(sseActivity({ kind: "activity", activity }));
40
+ });
41
+
42
+ const abort = () => {
43
+ unsubscribe();
44
+ controller.close();
45
+ };
46
+
47
+ if (request.signal.aborted) {
48
+ abort();
49
+ } else {
50
+ request.signal.addEventListener("abort", abort, { once: true });
51
+ }
52
+ },
53
+ });
54
+
55
+ return new Response(stream, {
56
+ headers: sseHeaders({ "A2A-Version": env.a2aVersion }),
57
+ });
58
+ }
Binary file
@@ -0,0 +1,174 @@
1
+ @import "tailwindcss";
2
+ @import "katex/dist/katex.min.css";
3
+
4
+ /* 官方 Getting Started:Tailwind v4 必须加这句,否则 Streamdown 内置样式不会被打包 */
5
+ @source "../../node_modules/streamdown/dist/*.js";
6
+
7
+ /* 官方 Styling:Streamdown 用的 shadcn 设计 token,见 https://streamdown.ai/docs/styling */
8
+ @layer base {
9
+ :root {
10
+ --background: 0 0% 100%;
11
+ --foreground: 222.2 84% 4.9%;
12
+ --card: 0 0% 100%;
13
+ --card-foreground: 222.2 84% 4.9%;
14
+ --popover: 0 0% 100%;
15
+ --popover-foreground: 222.2 84% 4.9%;
16
+ --primary: 222.2 47.4% 11.2%;
17
+ --primary-foreground: 210 40% 98%;
18
+ --secondary: 210 40% 96.1%;
19
+ --secondary-foreground: 222.2 47.4% 11.2%;
20
+ --muted: 210 40% 96.1%;
21
+ --muted-foreground: 215.4 16.3% 46.9%;
22
+ --accent: 210 40% 96.1%;
23
+ --accent-foreground: 222.2 47.4% 11.2%;
24
+ --destructive: 0 84.2% 60.2%;
25
+ --destructive-foreground: 210 40% 98%;
26
+ --border: 214.3 31.8% 91.4%;
27
+ --input: 214.3 31.8% 91.4%;
28
+ --ring: 222.2 84% 4.9%;
29
+ --radius: 0.5rem;
30
+ }
31
+
32
+ .dark {
33
+ --background: 222.2 84% 4.9%;
34
+ --foreground: 210 40% 98%;
35
+ --card: 222.2 84% 4.9%;
36
+ --card-foreground: 210 40% 98%;
37
+ --popover: 222.2 84% 4.9%;
38
+ --popover-foreground: 210 40% 98%;
39
+ --primary: 210 40% 98%;
40
+ --primary-foreground: 222.2 47.4% 11.2%;
41
+ --secondary: 217.2 32.6% 17.5%;
42
+ --secondary-foreground: 210 40% 98%;
43
+ --muted: 217.2 32.6% 17.5%;
44
+ --muted-foreground: 215 20.2% 65.1%;
45
+ --accent: 217.2 32.6% 17.5%;
46
+ --accent-foreground: 210 40% 98%;
47
+ --destructive: 0 62.8% 30.6%;
48
+ --destructive-foreground: 210 40% 98%;
49
+ --border: 217.2 32.6% 17.5%;
50
+ --input: 217.2 32.6% 17.5%;
51
+ --ring: 212.7 26.8% 83.9%;
52
+ }
53
+
54
+ /* 无 .dark 时用系统偏好暗色 */
55
+ @media (prefers-color-scheme: dark) {
56
+ :root:not(.light) {
57
+ --background: 222.2 84% 4.9%;
58
+ --foreground: 210 40% 98%;
59
+ --card: 222.2 84% 4.9%;
60
+ --card-foreground: 210 40% 98%;
61
+ --popover: 222.2 84% 4.9%;
62
+ --popover-foreground: 210 40% 98%;
63
+ --primary: 210 40% 98%;
64
+ --primary-foreground: 222.2 47.4% 11.2%;
65
+ --secondary: 217.2 32.6% 17.5%;
66
+ --secondary-foreground: 210 40% 98%;
67
+ --muted: 217.2 32.6% 17.5%;
68
+ --muted-foreground: 215 20.2% 65.1%;
69
+ --accent: 217.2 32.6% 17.5%;
70
+ --accent-foreground: 210 40% 98%;
71
+ --destructive: 0 62.8% 30.6%;
72
+ --destructive-foreground: 210 40% 98%;
73
+ --border: 217.2 32.6% 17.5%;
74
+ --input: 217.2 32.6% 17.5%;
75
+ --ring: 212.7 26.8% 83.9%;
76
+ }
77
+ }
78
+ }
79
+
80
+ @theme inline {
81
+ --color-background: hsl(var(--background));
82
+ --color-foreground: hsl(var(--foreground));
83
+ --color-card: hsl(var(--card));
84
+ --color-card-foreground: hsl(var(--card-foreground));
85
+ --color-popover: hsl(var(--popover));
86
+ --color-popover-foreground: hsl(var(--popover-foreground));
87
+ --color-primary: hsl(var(--primary));
88
+ --color-primary-foreground: hsl(var(--primary-foreground));
89
+ --color-secondary: hsl(var(--secondary));
90
+ --color-secondary-foreground: hsl(var(--secondary-foreground));
91
+ --color-muted: hsl(var(--muted));
92
+ --color-muted-foreground: hsl(var(--muted-foreground));
93
+ --color-accent: hsl(var(--accent));
94
+ --color-accent-foreground: hsl(var(--accent-foreground));
95
+ --color-destructive: hsl(var(--destructive));
96
+ --color-destructive-foreground: hsl(var(--destructive-foreground));
97
+ --color-border: hsl(var(--border));
98
+ --color-input: hsl(var(--input));
99
+ --color-ring: hsl(var(--ring));
100
+ --font-sans: var(--font-geist-sans);
101
+ --font-mono: var(--font-geist-mono);
102
+ }
103
+
104
+ /* Streamdown: soften mermaid block border to avoid bright outline */
105
+ [data-streamdown="mermaid-block"] {
106
+ border-color: hsl(var(--border) / 0.4);
107
+ }
108
+
109
+ body {
110
+ background: hsl(var(--background));
111
+ color: hsl(var(--foreground));
112
+ font-family: var(--font-sans), Arial, Helvetica, sans-serif;
113
+ }
114
+
115
+ @keyframes enter {
116
+ from {
117
+ opacity: 0;
118
+ transform: translateY(10px);
119
+ }
120
+ to {
121
+ opacity: 1;
122
+ transform: none;
123
+ }
124
+ }
125
+
126
+ @keyframes fade-in {
127
+ from {
128
+ opacity: 0;
129
+ }
130
+ to {
131
+ opacity: 1;
132
+ }
133
+ }
134
+
135
+ @keyframes slide-in-from-top-2 {
136
+ from {
137
+ transform: translateY(-0.5rem);
138
+ opacity: 0;
139
+ }
140
+ to {
141
+ transform: translateY(0);
142
+ opacity: 1;
143
+ }
144
+ }
145
+
146
+ .animate-in {
147
+ animation: enter 0.3s ease-out forwards;
148
+ }
149
+
150
+ .slide-in-from-top-2 {
151
+ animation: slide-in-from-top-2 0.2s ease-out forwards;
152
+ }
153
+
154
+ .fade-in {
155
+ animation: fade-in 0.5s ease-out forwards;
156
+ }
157
+
158
+ /* Custom Scrollbar for verified Vercel-like feel */
159
+ ::-webkit-scrollbar {
160
+ width: 6px;
161
+ height: 6px;
162
+ }
163
+ ::-webkit-scrollbar-track {
164
+ background: transparent;
165
+ }
166
+ ::-webkit-scrollbar-thumb {
167
+ background: var(--color-border);
168
+ border-radius: 3px;
169
+ }
170
+ @media (prefers-color-scheme: dark) {
171
+ ::-webkit-scrollbar-thumb {
172
+ background: var(--color-border);
173
+ }
174
+ }
@@ -0,0 +1,34 @@
1
+ import type { Metadata } from "next";
2
+ import { Geist, Geist_Mono } from "next/font/google";
3
+ import "./globals.css";
4
+
5
+ const geistSans = Geist({
6
+ variable: "--font-geist-sans",
7
+ subsets: ["latin"],
8
+ });
9
+
10
+ const geistMono = Geist_Mono({
11
+ variable: "--font-geist-mono",
12
+ subsets: ["latin"],
13
+ });
14
+
15
+ export const metadata: Metadata = {
16
+ title: "Create Next App",
17
+ description: "Generated by create next app",
18
+ };
19
+
20
+ export default function RootLayout({
21
+ children,
22
+ }: Readonly<{
23
+ children: React.ReactNode;
24
+ }>) {
25
+ return (
26
+ <html lang="en">
27
+ <body
28
+ className={`${geistSans.variable} ${geistMono.variable} antialiased`}
29
+ >
30
+ {children}
31
+ </body>
32
+ </html>
33
+ );
34
+ }
@@ -0,0 +1,57 @@
1
+ import { NextResponse } from "next/server";
2
+
3
+ import { submitAnswer } from "@/lib/agent/answer-store";
4
+ import type { AskUserQuestionAnswer } from "@/lib/a2a/types";
5
+
6
+ export const runtime = "nodejs";
7
+
8
+ function isValidRequest(body: unknown): body is AskUserQuestionAnswer {
9
+ if (!body || typeof body !== "object") return false;
10
+ const rec = body as Record<string, unknown>;
11
+ if (typeof rec.requestId !== "string" || !rec.requestId) return false;
12
+ if (typeof rec.taskId !== "string" || !rec.taskId) return false;
13
+ if (!rec.answers || typeof rec.answers !== "object") return false;
14
+ return true;
15
+ }
16
+
17
+ export async function POST(request: Request) {
18
+ let body: unknown;
19
+ try {
20
+ body = await request.json();
21
+ } catch {
22
+ return NextResponse.json(
23
+ { error: { code: "ValidationError", message: "Invalid JSON body" } },
24
+ { status: 400 },
25
+ );
26
+ }
27
+
28
+ if (!isValidRequest(body)) {
29
+ return NextResponse.json(
30
+ {
31
+ error: {
32
+ code: "ValidationError",
33
+ message: "Missing or invalid requestId, taskId, or answers",
34
+ },
35
+ },
36
+ { status: 400 },
37
+ );
38
+ }
39
+
40
+ const { requestId, answers } = body;
41
+
42
+ const success = submitAnswer({ requestId, answers });
43
+
44
+ if (!success) {
45
+ return NextResponse.json(
46
+ {
47
+ error: {
48
+ code: "NotFoundError",
49
+ message: "No pending question found for this requestId",
50
+ },
51
+ },
52
+ { status: 404 },
53
+ );
54
+ }
55
+
56
+ return NextResponse.json({ success: true });
57
+ }