nastech-app 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/agents/i18n-translator.md +119 -0
- package/.claude/settings.json +8 -0
- package/.eas/workflows/ota.yaml +9 -0
- package/.eas/workflows/preview.yaml +12 -0
- package/.easignore +12 -0
- package/.github/workflows/eas-build.yml +24 -0
- package/CHANGELOG.md +117 -0
- package/CLAUDE.md +413 -0
- package/GoogleService-Info.plist +30 -0
- package/LICENSE +21 -0
- package/NasTechapp.md +383 -0
- package/README.md +75 -0
- package/Stores.md +85 -0
- package/TERMS.md +83 -0
- package/app.config.js +153 -0
- package/babel.config.js +28 -0
- package/deploy/nastech-app.yaml +51 -0
- package/docs/marketing/README-creators.md +73 -0
- package/eas-build-post-install.sh +11 -0
- package/eas-build-pre-install.sh +27 -0
- package/eas.json +78 -0
- package/google-services.json +67 -0
- package/index.ts +3 -0
- package/logo.png +0 -0
- package/metro.config.js +54 -0
- package/nativewind-env.d.ts +1 -0
- package/package.json +233 -0
- package/patches/.keep +0 -0
- package/plugins/withEinkCompatibility.js +156 -0
- package/public/.well-known/apple-app-site-association +22 -0
- package/public/.well-known/assetlinks.json +12 -0
- package/public/canvaskit.wasm +0 -0
- package/public/favicon-active.ico +0 -0
- package/release-dev.sh +7 -0
- package/release-production.sh +3 -0
- package/release.cjs +160 -0
- package/sources/-session/SessionView.tsx +944 -0
- package/sources/-session/sessionOverlayNav.ts +34 -0
- package/sources/app/(app)/_layout.tsx +321 -0
- package/sources/app/(app)/artifacts/[id].tsx +279 -0
- package/sources/app/(app)/artifacts/edit/[id].tsx +318 -0
- package/sources/app/(app)/artifacts/index.tsx +264 -0
- package/sources/app/(app)/artifacts/new.tsx +219 -0
- package/sources/app/(app)/changelog.tsx +113 -0
- package/sources/app/(app)/dev/colors.tsx +197 -0
- package/sources/app/(app)/dev/device-info.tsx +183 -0
- package/sources/app/(app)/dev/expo-constants.tsx +394 -0
- package/sources/app/(app)/dev/index.tsx +400 -0
- package/sources/app/(app)/dev/input-styles.tsx +1951 -0
- package/sources/app/(app)/dev/inverted-list.tsx +295 -0
- package/sources/app/(app)/dev/list-demo.tsx +125 -0
- package/sources/app/(app)/dev/logs.tsx +160 -0
- package/sources/app/(app)/dev/messages-demo-data.ts +479 -0
- package/sources/app/(app)/dev/messages-demo.tsx +45 -0
- package/sources/app/(app)/dev/modal-demo.tsx +211 -0
- package/sources/app/(app)/dev/multi-text-input.tsx +224 -0
- package/sources/app/(app)/dev/purchases.tsx +228 -0
- package/sources/app/(app)/dev/qr-test.tsx +168 -0
- package/sources/app/(app)/dev/session-composer.tsx +812 -0
- package/sources/app/(app)/dev/shimmer-demo.tsx +275 -0
- package/sources/app/(app)/dev/tests.tsx +203 -0
- package/sources/app/(app)/dev/tools2.tsx +556 -0
- package/sources/app/(app)/dev/typography.tsx +177 -0
- package/sources/app/(app)/dev/unistyles-demo.tsx +376 -0
- package/sources/app/(app)/friends/index.tsx +167 -0
- package/sources/app/(app)/friends/search.tsx +232 -0
- package/sources/app/(app)/inbox/index.tsx +124 -0
- package/sources/app/(app)/index.tsx +264 -0
- package/sources/app/(app)/machine/[id].tsx +646 -0
- package/sources/app/(app)/new/index.tsx +1611 -0
- package/sources/app/(app)/restore/index.tsx +167 -0
- package/sources/app/(app)/restore/manual.tsx +138 -0
- package/sources/app/(app)/server.tsx +234 -0
- package/sources/app/(app)/session/[id]/file.tsx +527 -0
- package/sources/app/(app)/session/[id]/files.tsx +442 -0
- package/sources/app/(app)/session/[id]/info.tsx +655 -0
- package/sources/app/(app)/session/[id]/message/[messageId].tsx +125 -0
- package/sources/app/(app)/session/[id].tsx +10 -0
- package/sources/app/(app)/session/recent.tsx +270 -0
- package/sources/app/(app)/settings/account.tsx +600 -0
- package/sources/app/(app)/settings/agents.tsx +180 -0
- package/sources/app/(app)/settings/appearance.tsx +259 -0
- package/sources/app/(app)/settings/connect/claude.tsx +178 -0
- package/sources/app/(app)/settings/features.tsx +177 -0
- package/sources/app/(app)/settings/index.tsx +3 -0
- package/sources/app/(app)/settings/language.tsx +106 -0
- package/sources/app/(app)/settings/usage.tsx +11 -0
- package/sources/app/(app)/settings/voice/language.tsx +114 -0
- package/sources/app/(app)/settings/voice.tsx +274 -0
- package/sources/app/(app)/terminal/connect.tsx +241 -0
- package/sources/app/(app)/terminal/index.tsx +184 -0
- package/sources/app/(app)/text-selection.tsx +149 -0
- package/sources/app/(app)/user/[id].tsx +314 -0
- package/sources/app/+html.tsx +39 -0
- package/sources/app/_layout.tsx +402 -0
- package/sources/assets/animations/game.json +1 -0
- package/sources/assets/animations/owl.json +1 -0
- package/sources/assets/animations/popcorn.json +1 -0
- package/sources/assets/animations/robot.json +1 -0
- package/sources/assets/animations/sparkles.json +1 -0
- package/sources/assets/animations/stone.json +1 -0
- package/sources/assets/fonts/BricolageGrotesque-Bold.ttf +0 -0
- package/sources/assets/fonts/IBMPlexMono-Italic.ttf +0 -0
- package/sources/assets/fonts/IBMPlexMono-Regular.ttf +0 -0
- package/sources/assets/fonts/IBMPlexMono-SemiBold.ttf +0 -0
- package/sources/assets/fonts/IBMPlexSans-Italic.ttf +0 -0
- package/sources/assets/fonts/IBMPlexSans-Regular.ttf +0 -0
- package/sources/assets/fonts/IBMPlexSans-SemiBold.ttf +0 -0
- package/sources/assets/fonts/SpaceMono-Regular.ttf +0 -0
- package/sources/assets/images/brutalist/Abstract-1.png +0 -0
- package/sources/assets/images/brutalist/Abstract-10.png +0 -0
- package/sources/assets/images/brutalist/Abstract-100.png +0 -0
- package/sources/assets/images/brutalist/Abstract-101.png +0 -0
- package/sources/assets/images/brutalist/Abstract-102.png +0 -0
- package/sources/assets/images/brutalist/Abstract-103.png +0 -0
- package/sources/assets/images/brutalist/Abstract-104.png +0 -0
- package/sources/assets/images/brutalist/Abstract-105.png +0 -0
- package/sources/assets/images/brutalist/Abstract-106.png +0 -0
- package/sources/assets/images/brutalist/Abstract-107.png +0 -0
- package/sources/assets/images/brutalist/Abstract-108.png +0 -0
- package/sources/assets/images/brutalist/Abstract-109.png +0 -0
- package/sources/assets/images/brutalist/Abstract-11.png +0 -0
- package/sources/assets/images/brutalist/Abstract-110.png +0 -0
- package/sources/assets/images/brutalist/Abstract-111.png +0 -0
- package/sources/assets/images/brutalist/Abstract-112.png +0 -0
- package/sources/assets/images/brutalist/Abstract-113.png +0 -0
- package/sources/assets/images/brutalist/Abstract-114.png +0 -0
- package/sources/assets/images/brutalist/Abstract-115.png +0 -0
- package/sources/assets/images/brutalist/Abstract-116.png +0 -0
- package/sources/assets/images/brutalist/Abstract-117.png +0 -0
- package/sources/assets/images/brutalist/Abstract-118.png +0 -0
- package/sources/assets/images/brutalist/Abstract-119.png +0 -0
- package/sources/assets/images/brutalist/Abstract-12.png +0 -0
- package/sources/assets/images/brutalist/Abstract-120.png +0 -0
- package/sources/assets/images/brutalist/Abstract-121.png +0 -0
- package/sources/assets/images/brutalist/Abstract-122.png +0 -0
- package/sources/assets/images/brutalist/Abstract-123.png +0 -0
- package/sources/assets/images/brutalist/Abstract-124.png +0 -0
- package/sources/assets/images/brutalist/Abstract-125.png +0 -0
- package/sources/assets/images/brutalist/Abstract-126.png +0 -0
- package/sources/assets/images/brutalist/Abstract-127.png +0 -0
- package/sources/assets/images/brutalist/Abstract-128.png +0 -0
- package/sources/assets/images/brutalist/Abstract-129.png +0 -0
- package/sources/assets/images/brutalist/Abstract-13.png +0 -0
- package/sources/assets/images/brutalist/Abstract-130.png +0 -0
- package/sources/assets/images/brutalist/Abstract-131.png +0 -0
- package/sources/assets/images/brutalist/Abstract-132.png +0 -0
- package/sources/assets/images/brutalist/Abstract-133.png +0 -0
- package/sources/assets/images/brutalist/Abstract-134.png +0 -0
- package/sources/assets/images/brutalist/Abstract-135.png +0 -0
- package/sources/assets/images/brutalist/Abstract-136.png +0 -0
- package/sources/assets/images/brutalist/Abstract-137.png +0 -0
- package/sources/assets/images/brutalist/Abstract-138.png +0 -0
- package/sources/assets/images/brutalist/Abstract-139.png +0 -0
- package/sources/assets/images/brutalist/Abstract-14.png +0 -0
- package/sources/assets/images/brutalist/Abstract-140.png +0 -0
- package/sources/assets/images/brutalist/Abstract-141.png +0 -0
- package/sources/assets/images/brutalist/Abstract-142.png +0 -0
- package/sources/assets/images/brutalist/Abstract-143.png +0 -0
- package/sources/assets/images/brutalist/Abstract-144.png +0 -0
- package/sources/assets/images/brutalist/Abstract-145.png +0 -0
- package/sources/assets/images/brutalist/Abstract-146.png +0 -0
- package/sources/assets/images/brutalist/Abstract-147.png +0 -0
- package/sources/assets/images/brutalist/Abstract-148.png +0 -0
- package/sources/assets/images/brutalist/Abstract-149.png +0 -0
- package/sources/assets/images/brutalist/Abstract-15.png +0 -0
- package/sources/assets/images/brutalist/Abstract-150.png +0 -0
- package/sources/assets/images/brutalist/Abstract-151.png +0 -0
- package/sources/assets/images/brutalist/Abstract-152.png +0 -0
- package/sources/assets/images/brutalist/Abstract-153.png +0 -0
- package/sources/assets/images/brutalist/Abstract-154.png +0 -0
- package/sources/assets/images/brutalist/Abstract-155.png +0 -0
- package/sources/assets/images/brutalist/Abstract-156.png +0 -0
- package/sources/assets/images/brutalist/Abstract-157.png +0 -0
- package/sources/assets/images/brutalist/Abstract-158.png +0 -0
- package/sources/assets/images/brutalist/Abstract-159.png +0 -0
- package/sources/assets/images/brutalist/Abstract-16.png +0 -0
- package/sources/assets/images/brutalist/Abstract-160.png +0 -0
- package/sources/assets/images/brutalist/Abstract-161.png +0 -0
- package/sources/assets/images/brutalist/Abstract-162.png +0 -0
- package/sources/assets/images/brutalist/Abstract-163.png +0 -0
- package/sources/assets/images/brutalist/Abstract-164.png +0 -0
- package/sources/assets/images/brutalist/Abstract-165.png +0 -0
- package/sources/assets/images/brutalist/Abstract-166.png +0 -0
- package/sources/assets/images/brutalist/Abstract-167.png +0 -0
- package/sources/assets/images/brutalist/Abstract-168.png +0 -0
- package/sources/assets/images/brutalist/Abstract-169.png +0 -0
- package/sources/assets/images/brutalist/Abstract-17.png +0 -0
- package/sources/assets/images/brutalist/Abstract-170.png +0 -0
- package/sources/assets/images/brutalist/Abstract-171.png +0 -0
- package/sources/assets/images/brutalist/Abstract-172.png +0 -0
- package/sources/assets/images/brutalist/Abstract-173.png +0 -0
- package/sources/assets/images/brutalist/Abstract-174.png +0 -0
- package/sources/assets/images/brutalist/Abstract-175.png +0 -0
- package/sources/assets/images/brutalist/Abstract-176.png +0 -0
- package/sources/assets/images/brutalist/Abstract-177.png +0 -0
- package/sources/assets/images/brutalist/Abstract-178.png +0 -0
- package/sources/assets/images/brutalist/Abstract-179.png +0 -0
- package/sources/assets/images/brutalist/Abstract-18.png +0 -0
- package/sources/assets/images/brutalist/Abstract-180.png +0 -0
- package/sources/assets/images/brutalist/Abstract-181.png +0 -0
- package/sources/assets/images/brutalist/Abstract-182.png +0 -0
- package/sources/assets/images/brutalist/Abstract-183.png +0 -0
- package/sources/assets/images/brutalist/Abstract-184.png +0 -0
- package/sources/assets/images/brutalist/Abstract-185.png +0 -0
- package/sources/assets/images/brutalist/Abstract-186.png +0 -0
- package/sources/assets/images/brutalist/Abstract-187.png +0 -0
- package/sources/assets/images/brutalist/Abstract-188.png +0 -0
- package/sources/assets/images/brutalist/Abstract-189.png +0 -0
- package/sources/assets/images/brutalist/Abstract-19.png +0 -0
- package/sources/assets/images/brutalist/Abstract-190.png +0 -0
- package/sources/assets/images/brutalist/Abstract-191.png +0 -0
- package/sources/assets/images/brutalist/Abstract-192.png +0 -0
- package/sources/assets/images/brutalist/Abstract-193.png +0 -0
- package/sources/assets/images/brutalist/Abstract-194.png +0 -0
- package/sources/assets/images/brutalist/Abstract-195.png +0 -0
- package/sources/assets/images/brutalist/Abstract-196.png +0 -0
- package/sources/assets/images/brutalist/Abstract-197.png +0 -0
- package/sources/assets/images/brutalist/Abstract-198.png +0 -0
- package/sources/assets/images/brutalist/Abstract-199.png +0 -0
- package/sources/assets/images/brutalist/Abstract-2.png +0 -0
- package/sources/assets/images/brutalist/Abstract-20.png +0 -0
- package/sources/assets/images/brutalist/Abstract-200.png +0 -0
- package/sources/assets/images/brutalist/Abstract-201.png +0 -0
- package/sources/assets/images/brutalist/Abstract-202.png +0 -0
- package/sources/assets/images/brutalist/Abstract-203.png +0 -0
- package/sources/assets/images/brutalist/Abstract-204.png +0 -0
- package/sources/assets/images/brutalist/Abstract-205.png +0 -0
- package/sources/assets/images/brutalist/Abstract-206.png +0 -0
- package/sources/assets/images/brutalist/Abstract-207.png +0 -0
- package/sources/assets/images/brutalist/Abstract-208.png +0 -0
- package/sources/assets/images/brutalist/Abstract-209.png +0 -0
- package/sources/assets/images/brutalist/Abstract-21.png +0 -0
- package/sources/assets/images/brutalist/Abstract-210.png +0 -0
- package/sources/assets/images/brutalist/Abstract-211.png +0 -0
- package/sources/assets/images/brutalist/Abstract-212.png +0 -0
- package/sources/assets/images/brutalist/Abstract-213.png +0 -0
- package/sources/assets/images/brutalist/Abstract-214.png +0 -0
- package/sources/assets/images/brutalist/Abstract-215.png +0 -0
- package/sources/assets/images/brutalist/Abstract-216.png +0 -0
- package/sources/assets/images/brutalist/Abstract-217.png +0 -0
- package/sources/assets/images/brutalist/Abstract-218.png +0 -0
- package/sources/assets/images/brutalist/Abstract-219.png +0 -0
- package/sources/assets/images/brutalist/Abstract-22.png +0 -0
- package/sources/assets/images/brutalist/Abstract-220.png +0 -0
- package/sources/assets/images/brutalist/Abstract-221.png +0 -0
- package/sources/assets/images/brutalist/Abstract-222.png +0 -0
- package/sources/assets/images/brutalist/Abstract-223.png +0 -0
- package/sources/assets/images/brutalist/Abstract-224.png +0 -0
- package/sources/assets/images/brutalist/Abstract-225.png +0 -0
- package/sources/assets/images/brutalist/Abstract-226.png +0 -0
- package/sources/assets/images/brutalist/Abstract-227.png +0 -0
- package/sources/assets/images/brutalist/Abstract-228.png +0 -0
- package/sources/assets/images/brutalist/Abstract-229.png +0 -0
- package/sources/assets/images/brutalist/Abstract-23.png +0 -0
- package/sources/assets/images/brutalist/Abstract-230.png +0 -0
- package/sources/assets/images/brutalist/Abstract-231.png +0 -0
- package/sources/assets/images/brutalist/Abstract-232.png +0 -0
- package/sources/assets/images/brutalist/Abstract-233.png +0 -0
- package/sources/assets/images/brutalist/Abstract-234.png +0 -0
- package/sources/assets/images/brutalist/Abstract-235.png +0 -0
- package/sources/assets/images/brutalist/Abstract-236.png +0 -0
- package/sources/assets/images/brutalist/Abstract-237.png +0 -0
- package/sources/assets/images/brutalist/Abstract-238.png +0 -0
- package/sources/assets/images/brutalist/Abstract-239.png +0 -0
- package/sources/assets/images/brutalist/Abstract-24.png +0 -0
- package/sources/assets/images/brutalist/Abstract-240.png +0 -0
- package/sources/assets/images/brutalist/Abstract-241.png +0 -0
- package/sources/assets/images/brutalist/Abstract-242.png +0 -0
- package/sources/assets/images/brutalist/Abstract-243.png +0 -0
- package/sources/assets/images/brutalist/Abstract-244.png +0 -0
- package/sources/assets/images/brutalist/Abstract-245.png +0 -0
- package/sources/assets/images/brutalist/Abstract-246.png +0 -0
- package/sources/assets/images/brutalist/Abstract-247.png +0 -0
- package/sources/assets/images/brutalist/Abstract-248.png +0 -0
- package/sources/assets/images/brutalist/Abstract-249.png +0 -0
- package/sources/assets/images/brutalist/Abstract-25.png +0 -0
- package/sources/assets/images/brutalist/Abstract-250.png +0 -0
- package/sources/assets/images/brutalist/Abstract-251.png +0 -0
- package/sources/assets/images/brutalist/Abstract-252.png +0 -0
- package/sources/assets/images/brutalist/Abstract-253.png +0 -0
- package/sources/assets/images/brutalist/Abstract-254.png +0 -0
- package/sources/assets/images/brutalist/Abstract-255.png +0 -0
- package/sources/assets/images/brutalist/Abstract-256.png +0 -0
- package/sources/assets/images/brutalist/Abstract-257.png +0 -0
- package/sources/assets/images/brutalist/Abstract-258.png +0 -0
- package/sources/assets/images/brutalist/Abstract-259.png +0 -0
- package/sources/assets/images/brutalist/Abstract-26.png +0 -0
- package/sources/assets/images/brutalist/Abstract-260.png +0 -0
- package/sources/assets/images/brutalist/Abstract-261.png +0 -0
- package/sources/assets/images/brutalist/Abstract-262.png +0 -0
- package/sources/assets/images/brutalist/Abstract-27.png +0 -0
- package/sources/assets/images/brutalist/Abstract-28.png +0 -0
- package/sources/assets/images/brutalist/Abstract-29.png +0 -0
- package/sources/assets/images/brutalist/Abstract-3.png +0 -0
- package/sources/assets/images/brutalist/Abstract-30.png +0 -0
- package/sources/assets/images/brutalist/Abstract-31.png +0 -0
- package/sources/assets/images/brutalist/Abstract-32.png +0 -0
- package/sources/assets/images/brutalist/Abstract-33.png +0 -0
- package/sources/assets/images/brutalist/Abstract-34.png +0 -0
- package/sources/assets/images/brutalist/Abstract-35.png +0 -0
- package/sources/assets/images/brutalist/Abstract-36.png +0 -0
- package/sources/assets/images/brutalist/Abstract-37.png +0 -0
- package/sources/assets/images/brutalist/Abstract-38.png +0 -0
- package/sources/assets/images/brutalist/Abstract-39.png +0 -0
- package/sources/assets/images/brutalist/Abstract-4.png +0 -0
- package/sources/assets/images/brutalist/Abstract-40.png +0 -0
- package/sources/assets/images/brutalist/Abstract-41.png +0 -0
- package/sources/assets/images/brutalist/Abstract-42.png +0 -0
- package/sources/assets/images/brutalist/Abstract-43.png +0 -0
- package/sources/assets/images/brutalist/Abstract-44.png +0 -0
- package/sources/assets/images/brutalist/Abstract-45.png +0 -0
- package/sources/assets/images/brutalist/Abstract-46.png +0 -0
- package/sources/assets/images/brutalist/Abstract-47.png +0 -0
- package/sources/assets/images/brutalist/Abstract-48.png +0 -0
- package/sources/assets/images/brutalist/Abstract-49.png +0 -0
- package/sources/assets/images/brutalist/Abstract-5.png +0 -0
- package/sources/assets/images/brutalist/Abstract-50.png +0 -0
- package/sources/assets/images/brutalist/Abstract-51.png +0 -0
- package/sources/assets/images/brutalist/Abstract-52.png +0 -0
- package/sources/assets/images/brutalist/Abstract-53.png +0 -0
- package/sources/assets/images/brutalist/Abstract-54.png +0 -0
- package/sources/assets/images/brutalist/Abstract-55.png +0 -0
- package/sources/assets/images/brutalist/Abstract-56.png +0 -0
- package/sources/assets/images/brutalist/Abstract-57.png +0 -0
- package/sources/assets/images/brutalist/Abstract-58.png +0 -0
- package/sources/assets/images/brutalist/Abstract-59.png +0 -0
- package/sources/assets/images/brutalist/Abstract-6.png +0 -0
- package/sources/assets/images/brutalist/Abstract-60.png +0 -0
- package/sources/assets/images/brutalist/Abstract-61.png +0 -0
- package/sources/assets/images/brutalist/Abstract-62.png +0 -0
- package/sources/assets/images/brutalist/Abstract-63.png +0 -0
- package/sources/assets/images/brutalist/Abstract-64.png +0 -0
- package/sources/assets/images/brutalist/Abstract-65.png +0 -0
- package/sources/assets/images/brutalist/Abstract-66.png +0 -0
- package/sources/assets/images/brutalist/Abstract-67.png +0 -0
- package/sources/assets/images/brutalist/Abstract-68.png +0 -0
- package/sources/assets/images/brutalist/Abstract-69.png +0 -0
- package/sources/assets/images/brutalist/Abstract-7.png +0 -0
- package/sources/assets/images/brutalist/Abstract-70.png +0 -0
- package/sources/assets/images/brutalist/Abstract-71.png +0 -0
- package/sources/assets/images/brutalist/Abstract-72.png +0 -0
- package/sources/assets/images/brutalist/Abstract-73.png +0 -0
- package/sources/assets/images/brutalist/Abstract-74.png +0 -0
- package/sources/assets/images/brutalist/Abstract-75.png +0 -0
- package/sources/assets/images/brutalist/Abstract-76.png +0 -0
- package/sources/assets/images/brutalist/Abstract-77.png +0 -0
- package/sources/assets/images/brutalist/Abstract-78.png +0 -0
- package/sources/assets/images/brutalist/Abstract-79.png +0 -0
- package/sources/assets/images/brutalist/Abstract-8.png +0 -0
- package/sources/assets/images/brutalist/Abstract-80.png +0 -0
- package/sources/assets/images/brutalist/Abstract-81.png +0 -0
- package/sources/assets/images/brutalist/Abstract-82.png +0 -0
- package/sources/assets/images/brutalist/Abstract-83.png +0 -0
- package/sources/assets/images/brutalist/Abstract-84.png +0 -0
- package/sources/assets/images/brutalist/Abstract-85.png +0 -0
- package/sources/assets/images/brutalist/Abstract-86.png +0 -0
- package/sources/assets/images/brutalist/Abstract-87.png +0 -0
- package/sources/assets/images/brutalist/Abstract-88.png +0 -0
- package/sources/assets/images/brutalist/Abstract-89.png +0 -0
- package/sources/assets/images/brutalist/Abstract-9.png +0 -0
- package/sources/assets/images/brutalist/Abstract-90.png +0 -0
- package/sources/assets/images/brutalist/Abstract-91.png +0 -0
- package/sources/assets/images/brutalist/Abstract-92.png +0 -0
- package/sources/assets/images/brutalist/Abstract-93.png +0 -0
- package/sources/assets/images/brutalist/Abstract-94.png +0 -0
- package/sources/assets/images/brutalist/Abstract-95.png +0 -0
- package/sources/assets/images/brutalist/Abstract-96.png +0 -0
- package/sources/assets/images/brutalist/Abstract-97.png +0 -0
- package/sources/assets/images/brutalist/Abstract-98.png +0 -0
- package/sources/assets/images/brutalist/Abstract-99.png +0 -0
- package/sources/assets/images/brutalist/Bauhaus-1.png +0 -0
- package/sources/assets/images/brutalist/Bauhaus-10.png +0 -0
- package/sources/assets/images/brutalist/Bauhaus-11.png +0 -0
- package/sources/assets/images/brutalist/Bauhaus-12.png +0 -0
- package/sources/assets/images/brutalist/Bauhaus-13.png +0 -0
- package/sources/assets/images/brutalist/Bauhaus-14.png +0 -0
- package/sources/assets/images/brutalist/Bauhaus-15.png +0 -0
- package/sources/assets/images/brutalist/Bauhaus-16.png +0 -0
- package/sources/assets/images/brutalist/Bauhaus-17.png +0 -0
- package/sources/assets/images/brutalist/Bauhaus-18.png +0 -0
- package/sources/assets/images/brutalist/Bauhaus-19.png +0 -0
- package/sources/assets/images/brutalist/Bauhaus-2.png +0 -0
- package/sources/assets/images/brutalist/Bauhaus-20.png +0 -0
- package/sources/assets/images/brutalist/Bauhaus-21.png +0 -0
- package/sources/assets/images/brutalist/Bauhaus-22.png +0 -0
- package/sources/assets/images/brutalist/Bauhaus-23.png +0 -0
- package/sources/assets/images/brutalist/Bauhaus-24.png +0 -0
- package/sources/assets/images/brutalist/Bauhaus-25.png +0 -0
- package/sources/assets/images/brutalist/Bauhaus-26.png +0 -0
- package/sources/assets/images/brutalist/Bauhaus-27.png +0 -0
- package/sources/assets/images/brutalist/Bauhaus-28.png +0 -0
- package/sources/assets/images/brutalist/Bauhaus-29.png +0 -0
- package/sources/assets/images/brutalist/Bauhaus-3.png +0 -0
- package/sources/assets/images/brutalist/Bauhaus-30.png +0 -0
- package/sources/assets/images/brutalist/Bauhaus-31.png +0 -0
- package/sources/assets/images/brutalist/Bauhaus-32.png +0 -0
- package/sources/assets/images/brutalist/Bauhaus-33.png +0 -0
- package/sources/assets/images/brutalist/Bauhaus-34.png +0 -0
- package/sources/assets/images/brutalist/Bauhaus-35.png +0 -0
- package/sources/assets/images/brutalist/Bauhaus-36.png +0 -0
- package/sources/assets/images/brutalist/Bauhaus-37.png +0 -0
- package/sources/assets/images/brutalist/Bauhaus-38.png +0 -0
- package/sources/assets/images/brutalist/Bauhaus-39.png +0 -0
- package/sources/assets/images/brutalist/Bauhaus-4.png +0 -0
- package/sources/assets/images/brutalist/Bauhaus-40.png +0 -0
- package/sources/assets/images/brutalist/Bauhaus-5.png +0 -0
- package/sources/assets/images/brutalist/Bauhaus-6.png +0 -0
- package/sources/assets/images/brutalist/Bauhaus-7.png +0 -0
- package/sources/assets/images/brutalist/Bauhaus-8.png +0 -0
- package/sources/assets/images/brutalist/Bauhaus-9.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-1.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-10.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-100.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-101.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-102.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-103.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-104.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-105.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-106.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-107.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-108.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-109.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-11.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-110.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-111.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-112.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-113.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-114.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-115.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-116.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-117.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-118.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-12.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-13.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-14.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-15.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-16.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-17.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-18.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-19.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-2.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-20.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-21.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-22.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-23.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-24.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-25.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-26.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-27.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-28.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-29.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-3.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-30.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-31.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-32.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-33.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-34.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-35.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-36.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-37.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-38.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-39.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-4.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-40.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-41.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-42.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-43.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-44.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-45.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-46.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-47.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-48.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-49.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-5.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-50.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-51.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-52.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-53.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-54.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-55.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-56.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-57.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-58.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-59.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-6.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-60.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-61.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-62.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-63.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-64.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-65.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-66.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-67.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-68.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-69.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-7.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-70.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-71.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-72.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-73.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-74.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-75.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-76.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-77.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-78.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-79.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-8.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-80.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-81.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-82.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-83.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-84.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-85.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-86.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-87.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-88.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-89.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-9.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-90.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-91.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-92.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-93.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-94.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-95.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-96.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-97.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-98.png +0 -0
- package/sources/assets/images/brutalist/Brutalism-99.png +0 -0
- package/sources/assets/images/favicon-active.png +0 -0
- package/sources/assets/images/favicon.png +0 -0
- package/sources/assets/images/gradients/01.png +0 -0
- package/sources/assets/images/gradients/02.png +0 -0
- package/sources/assets/images/gradients/03.png +0 -0
- package/sources/assets/images/gradients/04.png +0 -0
- package/sources/assets/images/gradients/05.png +0 -0
- package/sources/assets/images/gradients/06.png +0 -0
- package/sources/assets/images/gradients/07.png +0 -0
- package/sources/assets/images/gradients/08.png +0 -0
- package/sources/assets/images/gradients/09.png +0 -0
- package/sources/assets/images/gradients/10.png +0 -0
- package/sources/assets/images/gradients/100.png +0 -0
- package/sources/assets/images/gradients/11.png +0 -0
- package/sources/assets/images/gradients/12.png +0 -0
- package/sources/assets/images/gradients/13.png +0 -0
- package/sources/assets/images/gradients/14.png +0 -0
- package/sources/assets/images/gradients/15.png +0 -0
- package/sources/assets/images/gradients/16.png +0 -0
- package/sources/assets/images/gradients/17.png +0 -0
- package/sources/assets/images/gradients/18.png +0 -0
- package/sources/assets/images/gradients/19.png +0 -0
- package/sources/assets/images/gradients/20.png +0 -0
- package/sources/assets/images/gradients/21.png +0 -0
- package/sources/assets/images/gradients/22.png +0 -0
- package/sources/assets/images/gradients/23.png +0 -0
- package/sources/assets/images/gradients/24.png +0 -0
- package/sources/assets/images/gradients/25.png +0 -0
- package/sources/assets/images/gradients/26.png +0 -0
- package/sources/assets/images/gradients/27.png +0 -0
- package/sources/assets/images/gradients/28.png +0 -0
- package/sources/assets/images/gradients/29.png +0 -0
- package/sources/assets/images/gradients/30.png +0 -0
- package/sources/assets/images/gradients/31.png +0 -0
- package/sources/assets/images/gradients/32.png +0 -0
- package/sources/assets/images/gradients/33.png +0 -0
- package/sources/assets/images/gradients/34.png +0 -0
- package/sources/assets/images/gradients/35.png +0 -0
- package/sources/assets/images/gradients/36.png +0 -0
- package/sources/assets/images/gradients/37.png +0 -0
- package/sources/assets/images/gradients/38.png +0 -0
- package/sources/assets/images/gradients/39.png +0 -0
- package/sources/assets/images/gradients/40.png +0 -0
- package/sources/assets/images/gradients/41.png +0 -0
- package/sources/assets/images/gradients/42.png +0 -0
- package/sources/assets/images/gradients/43.png +0 -0
- package/sources/assets/images/gradients/44.png +0 -0
- package/sources/assets/images/gradients/45.png +0 -0
- package/sources/assets/images/gradients/46.png +0 -0
- package/sources/assets/images/gradients/47.png +0 -0
- package/sources/assets/images/gradients/48.png +0 -0
- package/sources/assets/images/gradients/49.png +0 -0
- package/sources/assets/images/gradients/50.png +0 -0
- package/sources/assets/images/gradients/51.png +0 -0
- package/sources/assets/images/gradients/52.png +0 -0
- package/sources/assets/images/gradients/53.png +0 -0
- package/sources/assets/images/gradients/54.png +0 -0
- package/sources/assets/images/gradients/55.png +0 -0
- package/sources/assets/images/gradients/56.png +0 -0
- package/sources/assets/images/gradients/57.png +0 -0
- package/sources/assets/images/gradients/58.png +0 -0
- package/sources/assets/images/gradients/59.png +0 -0
- package/sources/assets/images/gradients/60.png +0 -0
- package/sources/assets/images/gradients/61.png +0 -0
- package/sources/assets/images/gradients/62.png +0 -0
- package/sources/assets/images/gradients/63.png +0 -0
- package/sources/assets/images/gradients/64.png +0 -0
- package/sources/assets/images/gradients/65.png +0 -0
- package/sources/assets/images/gradients/66.png +0 -0
- package/sources/assets/images/gradients/67.png +0 -0
- package/sources/assets/images/gradients/68.png +0 -0
- package/sources/assets/images/gradients/69.png +0 -0
- package/sources/assets/images/gradients/70.png +0 -0
- package/sources/assets/images/gradients/71.png +0 -0
- package/sources/assets/images/gradients/72.png +0 -0
- package/sources/assets/images/gradients/73.png +0 -0
- package/sources/assets/images/gradients/74.png +0 -0
- package/sources/assets/images/gradients/75.png +0 -0
- package/sources/assets/images/gradients/76.png +0 -0
- package/sources/assets/images/gradients/77.png +0 -0
- package/sources/assets/images/gradients/78.png +0 -0
- package/sources/assets/images/gradients/79.png +0 -0
- package/sources/assets/images/gradients/80.png +0 -0
- package/sources/assets/images/gradients/81.png +0 -0
- package/sources/assets/images/gradients/82.png +0 -0
- package/sources/assets/images/gradients/83.png +0 -0
- package/sources/assets/images/gradients/84.png +0 -0
- package/sources/assets/images/gradients/85.png +0 -0
- package/sources/assets/images/gradients/86.png +0 -0
- package/sources/assets/images/gradients/87.png +0 -0
- package/sources/assets/images/gradients/88.png +0 -0
- package/sources/assets/images/gradients/89.png +0 -0
- package/sources/assets/images/gradients/90.png +0 -0
- package/sources/assets/images/gradients/91.png +0 -0
- package/sources/assets/images/gradients/92.png +0 -0
- package/sources/assets/images/gradients/93.png +0 -0
- package/sources/assets/images/gradients/94.png +0 -0
- package/sources/assets/images/gradients/95.png +0 -0
- package/sources/assets/images/gradients/96.png +0 -0
- package/sources/assets/images/gradients/97.png +0 -0
- package/sources/assets/images/gradients/98.png +0 -0
- package/sources/assets/images/gradients/99.png +0 -0
- package/sources/assets/images/icon-adaptive.png +0 -0
- package/sources/assets/images/icon-claude.png +0 -0
- package/sources/assets/images/icon-claude@2x.png +0 -0
- package/sources/assets/images/icon-claude@3x.png +0 -0
- package/sources/assets/images/icon-gemini.png +0 -0
- package/sources/assets/images/icon-gemini@2x.png +0 -0
- package/sources/assets/images/icon-gemini@3x.png +0 -0
- package/sources/assets/images/icon-gpt.png +0 -0
- package/sources/assets/images/icon-gpt@2x.png +0 -0
- package/sources/assets/images/icon-gpt@3x.png +0 -0
- package/sources/assets/images/icon-monochrome.png +0 -0
- package/sources/assets/images/icon-notification.png +0 -0
- package/sources/assets/images/icon-openclaw.png +0 -0
- package/sources/assets/images/icon-openclaw@2x.png +0 -0
- package/sources/assets/images/icon-openclaw@3x.png +0 -0
- package/sources/assets/images/icon-tauri.png +0 -0
- package/sources/assets/images/icon-voice-white.png +0 -0
- package/sources/assets/images/icon-voice.png +0 -0
- package/sources/assets/images/icon-voice@2x.png +0 -0
- package/sources/assets/images/icon-voice@3x.png +0 -0
- package/sources/assets/images/icon.png +0 -0
- package/sources/assets/images/logo-black.png +0 -0
- package/sources/assets/images/logo-white.png +0 -0
- package/sources/assets/images/logotype-dark.png +0 -0
- package/sources/assets/images/logotype-dark@2x.png +0 -0
- package/sources/assets/images/logotype-dark@3x.png +0 -0
- package/sources/assets/images/logotype-light.png +0 -0
- package/sources/assets/images/logotype-light@2x.png +0 -0
- package/sources/assets/images/logotype-light@3x.png +0 -0
- package/sources/assets/images/logotype.png +0 -0
- package/sources/assets/images/logotype@2x.png +0 -0
- package/sources/assets/images/logotype@3x.png +0 -0
- package/sources/assets/images/splash-android-dark.png +0 -0
- package/sources/assets/images/splash-android-light.png +0 -0
- package/sources/assets/images/transparent.png +0 -0
- package/sources/assets/images/zen-icon.png +0 -0
- package/sources/auth/AuthContext.tsx +100 -0
- package/sources/auth/authAccountApprove.ts +2 -0
- package/sources/auth/authApprove.ts +2 -0
- package/sources/auth/authChallenge.ts +8 -0
- package/sources/auth/authGetToken.ts +4 -0
- package/sources/auth/authQRStart.ts +17 -0
- package/sources/auth/authQRWait.ts +13 -0
- package/sources/auth/secretKeyBackup.spec.ts +465 -0
- package/sources/auth/secretKeyBackup.ts +179 -0
- package/sources/auth/tokenStorage.ts +27 -0
- package/sources/changelog/changelog.json +60 -0
- package/sources/changelog/index.ts +3 -0
- package/sources/changelog/parser.ts +23 -0
- package/sources/changelog/storage.ts +17 -0
- package/sources/changelog/types.ts +10 -0
- package/sources/components/ActiveSessionsGroupCompact.tsx +567 -0
- package/sources/components/AgentContentView.ios.tsx +70 -0
- package/sources/components/AgentContentView.tsx +48 -0
- package/sources/components/AgentInput.tsx +1468 -0
- package/sources/components/AgentInputAttachmentStrip.tsx +122 -0
- package/sources/components/AgentInputAutocomplete.tsx +96 -0
- package/sources/components/AgentInputSuggestionView.tsx +106 -0
- package/sources/components/AllFilesDiffView.tsx +515 -0
- package/sources/components/Avatar.tsx +149 -0
- package/sources/components/AvatarBrutalist.tsx +501 -0
- package/sources/components/AvatarGradient.tsx +147 -0
- package/sources/components/AvatarSkia.tsx +111 -0
- package/sources/components/AvatarSkia.web.tsx +113 -0
- package/sources/components/ChatFooter.tsx +50 -0
- package/sources/components/ChatHeaderView.tsx +180 -0
- package/sources/components/ChatList.tsx +283 -0
- package/sources/components/CodeEditor.tsx +22 -0
- package/sources/components/CodeEditor.web.tsx +180 -0
- package/sources/components/CodeView.tsx +33 -0
- package/sources/components/CommandPalette/CommandPalette.tsx +72 -0
- package/sources/components/CommandPalette/CommandPaletteInput.tsx +65 -0
- package/sources/components/CommandPalette/CommandPaletteItem.tsx +141 -0
- package/sources/components/CommandPalette/CommandPaletteModal.tsx +148 -0
- package/sources/components/CommandPalette/CommandPaletteProvider.tsx +141 -0
- package/sources/components/CommandPalette/CommandPaletteResults.tsx +129 -0
- package/sources/components/CommandPalette/index.ts +3 -0
- package/sources/components/CommandPalette/types.ts +15 -0
- package/sources/components/CommandPalette/useCommandPalette.ts +107 -0
- package/sources/components/CommandView.tsx +135 -0
- package/sources/components/CompactGitStatus.tsx +88 -0
- package/sources/components/ConnectButton.tsx +117 -0
- package/sources/components/Deferred.tsx +18 -0
- package/sources/components/DuplicateSheet.tsx +295 -0
- package/sources/components/EmptyMainScreen.tsx +171 -0
- package/sources/components/EmptyMessages.tsx +123 -0
- package/sources/components/EmptySessionsTablet.tsx +111 -0
- package/sources/components/ExternalLink.tsx +22 -0
- package/sources/components/FAB.tsx +53 -0
- package/sources/components/FABWide.tsx +59 -0
- package/sources/components/FeedItemCard.tsx +98 -0
- package/sources/components/FileIcon.tsx +63 -0
- package/sources/components/FileViewPanel.tsx +673 -0
- package/sources/components/FilesSidebar.tsx +739 -0
- package/sources/components/FloatingOverlay.tsx +48 -0
- package/sources/components/GitStatusBadge.tsx +82 -0
- package/sources/components/HeaderLogo.tsx +28 -0
- package/sources/components/HomeHeader.tsx +243 -0
- package/sources/components/HorizontalScrollView.tsx +88 -0
- package/sources/components/InboxView.tsx +260 -0
- package/sources/components/InlineFileDiff.tsx +277 -0
- package/sources/components/Item.tsx +315 -0
- package/sources/components/ItemGroup.tsx +147 -0
- package/sources/components/ItemList.tsx +102 -0
- package/sources/components/MainView.tsx +324 -0
- package/sources/components/MessageView.tsx +299 -0
- package/sources/components/MultiTextInput.tsx +285 -0
- package/sources/components/MultiTextInput.web.tsx +220 -0
- package/sources/components/OAuthView.tsx +374 -0
- package/sources/components/PermissionModeSelector.tsx +68 -0
- package/sources/components/PlaceholderContainerView.tsx +47 -0
- package/sources/components/PlusPlus.tsx +34 -0
- package/sources/components/PlusPlus.web.tsx +34 -0
- package/sources/components/ProjectGitStatus.tsx +102 -0
- package/sources/components/RoundButton.tsx +130 -0
- package/sources/components/SearchableListSelector.tsx +675 -0
- package/sources/components/SessionActionsNativeMenu.android.tsx +58 -0
- package/sources/components/SessionActionsNativeMenu.ios.tsx +55 -0
- package/sources/components/SessionActionsNativeMenu.tsx +20 -0
- package/sources/components/SessionActionsNativeMenu.web.tsx +13 -0
- package/sources/components/SessionActionsPopover.tsx +240 -0
- package/sources/components/SessionsList.tsx +471 -0
- package/sources/components/SessionsListWrapper.tsx +72 -0
- package/sources/components/SettingsView.tsx +470 -0
- package/sources/components/SettingsViewWrapper.tsx +21 -0
- package/sources/components/Shaker.tsx +42 -0
- package/sources/components/Shaker.web.tsx +46 -0
- package/sources/components/ShimmerView.tsx +106 -0
- package/sources/components/SidebarNavigator.tsx +218 -0
- package/sources/components/SidebarView.tsx +104 -0
- package/sources/components/SimpleSyntaxHighlighter.tsx +322 -0
- package/sources/components/StatusBarProvider.tsx +12 -0
- package/sources/components/StatusDot.tsx +49 -0
- package/sources/components/StyledText.tsx +35 -0
- package/sources/components/Switch.tsx +20 -0
- package/sources/components/TabBar.tsx +140 -0
- package/sources/components/ToolGroupView.tsx +101 -0
- package/sources/components/TransitionStack.tsx +14 -0
- package/sources/components/UpdateBanner.tsx +74 -0
- package/sources/components/UserCard.tsx +41 -0
- package/sources/components/UserSearchResult.tsx +129 -0
- package/sources/components/VoiceAssistantStatusBar.tsx +260 -0
- package/sources/components/VoiceBars.tsx +95 -0
- package/sources/components/autocomplete/applySuggestion.test.ts +194 -0
- package/sources/components/autocomplete/applySuggestion.ts +61 -0
- package/sources/components/autocomplete/findActiveWord.test.ts +365 -0
- package/sources/components/autocomplete/findActiveWord.ts +207 -0
- package/sources/components/autocomplete/suggestions.ts +79 -0
- package/sources/components/autocomplete/useActiveSuggestions.ts +130 -0
- package/sources/components/autocomplete/useActiveWord.ts +19 -0
- package/sources/components/diff/DiffView.tsx +188 -0
- package/sources/components/diff/PierreDiffView.tsx +253 -0
- package/sources/components/diff/calculateDiff.ts +317 -0
- package/sources/components/entityColor.ts +51 -0
- package/sources/components/haptics.ts +9 -0
- package/sources/components/haptics.web.ts +7 -0
- package/sources/components/layout.ts +44 -0
- package/sources/components/markdown/MarkdownView.tsx +670 -0
- package/sources/components/markdown/MermaidRenderer.tsx +233 -0
- package/sources/components/markdown/linkUtils.test.ts +17 -0
- package/sources/components/markdown/linkUtils.ts +5 -0
- package/sources/components/markdown/parseMarkdown.test.ts +64 -0
- package/sources/components/markdown/parseMarkdown.ts +46 -0
- package/sources/components/markdown/parseMarkdownBlock.test.ts +108 -0
- package/sources/components/markdown/parseMarkdownBlock.ts +200 -0
- package/sources/components/markdown/parseMarkdownSpans.ts +88 -0
- package/sources/components/modelModeOptions.test.ts +114 -0
- package/sources/components/modelModeOptions.ts +257 -0
- package/sources/components/navigation/Header.tsx +252 -0
- package/sources/components/parseLocalCommandMessage.spec.ts +96 -0
- package/sources/components/parseLocalCommandMessage.ts +97 -0
- package/sources/components/qr/QRCode.tsx +178 -0
- package/sources/components/qr/QRCode.web.tsx +229 -0
- package/sources/components/qr/index.ts +2 -0
- package/sources/components/qr/qrMatrix.ts +48 -0
- package/sources/components/tools/PermissionFooter.tsx +527 -0
- package/sources/components/tools/ToolDiffView.tsx +60 -0
- package/sources/components/tools/ToolError.tsx +49 -0
- package/sources/components/tools/ToolFullView.tsx +193 -0
- package/sources/components/tools/ToolHeader.tsx +93 -0
- package/sources/components/tools/ToolSectionView.tsx +42 -0
- package/sources/components/tools/ToolStatusIndicator.tsx +36 -0
- package/sources/components/tools/ToolView.tsx +340 -0
- package/sources/components/tools/knownTools.tsx +957 -0
- package/sources/components/tools/views/AskUserQuestionView.tsx +357 -0
- package/sources/components/tools/views/BashView.tsx +47 -0
- package/sources/components/tools/views/BashViewFull.tsx +81 -0
- package/sources/components/tools/views/CodexBashView.tsx +126 -0
- package/sources/components/tools/views/CodexDiffView.tsx +79 -0
- package/sources/components/tools/views/CodexPatchView.tsx +186 -0
- package/sources/components/tools/views/EditView.tsx +33 -0
- package/sources/components/tools/views/EditViewFull.tsx +38 -0
- package/sources/components/tools/views/ExitPlanToolView.tsx +21 -0
- package/sources/components/tools/views/FileView.tsx +118 -0
- package/sources/components/tools/views/GeminiEditView.tsx +75 -0
- package/sources/components/tools/views/GeminiExecuteView.tsx +92 -0
- package/sources/components/tools/views/MCPToolView.tsx +31 -0
- package/sources/components/tools/views/MultiEditView.tsx +41 -0
- package/sources/components/tools/views/MultiEditViewFull.tsx +84 -0
- package/sources/components/tools/views/TaskView.tsx +129 -0
- package/sources/components/tools/views/TodoView.tsx +90 -0
- package/sources/components/tools/views/WriteView.tsx +29 -0
- package/sources/components/tools/views/_all.tsx +88 -0
- package/sources/components/usage/UsageBar.tsx +80 -0
- package/sources/components/usage/UsageChart.tsx +164 -0
- package/sources/components/usage/UsagePanel.tsx +283 -0
- package/sources/components/web/FaviconPermissionIndicator.tsx +44 -0
- package/sources/config.ts +3 -0
- package/sources/constants/Languages.ts +116 -0
- package/sources/constants/Typography.ts +116 -0
- package/sources/dev/testRunner.ts +277 -0
- package/sources/docs/autocomplete-text-manipulation.md +224 -0
- package/sources/encryption/aes.appspec.ts +25 -0
- package/sources/encryption/aes.ts +21 -0
- package/sources/encryption/aes.web.test.ts +73 -0
- package/sources/encryption/aes.web.ts +79 -0
- package/sources/encryption/base64.appspec.ts +240 -0
- package/sources/encryption/base64.native.ts +12 -0
- package/sources/encryption/base64.ts +46 -0
- package/sources/encryption/blob.test.ts +120 -0
- package/sources/encryption/blob.ts +58 -0
- package/sources/encryption/deriveKey.appspec.ts +72 -0
- package/sources/encryption/deriveKey.ts +46 -0
- package/sources/encryption/hex.ts +17 -0
- package/sources/encryption/hmac_sha512.appspec.ts +40 -0
- package/sources/encryption/hmac_sha512.ts +42 -0
- package/sources/encryption/libsodium.lib.ts +2 -0
- package/sources/encryption/libsodium.lib.web.ts +2 -0
- package/sources/encryption/libsodium.ts +58 -0
- package/sources/encryption/text.test.ts +61 -0
- package/sources/encryption/text.ts +11 -0
- package/sources/hooks/useAsyncCommand.ts +25 -0
- package/sources/hooks/useAttachmentImage.ts +134 -0
- package/sources/hooks/useAutocomplete.ts +69 -0
- package/sources/hooks/useAutocompleteSession.ts +53 -0
- package/sources/hooks/useChangelog.ts +45 -0
- package/sources/hooks/useCheckCameraPermissions.ts +25 -0
- package/sources/hooks/useConnectAccount.ts +107 -0
- package/sources/hooks/useConnectTerminal.ts +112 -0
- package/sources/hooks/useDemoMessages.ts +48 -0
- package/sources/hooks/useDraft.ts +120 -0
- package/sources/hooks/useElapsedTime.ts +36 -0
- package/sources/hooks/useGetPath.ts +13 -0
- package/sources/hooks/useGitStatusFiles.ts +45 -0
- package/sources/hooks/useGlobalKeyboard.ts +29 -0
- package/sources/hooks/useGroupedMessages.ts +149 -0
- package/sources/hooks/useImagePicker.ts +135 -0
- package/sources/hooks/useInboxHasContent.ts +19 -0
- package/sources/hooks/useMultiClick.ts +56 -0
- package/sources/hooks/useNasTechAction.ts +45 -0
- package/sources/hooks/useNativeUpdate.ts +10 -0
- package/sources/hooks/useNavigateToSession.ts +20 -0
- package/sources/hooks/useNewSessionDraft.ts +70 -0
- package/sources/hooks/usePrefetchFileContents.ts +162 -0
- package/sources/hooks/useSearch.ts +120 -0
- package/sources/hooks/useSessionQuickActions.ts +325 -0
- package/sources/hooks/useTauriDrag.ts +76 -0
- package/sources/hooks/useTauriZoom.ts +67 -0
- package/sources/hooks/useUpdates.ts +84 -0
- package/sources/hooks/useVisibleSessionListViewData.ts +65 -0
- package/sources/hooks/useWorktreeCleanup.ts +69 -0
- package/sources/log.ts +108 -0
- package/sources/modal/ModalManager.ts +203 -0
- package/sources/modal/ModalProvider.tsx +103 -0
- package/sources/modal/components/BaseModal.tsx +122 -0
- package/sources/modal/components/CustomModal.tsx +42 -0
- package/sources/modal/components/WebAlertModal.tsx +139 -0
- package/sources/modal/components/WebPromptModal.tsx +185 -0
- package/sources/modal/index.ts +3 -0
- package/sources/modal/types.ts +79 -0
- package/sources/nastech-wire/index.ts +10 -0
- package/sources/nastech-wire/legacyProtocol.ts +27 -0
- package/sources/nastech-wire/messageMeta.ts +14 -0
- package/sources/nastech-wire/messages.ts +113 -0
- package/sources/nastech-wire/sessionProtocol.ts +134 -0
- package/sources/nastech-wire/voice.ts +34 -0
- package/sources/polyfills/screenOrientation.ts +33 -0
- package/sources/realtime/RealtimeProvider.tsx +20 -0
- package/sources/realtime/RealtimeProvider.web.tsx +15 -0
- package/sources/realtime/RealtimeSession.ts +200 -0
- package/sources/realtime/RealtimeVoiceSession.tsx +211 -0
- package/sources/realtime/RealtimeVoiceSession.web.tsx +209 -0
- package/sources/realtime/hooks/contextFormatters.ts +127 -0
- package/sources/realtime/hooks/voiceHooks.ts +232 -0
- package/sources/realtime/realtimeClientTools.ts +94 -0
- package/sources/realtime/types.ts +19 -0
- package/sources/realtime/voiceConfig.ts +31 -0
- package/sources/realtime/voiceExperiment.ts +91 -0
- package/sources/realtime/voiceSystemPrompt.ts +75 -0
- package/sources/scripts/compareTranslations.ts +217 -0
- package/sources/scripts/parseChangelog.ts +87 -0
- package/sources/sync/__testdata__/trace_0.json +3986 -0
- package/sources/sync/__testdata__/trace_1.json +1391 -0
- package/sources/sync/__testdata__/trace_2.json +182 -0
- package/sources/sync/agentDefaults.ts +108 -0
- package/sources/sync/apiArtifacts.ts +143 -0
- package/sources/sync/apiAttachments.ts +217 -0
- package/sources/sync/apiFeed.ts +60 -0
- package/sources/sync/apiFriends.ts +217 -0
- package/sources/sync/apiGithub.spec.ts +97 -0
- package/sources/sync/apiGithub.ts +103 -0
- package/sources/sync/apiKv.ts +270 -0
- package/sources/sync/apiPush.ts +83 -0
- package/sources/sync/apiServices.ts +64 -0
- package/sources/sync/apiSocket.ts +290 -0
- package/sources/sync/apiTypes.spec.ts +23 -0
- package/sources/sync/apiTypes.ts +213 -0
- package/sources/sync/apiUsage.ts +130 -0
- package/sources/sync/apiVoice.ts +57 -0
- package/sources/sync/appConfig.ts +95 -0
- package/sources/sync/artifactTypes.ts +85 -0
- package/sources/sync/attachmentTypes.ts +28 -0
- package/sources/sync/encryption/artifactEncryption.ts +83 -0
- package/sources/sync/encryption/encryption.ts +220 -0
- package/sources/sync/encryption/encryptionCache.ts +248 -0
- package/sources/sync/encryption/encryptor.appspec.ts +409 -0
- package/sources/sync/encryption/encryptor.ts +126 -0
- package/sources/sync/encryption/machineEncryption.ts +122 -0
- package/sources/sync/encryption/sessionEncryption.ts +207 -0
- package/sources/sync/feedTypes.ts +43 -0
- package/sources/sync/friendTypes.ts +92 -0
- package/sources/sync/git-parsers/LineParser.ts +62 -0
- package/sources/sync/git-parsers/parseBranch.ts +97 -0
- package/sources/sync/git-parsers/parseDiff.ts +180 -0
- package/sources/sync/git-parsers/parseStatus.ts +162 -0
- package/sources/sync/git-parsers/parseStatusV2.ts +307 -0
- package/sources/sync/gitStatusFiles.ts +185 -0
- package/sources/sync/gitStatusSync.ts +282 -0
- package/sources/sync/localSettings.ts +67 -0
- package/sources/sync/messageMeta.test.ts +87 -0
- package/sources/sync/messageMeta.ts +36 -0
- package/sources/sync/modeHacks.test.ts +29 -0
- package/sources/sync/modeHacks.ts +22 -0
- package/sources/sync/nastechApi.ts +124 -0
- package/sources/sync/ops.ts +776 -0
- package/sources/sync/persistence.ts +322 -0
- package/sources/sync/profile.ts +95 -0
- package/sources/sync/projectFiles.ts +54 -0
- package/sources/sync/prompt/systemPrompt.ts +20 -0
- package/sources/sync/purchases.ts +67 -0
- package/sources/sync/pushRegistration.ts +229 -0
- package/sources/sync/reducer/activityUpdateAccumulator.test.ts +492 -0
- package/sources/sync/reducer/activityUpdateAccumulator.ts +96 -0
- package/sources/sync/reducer/messageToEvent.ts +85 -0
- package/sources/sync/reducer/phase0-skipping.spec.ts +206 -0
- package/sources/sync/reducer/reducer.spec.ts +3169 -0
- package/sources/sync/reducer/reducer.ts +1214 -0
- package/sources/sync/reducer/reducerTracer.spec.ts +502 -0
- package/sources/sync/reducer/reducerTracer.ts +310 -0
- package/sources/sync/revenueCat/index.ts +21 -0
- package/sources/sync/revenueCat/revenueCat.ts +215 -0
- package/sources/sync/revenueCat/revenueCat.web.ts +238 -0
- package/sources/sync/revenueCat/types.ts +82 -0
- package/sources/sync/serverConfig.ts +72 -0
- package/sources/sync/settings.spec.ts +456 -0
- package/sources/sync/settings.ts +186 -0
- package/sources/sync/storage.ts +1653 -0
- package/sources/sync/storageTypes.spec.ts +24 -0
- package/sources/sync/storageTypes.ts +215 -0
- package/sources/sync/suggestionCommands.ts +149 -0
- package/sources/sync/suggestionFile.ts +206 -0
- package/sources/sync/sync.ts +2555 -0
- package/sources/sync/typesMessage.ts +69 -0
- package/sources/sync/typesMessageMeta.test.ts +14 -0
- package/sources/sync/typesMessageMeta.ts +17 -0
- package/sources/sync/typesRaw.spec.ts +2010 -0
- package/sources/sync/typesRaw.ts +1183 -0
- package/sources/sync/uploadFormFile.ts +29 -0
- package/sources/sync/uploadFormFile.web.ts +14 -0
- package/sources/sync/webTabTitle.ts +58 -0
- package/sources/text/README.md +223 -0
- package/sources/text/_all.ts +104 -0
- package/sources/text/_default.ts +1015 -0
- package/sources/text/index.ts +215 -0
- package/sources/text/translations/ca.ts +993 -0
- package/sources/text/translations/en.ts +1009 -0
- package/sources/text/translations/es.ts +995 -0
- package/sources/text/translations/it.ts +992 -0
- package/sources/text/translations/ja.ts +993 -0
- package/sources/text/translations/pl.ts +1024 -0
- package/sources/text/translations/pt.ts +992 -0
- package/sources/text/translations/ru.ts +1023 -0
- package/sources/text/translations/zh-Hans.ts +992 -0
- package/sources/text/translations/zh-Hant.ts +991 -0
- package/sources/theme.css +72 -0
- package/sources/theme.dark.json +31 -0
- package/sources/theme.figma.json +457 -0
- package/sources/theme.gen.ts +10 -0
- package/sources/theme.light.json +31 -0
- package/sources/theme.ts +452 -0
- package/sources/track/index.ts +171 -0
- package/sources/track/tracking.ts +12 -0
- package/sources/track/useTrackScreens.ts +10 -0
- package/sources/types/react-native-webrtc-web-shim.d.ts +6 -0
- package/sources/unistyles.ts +97 -0
- package/sources/utils/codexUnifiedDiff.spec.ts +43 -0
- package/sources/utils/codexUnifiedDiff.ts +70 -0
- package/sources/utils/consoleLogging.ts +145 -0
- package/sources/utils/copySessionMetadataToClipboard.ts +53 -0
- package/sources/utils/debounce.test.ts +646 -0
- package/sources/utils/debounce.ts +122 -0
- package/sources/utils/deviceCalculations.test.ts +318 -0
- package/sources/utils/deviceCalculations.ts +87 -0
- package/sources/utils/errors.ts +10 -0
- package/sources/utils/formatPermissionParams.ts +23 -0
- package/sources/utils/isTauri.ts +7 -0
- package/sources/utils/loadSkia.ts +3 -0
- package/sources/utils/loadSkia.web.ts +5 -0
- package/sources/utils/lock.ts +40 -0
- package/sources/utils/machineUtils.ts +6 -0
- package/sources/utils/messageUtils.ts +254 -0
- package/sources/utils/microphonePermissions.ts +109 -0
- package/sources/utils/notificationRouting.test.ts +51 -0
- package/sources/utils/notificationRouting.ts +81 -0
- package/sources/utils/oauth.ts +143 -0
- package/sources/utils/openExternalUrl.ts +19 -0
- package/sources/utils/parseToken.ts +23 -0
- package/sources/utils/pasteImages.web.ts +81 -0
- package/sources/utils/pathUtils.spec.ts +226 -0
- package/sources/utils/pathUtils.ts +75 -0
- package/sources/utils/platform.ts +19 -0
- package/sources/utils/readFileBytes.ts +11 -0
- package/sources/utils/readFileBytes.web.ts +12 -0
- package/sources/utils/requestReview.ts +135 -0
- package/sources/utils/responsive.ts +87 -0
- package/sources/utils/resumeCommand.test.ts +78 -0
- package/sources/utils/resumeCommand.ts +70 -0
- package/sources/utils/sessionFileLinks.test.ts +112 -0
- package/sources/utils/sessionFileLinks.ts +388 -0
- package/sources/utils/sessionUtils.ts +226 -0
- package/sources/utils/stringUtils.ts +41 -0
- package/sources/utils/sync.ts +164 -0
- package/sources/utils/thumbhash.ts +17 -0
- package/sources/utils/thumbhash.web.ts +85 -0
- package/sources/utils/time.ts +41 -0
- package/sources/utils/toSnakeCase.test.ts +182 -0
- package/sources/utils/toSnakeCase.ts +40 -0
- package/sources/utils/toolCommand.test.ts +23 -0
- package/sources/utils/toolCommand.ts +35 -0
- package/sources/utils/toolComparison.test.ts +101 -0
- package/sources/utils/toolComparison.ts +73 -0
- package/sources/utils/toolErrorParser.test.ts +126 -0
- package/sources/utils/toolErrorParser.ts +102 -0
- package/sources/utils/trimIdent.ts +27 -0
- package/sources/utils/truncateForLogs.ts +37 -0
- package/sources/utils/versionUtils.test.ts +58 -0
- package/sources/utils/versionUtils.ts +69 -0
- package/sources/utils/web/faviconGenerator.ts +39 -0
- package/sources/utils/worktree.ts +192 -0
- package/sources/wire/index.ts +97 -0
- package/src-tauri/Cargo.lock +5978 -0
- package/src-tauri/Cargo.toml +27 -0
- package/src-tauri/build.rs +3 -0
- package/src-tauri/capabilities/default.json +27 -0
- package/src-tauri/deny.toml +53 -0
- package/src-tauri/entitlements.plist +24 -0
- package/src-tauri/icons/128x128.png +0 -0
- package/src-tauri/icons/128x128@2x.png +0 -0
- package/src-tauri/icons/32x32.png +0 -0
- package/src-tauri/icons/64x64.png +0 -0
- package/src-tauri/icons/Square107x107Logo.png +0 -0
- package/src-tauri/icons/Square142x142Logo.png +0 -0
- package/src-tauri/icons/Square150x150Logo.png +0 -0
- package/src-tauri/icons/Square284x284Logo.png +0 -0
- package/src-tauri/icons/Square30x30Logo.png +0 -0
- package/src-tauri/icons/Square310x310Logo.png +0 -0
- package/src-tauri/icons/Square44x44Logo.png +0 -0
- package/src-tauri/icons/Square71x71Logo.png +0 -0
- package/src-tauri/icons/Square89x89Logo.png +0 -0
- package/src-tauri/icons/StoreLogo.png +0 -0
- package/src-tauri/icons/icon.icns +0 -0
- package/src-tauri/icons/icon.ico +0 -0
- package/src-tauri/icons/icon.png +0 -0
- package/src-tauri/src/lib.rs +18 -0
- package/src-tauri/src/main.rs +6 -0
- package/src-tauri/tauri.conf.json +51 -0
- package/src-tauri/tauri.dev.conf.json +20 -0
- package/src-tauri/tauri.preview.conf.json +20 -0
- package/tsconfig.json +45 -0
- package/vitest.config.ts +26 -0
|
@@ -0,0 +1,1214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Message Reducer for Real-time Sync System
|
|
3
|
+
*
|
|
4
|
+
* This reducer is the core message processing engine that transforms raw messages from
|
|
5
|
+
* the sync system into a structured, deduplicated message history. It handles complex
|
|
6
|
+
* scenarios including tool permissions, sidechains, and message deduplication.
|
|
7
|
+
*
|
|
8
|
+
* ## Core Responsibilities:
|
|
9
|
+
*
|
|
10
|
+
* 1. **Message Deduplication**: Prevents duplicate messages using multiple tracking mechanisms:
|
|
11
|
+
* - localId tracking for user messages
|
|
12
|
+
* - messageId tracking for all messages
|
|
13
|
+
* - Permission ID tracking for tool permissions
|
|
14
|
+
*
|
|
15
|
+
* 2. **Tool Permission Management**: Integrates with AgentState to handle tool permissions:
|
|
16
|
+
* - Creates placeholder messages for pending permission requests
|
|
17
|
+
* - Updates permission status (pending → approved/denied/canceled)
|
|
18
|
+
* - Matches incoming tool calls to approved permissions
|
|
19
|
+
* - Prioritizes tool calls over permissions when both exist
|
|
20
|
+
*
|
|
21
|
+
* 3. **Tool Call Lifecycle**: Manages the complete lifecycle of tool calls:
|
|
22
|
+
* - Creation from permission requests or direct tool calls
|
|
23
|
+
* - Matching tool calls to existing permission messages
|
|
24
|
+
* - Processing tool results and updating states
|
|
25
|
+
* - Handling errors and completion states
|
|
26
|
+
*
|
|
27
|
+
* 4. **Sidechain Processing**: Handles nested conversation branches (sidechains):
|
|
28
|
+
* - Identifies sidechain messages using the tracer
|
|
29
|
+
* - Stores sidechain messages separately
|
|
30
|
+
* - Links sidechains to their parent tool calls
|
|
31
|
+
*
|
|
32
|
+
* ## Processing Phases:
|
|
33
|
+
*
|
|
34
|
+
* The reducer processes messages in a specific order to ensure correct behavior:
|
|
35
|
+
*
|
|
36
|
+
* **Phase 0: AgentState Permissions**
|
|
37
|
+
* - Processes pending and completed permission requests
|
|
38
|
+
* - Creates tool messages for permissions
|
|
39
|
+
* - Skips completed permissions if matching tool call (same name AND arguments) exists in incoming messages
|
|
40
|
+
* - Phase 2 will handle matching tool calls to existing permission messages
|
|
41
|
+
*
|
|
42
|
+
* **Phase 0.5: Message-to-Event Conversion**
|
|
43
|
+
* - Parses messages to check if they should be converted to events
|
|
44
|
+
* - Converts matching messages to events immediately
|
|
45
|
+
* - Converted messages skip all subsequent processing phases
|
|
46
|
+
* - Supports user commands, tool results, and metadata-driven conversions
|
|
47
|
+
*
|
|
48
|
+
* **Phase 1: User and Text Messages**
|
|
49
|
+
* - Processes user messages with deduplication
|
|
50
|
+
* - Processes agent text messages
|
|
51
|
+
* - Skips tool calls for later phases
|
|
52
|
+
*
|
|
53
|
+
* **Phase 2: Tool Calls**
|
|
54
|
+
* - Processes incoming tool calls from agents
|
|
55
|
+
* - Matches to existing permission messages when possible
|
|
56
|
+
* - Creates new tool messages when no match exists
|
|
57
|
+
* - Prioritizes newest permission when multiple matches
|
|
58
|
+
*
|
|
59
|
+
* **Phase 3: Tool Results**
|
|
60
|
+
* - Updates tool messages with results
|
|
61
|
+
* - Sets completion or error states
|
|
62
|
+
* - Updates completion timestamps
|
|
63
|
+
*
|
|
64
|
+
* **Phase 4: Sidechains**
|
|
65
|
+
* - Processes sidechain messages separately
|
|
66
|
+
* - Stores in sidechain map linked to parent tool
|
|
67
|
+
* - Handles nested tool calls within sidechains
|
|
68
|
+
*
|
|
69
|
+
* **Phase 5: Mode Switch Events**
|
|
70
|
+
* - Processes agent event messages
|
|
71
|
+
* - Handles mode changes and other events
|
|
72
|
+
*
|
|
73
|
+
* ## Key Behaviors:
|
|
74
|
+
*
|
|
75
|
+
* - **Idempotency**: Calling the reducer multiple times with the same data produces no duplicates
|
|
76
|
+
* - **Priority Rules**: When both tool calls and permissions exist, tool calls take priority
|
|
77
|
+
* - **Argument Matching**: Tool calls match to permissions based on both name AND arguments
|
|
78
|
+
* - **Timestamp Preservation**: Original timestamps are preserved when matching tools to permissions
|
|
79
|
+
* - **State Persistence**: The ReducerState maintains all mappings across calls
|
|
80
|
+
* - **Message Immutability**: NEVER modify message timestamps or core properties after creation
|
|
81
|
+
* Messages can only have their tool state/result updated, never their creation metadata
|
|
82
|
+
* - **Timestamp Preservation**: NEVER change a message's createdAt timestamp. The timestamp
|
|
83
|
+
* represents when the message was originally created and must be preserved throughout all
|
|
84
|
+
* processing phases. This is critical for maintaining correct message ordering.
|
|
85
|
+
*
|
|
86
|
+
* ## Permission Matching Algorithm:
|
|
87
|
+
*
|
|
88
|
+
* When a tool call arrives, the matching algorithm:
|
|
89
|
+
* 1. Checks if the tool has already been processed (via toolIdToMessageId)
|
|
90
|
+
* 2. Searches for approved permission messages with:
|
|
91
|
+
* - Same tool name
|
|
92
|
+
* - Matching arguments (deep equality)
|
|
93
|
+
* - Not already linked to another tool
|
|
94
|
+
* 3. Prioritizes the newest matching permission
|
|
95
|
+
* 4. Updates the permission message with tool execution details
|
|
96
|
+
* 5. Falls back to creating a new tool message if no match
|
|
97
|
+
*
|
|
98
|
+
* ## Data Flow:
|
|
99
|
+
*
|
|
100
|
+
* Raw Messages → Normalizer → Reducer → Structured Messages
|
|
101
|
+
* ↑
|
|
102
|
+
* AgentState
|
|
103
|
+
*
|
|
104
|
+
* The reducer receives:
|
|
105
|
+
* - Normalized messages from the sync system
|
|
106
|
+
* - Current AgentState with permission information
|
|
107
|
+
*
|
|
108
|
+
* And produces:
|
|
109
|
+
* - Structured Message objects for UI rendering
|
|
110
|
+
* - Updated internal state for future processing
|
|
111
|
+
*/
|
|
112
|
+
|
|
113
|
+
import { Message, ToolCall } from "../typesMessage";
|
|
114
|
+
import { AgentEvent, NormalizedMessage, UsageData } from "../typesRaw";
|
|
115
|
+
import { createTracer, traceMessages, TracerState } from "./reducerTracer";
|
|
116
|
+
import { AgentState, TodoItem, TodoItemsSchema } from "../storageTypes";
|
|
117
|
+
import { MessageMeta } from "../typesMessageMeta";
|
|
118
|
+
import { parseMessageAsEvent } from "./messageToEvent";
|
|
119
|
+
|
|
120
|
+
type ReducerMessage = {
|
|
121
|
+
id: string;
|
|
122
|
+
realID: string | null;
|
|
123
|
+
createdAt: number;
|
|
124
|
+
role: 'user' | 'agent';
|
|
125
|
+
text: string | null;
|
|
126
|
+
isThinking?: boolean;
|
|
127
|
+
event: AgentEvent | null;
|
|
128
|
+
tool: ToolCall | null;
|
|
129
|
+
meta?: MessageMeta;
|
|
130
|
+
claudeUuid?: string;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
type StoredPermission = {
|
|
134
|
+
tool: string;
|
|
135
|
+
arguments: any;
|
|
136
|
+
createdAt: number;
|
|
137
|
+
completedAt?: number;
|
|
138
|
+
status: 'pending' | 'approved' | 'denied' | 'canceled';
|
|
139
|
+
reason?: string;
|
|
140
|
+
mode?: string;
|
|
141
|
+
allowedTools?: string[];
|
|
142
|
+
decision?: 'approved' | 'approved_for_session' | 'denied' | 'abort';
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
export type ReducerState = {
|
|
146
|
+
toolIdToMessageId: Map<string, string>; // toolId/permissionId -> messageId (since they're the same now)
|
|
147
|
+
sidechainToolIdToMessageId: Map<string, string>; // toolId -> sidechain messageId (for dual tracking)
|
|
148
|
+
permissions: Map<string, StoredPermission>; // Store permission details by ID for quick lookup
|
|
149
|
+
localIds: Map<string, string>;
|
|
150
|
+
messageIds: Map<string, string>; // originalId -> internalId
|
|
151
|
+
messages: Map<string, ReducerMessage>;
|
|
152
|
+
sidechains: Map<string, ReducerMessage[]>;
|
|
153
|
+
tracerState: TracerState; // Tracer state for sidechain processing
|
|
154
|
+
latestTodos?: {
|
|
155
|
+
todos: TodoItem[];
|
|
156
|
+
timestamp: number;
|
|
157
|
+
};
|
|
158
|
+
latestUsage?: {
|
|
159
|
+
inputTokens: number;
|
|
160
|
+
outputTokens: number;
|
|
161
|
+
cacheCreation: number;
|
|
162
|
+
cacheRead: number;
|
|
163
|
+
contextSize: number;
|
|
164
|
+
timestamp: number;
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
export function createReducer(): ReducerState {
|
|
169
|
+
return {
|
|
170
|
+
toolIdToMessageId: new Map(),
|
|
171
|
+
sidechainToolIdToMessageId: new Map(),
|
|
172
|
+
permissions: new Map(),
|
|
173
|
+
messages: new Map(),
|
|
174
|
+
localIds: new Map(),
|
|
175
|
+
messageIds: new Map(),
|
|
176
|
+
sidechains: new Map(),
|
|
177
|
+
tracerState: createTracer()
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
const ENABLE_LOGGING = false;
|
|
182
|
+
|
|
183
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
184
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function mergeToolInputs(existingInput: unknown, nextInput: unknown): unknown {
|
|
188
|
+
if (isRecord(existingInput) && isRecord(nextInput)) {
|
|
189
|
+
return { ...nextInput, ...existingInput };
|
|
190
|
+
}
|
|
191
|
+
return nextInput ?? existingInput;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function getSidechainOwner(state: ReducerState, sidechainId: string): ReducerMessage | null {
|
|
195
|
+
const ownerMessageId = state.messageIds.get(sidechainId);
|
|
196
|
+
if (ownerMessageId) {
|
|
197
|
+
const owner = state.messages.get(ownerMessageId);
|
|
198
|
+
if (owner?.tool) {
|
|
199
|
+
return owner;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
for (const message of state.messages.values()) {
|
|
204
|
+
if (message.realID === sidechainId && message.tool) {
|
|
205
|
+
return message;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return null;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function getVisibleSidechainPrompt(owner: ReducerMessage | null): string | null {
|
|
213
|
+
const prompt = owner?.tool?.input?.prompt;
|
|
214
|
+
if (typeof prompt !== 'string') {
|
|
215
|
+
return null;
|
|
216
|
+
}
|
|
217
|
+
const normalized = prompt.trim();
|
|
218
|
+
return normalized.length > 0 ? normalized : null;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function isDuplicateSidechainPrompt(
|
|
222
|
+
existingSidechain: ReducerMessage[],
|
|
223
|
+
ownerPrompt: string | null,
|
|
224
|
+
text: string,
|
|
225
|
+
): boolean {
|
|
226
|
+
if (existingSidechain.length > 0 || !ownerPrompt) {
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return text.trim() === ownerPrompt;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export type ReducerResult = {
|
|
234
|
+
messages: Message[];
|
|
235
|
+
todos?: TodoItem[];
|
|
236
|
+
usage?: {
|
|
237
|
+
inputTokens: number;
|
|
238
|
+
outputTokens: number;
|
|
239
|
+
cacheCreation: number;
|
|
240
|
+
cacheRead: number;
|
|
241
|
+
contextSize: number;
|
|
242
|
+
};
|
|
243
|
+
hasReadyEvent?: boolean;
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
function updateLatestTodos(state: ReducerState, value: unknown, timestamp: number) {
|
|
247
|
+
const parsed = TodoItemsSchema.safeParse(value);
|
|
248
|
+
if (!parsed.success) {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (!state.latestTodos || timestamp > state.latestTodos.timestamp) {
|
|
253
|
+
state.latestTodos = {
|
|
254
|
+
todos: parsed.data,
|
|
255
|
+
timestamp,
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export function reducer(state: ReducerState, messages: NormalizedMessage[], agentState?: AgentState | null): ReducerResult {
|
|
261
|
+
if (ENABLE_LOGGING) {
|
|
262
|
+
console.log(`[REDUCER] Called with ${messages.length} messages, agentState: ${agentState ? 'YES' : 'NO'}`);
|
|
263
|
+
if (agentState?.requests) {
|
|
264
|
+
console.log(`[REDUCER] AgentState has ${Object.keys(agentState.requests).length} pending requests`);
|
|
265
|
+
}
|
|
266
|
+
if (agentState?.completedRequests) {
|
|
267
|
+
console.log(`[REDUCER] AgentState has ${Object.keys(agentState.completedRequests).length} completed requests`);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
let newMessages: Message[] = [];
|
|
272
|
+
let changed: Set<string> = new Set();
|
|
273
|
+
let hasReadyEvent = false;
|
|
274
|
+
|
|
275
|
+
// First, trace all messages to identify sidechains
|
|
276
|
+
const tracedMessages = traceMessages(state.tracerState, messages);
|
|
277
|
+
|
|
278
|
+
// Separate sidechain and non-sidechain messages
|
|
279
|
+
let nonSidechainMessages = tracedMessages.filter(msg => !msg.sidechainId);
|
|
280
|
+
const sidechainMessages = tracedMessages.filter(msg => msg.sidechainId);
|
|
281
|
+
|
|
282
|
+
//
|
|
283
|
+
// Phase 0.5: Message-to-Event Conversion
|
|
284
|
+
// Convert certain messages to events before normal processing
|
|
285
|
+
//
|
|
286
|
+
|
|
287
|
+
if (ENABLE_LOGGING) {
|
|
288
|
+
console.log(`[REDUCER] Phase 0.5: Message-to-Event Conversion`);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
const messagesToProcess: NormalizedMessage[] = [];
|
|
292
|
+
const convertedEvents: { message: NormalizedMessage, event: AgentEvent }[] = [];
|
|
293
|
+
|
|
294
|
+
for (const msg of nonSidechainMessages) {
|
|
295
|
+
// Check if we've already processed this message
|
|
296
|
+
if (msg.role === 'user' && msg.localId && state.localIds.has(msg.localId)) {
|
|
297
|
+
continue;
|
|
298
|
+
}
|
|
299
|
+
if (state.messageIds.has(msg.id)) {
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// Filter out ready events completely - they should not create any message
|
|
304
|
+
if (msg.role === 'event' && msg.content.type === 'ready') {
|
|
305
|
+
// Mark as processed to prevent duplication but don't add to messages
|
|
306
|
+
state.messageIds.set(msg.id, msg.id);
|
|
307
|
+
hasReadyEvent = true;
|
|
308
|
+
continue;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// Session protocol turn-start markers are lifecycle-only and should stay invisible.
|
|
312
|
+
if (msg.role === 'event' && msg.content.type === 'message' && msg.content.message === 'Turn started') {
|
|
313
|
+
state.messageIds.set(msg.id, msg.id);
|
|
314
|
+
continue;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// Handle context reset events - reset state and let the message be shown
|
|
318
|
+
if (msg.role === 'event' && msg.content.type === 'message' && msg.content.message === 'Context was reset') {
|
|
319
|
+
// Reset todos to empty array and reset usage to zero
|
|
320
|
+
state.latestTodos = {
|
|
321
|
+
todos: [],
|
|
322
|
+
timestamp: msg.createdAt // Use message timestamp, not current time
|
|
323
|
+
};
|
|
324
|
+
state.latestUsage = {
|
|
325
|
+
inputTokens: 0,
|
|
326
|
+
outputTokens: 0,
|
|
327
|
+
cacheCreation: 0,
|
|
328
|
+
cacheRead: 0,
|
|
329
|
+
contextSize: 0,
|
|
330
|
+
timestamp: msg.createdAt // Use message timestamp to avoid blocking older usage data
|
|
331
|
+
};
|
|
332
|
+
// Don't continue - let the event be processed normally to create a message
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// Handle compaction completed events - reset context but keep todos
|
|
336
|
+
if (msg.role === 'event' && msg.content.type === 'message' && msg.content.message === 'Compaction completed') {
|
|
337
|
+
// Reset usage/context to zero but keep todos unchanged
|
|
338
|
+
state.latestUsage = {
|
|
339
|
+
inputTokens: 0,
|
|
340
|
+
outputTokens: 0,
|
|
341
|
+
cacheCreation: 0,
|
|
342
|
+
cacheRead: 0,
|
|
343
|
+
contextSize: 0,
|
|
344
|
+
timestamp: msg.createdAt // Use message timestamp to avoid blocking older usage data
|
|
345
|
+
};
|
|
346
|
+
// Don't continue - let the event be processed normally to create a message
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// Try to parse message as event
|
|
350
|
+
const event = parseMessageAsEvent(msg);
|
|
351
|
+
if (event) {
|
|
352
|
+
if (ENABLE_LOGGING) {
|
|
353
|
+
console.log(`[REDUCER] Converting message ${msg.id} to event:`, event);
|
|
354
|
+
}
|
|
355
|
+
convertedEvents.push({ message: msg, event });
|
|
356
|
+
// Mark as processed to prevent duplication
|
|
357
|
+
state.messageIds.set(msg.id, msg.id);
|
|
358
|
+
if (msg.role === 'user' && msg.localId) {
|
|
359
|
+
state.localIds.set(msg.localId, msg.id);
|
|
360
|
+
}
|
|
361
|
+
} else {
|
|
362
|
+
messagesToProcess.push(msg);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
// Process converted events immediately
|
|
367
|
+
for (const { message, event } of convertedEvents) {
|
|
368
|
+
const mid = allocateId();
|
|
369
|
+
state.messages.set(mid, {
|
|
370
|
+
id: mid,
|
|
371
|
+
realID: message.id,
|
|
372
|
+
role: 'agent',
|
|
373
|
+
createdAt: message.createdAt,
|
|
374
|
+
event: event,
|
|
375
|
+
tool: null,
|
|
376
|
+
text: null,
|
|
377
|
+
meta: message.meta,
|
|
378
|
+
});
|
|
379
|
+
changed.add(mid);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
// Update nonSidechainMessages to only include messages that weren't converted
|
|
383
|
+
nonSidechainMessages = messagesToProcess;
|
|
384
|
+
|
|
385
|
+
// Build a set of incoming tool IDs for quick lookup
|
|
386
|
+
const incomingToolIds = new Set<string>();
|
|
387
|
+
for (let msg of nonSidechainMessages) {
|
|
388
|
+
if (msg.role === 'agent') {
|
|
389
|
+
for (let c of msg.content) {
|
|
390
|
+
if (c.type === 'tool-call') {
|
|
391
|
+
incomingToolIds.add(c.id);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
//
|
|
398
|
+
// Phase 0: Process AgentState permissions
|
|
399
|
+
//
|
|
400
|
+
|
|
401
|
+
if (ENABLE_LOGGING) {
|
|
402
|
+
console.log(`[REDUCER] Phase 0: Processing AgentState`);
|
|
403
|
+
}
|
|
404
|
+
if (agentState) {
|
|
405
|
+
// Process pending permission requests
|
|
406
|
+
if (agentState.requests) {
|
|
407
|
+
for (const [permId, request] of Object.entries(agentState.requests)) {
|
|
408
|
+
// Skip if this permission is also in completedRequests (completed takes precedence)
|
|
409
|
+
if (agentState.completedRequests && agentState.completedRequests[permId]) {
|
|
410
|
+
continue;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
// Check if we already have a message for this permission ID
|
|
414
|
+
const existingMessageId = state.toolIdToMessageId.get(permId);
|
|
415
|
+
if (existingMessageId) {
|
|
416
|
+
// Update existing tool message with permission info
|
|
417
|
+
const message = state.messages.get(existingMessageId);
|
|
418
|
+
if (message?.tool && !message.tool.permission) {
|
|
419
|
+
if (ENABLE_LOGGING) {
|
|
420
|
+
console.log(`[REDUCER] Updating existing tool ${permId} with permission`);
|
|
421
|
+
}
|
|
422
|
+
message.tool.permission = {
|
|
423
|
+
id: permId,
|
|
424
|
+
status: 'pending'
|
|
425
|
+
};
|
|
426
|
+
changed.add(existingMessageId);
|
|
427
|
+
}
|
|
428
|
+
} else {
|
|
429
|
+
if (ENABLE_LOGGING) {
|
|
430
|
+
console.log(`[REDUCER] Creating new message for permission ${permId}`);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
// Create a new tool message for the permission request
|
|
434
|
+
let mid = allocateId();
|
|
435
|
+
let toolCall: ToolCall = {
|
|
436
|
+
name: request.tool,
|
|
437
|
+
state: 'running' as const,
|
|
438
|
+
input: request.arguments,
|
|
439
|
+
createdAt: request.createdAt || Date.now(),
|
|
440
|
+
startedAt: null,
|
|
441
|
+
completedAt: null,
|
|
442
|
+
description: null,
|
|
443
|
+
result: undefined,
|
|
444
|
+
permission: {
|
|
445
|
+
id: permId,
|
|
446
|
+
status: 'pending'
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
|
|
450
|
+
state.messages.set(mid, {
|
|
451
|
+
id: mid,
|
|
452
|
+
realID: null,
|
|
453
|
+
role: 'agent',
|
|
454
|
+
createdAt: request.createdAt || Date.now(),
|
|
455
|
+
text: null,
|
|
456
|
+
tool: toolCall,
|
|
457
|
+
event: null,
|
|
458
|
+
});
|
|
459
|
+
|
|
460
|
+
// Store by permission ID (which will match tool ID)
|
|
461
|
+
state.toolIdToMessageId.set(permId, mid);
|
|
462
|
+
|
|
463
|
+
changed.add(mid);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
// Store permission details for quick lookup
|
|
467
|
+
state.permissions.set(permId, {
|
|
468
|
+
tool: request.tool,
|
|
469
|
+
arguments: request.arguments,
|
|
470
|
+
createdAt: request.createdAt || Date.now(),
|
|
471
|
+
status: 'pending'
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
// Process completed permission requests
|
|
477
|
+
if (agentState.completedRequests) {
|
|
478
|
+
for (const [permId, completed] of Object.entries(agentState.completedRequests)) {
|
|
479
|
+
// Check if we have a message for this permission ID
|
|
480
|
+
const messageId = state.toolIdToMessageId.get(permId);
|
|
481
|
+
if (messageId) {
|
|
482
|
+
const message = state.messages.get(messageId);
|
|
483
|
+
if (message?.tool) {
|
|
484
|
+
// Skip if tool has already started actual execution with approval
|
|
485
|
+
if (message.tool.startedAt && message.tool.permission?.status === 'approved') {
|
|
486
|
+
continue;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
// Skip if permission already has date (came from tool result - preferred over agentState)
|
|
490
|
+
if (message.tool.permission?.date) {
|
|
491
|
+
continue;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
// Check if we need to update ANY field
|
|
495
|
+
const needsUpdate =
|
|
496
|
+
message.tool.permission?.status !== completed.status ||
|
|
497
|
+
message.tool.permission?.reason !== completed.reason ||
|
|
498
|
+
message.tool.permission?.mode !== completed.mode ||
|
|
499
|
+
message.tool.permission?.allowedTools !== completed.allowedTools ||
|
|
500
|
+
message.tool.permission?.decision !== completed.decision;
|
|
501
|
+
|
|
502
|
+
if (!needsUpdate) {
|
|
503
|
+
continue;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
let hasChanged = false;
|
|
507
|
+
|
|
508
|
+
// Update permission status
|
|
509
|
+
if (!message.tool.permission) {
|
|
510
|
+
message.tool.permission = {
|
|
511
|
+
id: permId,
|
|
512
|
+
status: completed.status,
|
|
513
|
+
mode: completed.mode || undefined,
|
|
514
|
+
allowedTools: completed.allowedTools || undefined,
|
|
515
|
+
decision: completed.decision || undefined,
|
|
516
|
+
reason: completed.reason || undefined
|
|
517
|
+
};
|
|
518
|
+
hasChanged = true;
|
|
519
|
+
} else {
|
|
520
|
+
// Update all fields
|
|
521
|
+
message.tool.permission.status = completed.status;
|
|
522
|
+
message.tool.permission.mode = completed.mode || undefined;
|
|
523
|
+
message.tool.permission.allowedTools = completed.allowedTools || undefined;
|
|
524
|
+
message.tool.permission.decision = completed.decision || undefined;
|
|
525
|
+
if (completed.reason) {
|
|
526
|
+
message.tool.permission.reason = completed.reason;
|
|
527
|
+
}
|
|
528
|
+
hasChanged = true;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
// Update tool state based on permission status
|
|
532
|
+
if (completed.status === 'approved') {
|
|
533
|
+
if (message.tool.state !== 'completed' && message.tool.state !== 'error' && message.tool.state !== 'running') {
|
|
534
|
+
message.tool.state = 'running';
|
|
535
|
+
hasChanged = true;
|
|
536
|
+
}
|
|
537
|
+
} else {
|
|
538
|
+
// denied or canceled
|
|
539
|
+
if (message.tool.state !== 'error' && message.tool.state !== 'completed') {
|
|
540
|
+
message.tool.state = 'error';
|
|
541
|
+
message.tool.completedAt = completed.completedAt || Date.now();
|
|
542
|
+
if (!message.tool.result && completed.reason) {
|
|
543
|
+
message.tool.result = { error: completed.reason };
|
|
544
|
+
}
|
|
545
|
+
hasChanged = true;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
// Update stored permission
|
|
550
|
+
state.permissions.set(permId, {
|
|
551
|
+
tool: completed.tool,
|
|
552
|
+
arguments: completed.arguments,
|
|
553
|
+
createdAt: completed.createdAt || Date.now(),
|
|
554
|
+
completedAt: completed.completedAt || undefined,
|
|
555
|
+
status: completed.status,
|
|
556
|
+
reason: completed.reason || undefined,
|
|
557
|
+
mode: completed.mode || undefined,
|
|
558
|
+
allowedTools: completed.allowedTools || undefined,
|
|
559
|
+
decision: completed.decision || undefined
|
|
560
|
+
});
|
|
561
|
+
|
|
562
|
+
if (hasChanged) {
|
|
563
|
+
changed.add(messageId);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
} else {
|
|
567
|
+
// No existing message - check if tool ID is in incoming messages
|
|
568
|
+
if (incomingToolIds.has(permId)) {
|
|
569
|
+
if (ENABLE_LOGGING) {
|
|
570
|
+
console.log(`[REDUCER] Storing permission ${permId} for incoming tool`);
|
|
571
|
+
}
|
|
572
|
+
// Store permission for when tool arrives in Phase 2
|
|
573
|
+
state.permissions.set(permId, {
|
|
574
|
+
tool: completed.tool,
|
|
575
|
+
arguments: completed.arguments,
|
|
576
|
+
createdAt: completed.createdAt || Date.now(),
|
|
577
|
+
completedAt: completed.completedAt || undefined,
|
|
578
|
+
status: completed.status,
|
|
579
|
+
reason: completed.reason || undefined
|
|
580
|
+
});
|
|
581
|
+
continue;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
// Skip if already processed as pending
|
|
585
|
+
if (agentState.requests && agentState.requests[permId]) {
|
|
586
|
+
continue;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
// Create a new message for completed permission without tool
|
|
590
|
+
let mid = allocateId();
|
|
591
|
+
let toolCall: ToolCall = {
|
|
592
|
+
name: completed.tool,
|
|
593
|
+
state: completed.status === 'approved' ? 'completed' : 'error',
|
|
594
|
+
input: completed.arguments,
|
|
595
|
+
createdAt: completed.createdAt || Date.now(),
|
|
596
|
+
startedAt: null,
|
|
597
|
+
completedAt: completed.completedAt || Date.now(),
|
|
598
|
+
description: null,
|
|
599
|
+
result: completed.status === 'approved'
|
|
600
|
+
? 'Approved'
|
|
601
|
+
: (completed.reason ? { error: completed.reason } : undefined),
|
|
602
|
+
permission: {
|
|
603
|
+
id: permId,
|
|
604
|
+
status: completed.status,
|
|
605
|
+
reason: completed.reason || undefined,
|
|
606
|
+
mode: completed.mode || undefined,
|
|
607
|
+
allowedTools: completed.allowedTools || undefined,
|
|
608
|
+
decision: completed.decision || undefined
|
|
609
|
+
}
|
|
610
|
+
};
|
|
611
|
+
|
|
612
|
+
state.messages.set(mid, {
|
|
613
|
+
id: mid,
|
|
614
|
+
realID: null,
|
|
615
|
+
role: 'agent',
|
|
616
|
+
createdAt: completed.createdAt || Date.now(),
|
|
617
|
+
text: null,
|
|
618
|
+
tool: toolCall,
|
|
619
|
+
event: null,
|
|
620
|
+
});
|
|
621
|
+
|
|
622
|
+
state.toolIdToMessageId.set(permId, mid);
|
|
623
|
+
|
|
624
|
+
// Store permission details
|
|
625
|
+
state.permissions.set(permId, {
|
|
626
|
+
tool: completed.tool,
|
|
627
|
+
arguments: completed.arguments,
|
|
628
|
+
createdAt: completed.createdAt || Date.now(),
|
|
629
|
+
completedAt: completed.completedAt || undefined,
|
|
630
|
+
status: completed.status,
|
|
631
|
+
reason: completed.reason || undefined,
|
|
632
|
+
mode: completed.mode || undefined,
|
|
633
|
+
allowedTools: completed.allowedTools || undefined,
|
|
634
|
+
decision: completed.decision || undefined
|
|
635
|
+
});
|
|
636
|
+
|
|
637
|
+
changed.add(mid);
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
//
|
|
644
|
+
// Phase 1: Process non-sidechain user messages and text messages
|
|
645
|
+
//
|
|
646
|
+
|
|
647
|
+
for (let msg of nonSidechainMessages) {
|
|
648
|
+
if (msg.role === 'user') {
|
|
649
|
+
// Check if we've seen this localId before
|
|
650
|
+
if (msg.localId && state.localIds.has(msg.localId)) {
|
|
651
|
+
continue;
|
|
652
|
+
}
|
|
653
|
+
// Check if we've seen this message ID before
|
|
654
|
+
if (state.messageIds.has(msg.id)) {
|
|
655
|
+
continue;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
// Create a new message
|
|
659
|
+
let mid = allocateId();
|
|
660
|
+
state.messages.set(mid, {
|
|
661
|
+
id: mid,
|
|
662
|
+
realID: msg.id,
|
|
663
|
+
role: 'user',
|
|
664
|
+
createdAt: msg.createdAt,
|
|
665
|
+
text: msg.content.text,
|
|
666
|
+
tool: null,
|
|
667
|
+
event: null,
|
|
668
|
+
meta: msg.meta,
|
|
669
|
+
claudeUuid: msg.claudeUuid,
|
|
670
|
+
});
|
|
671
|
+
|
|
672
|
+
// Track both localId and messageId
|
|
673
|
+
if (msg.localId) {
|
|
674
|
+
state.localIds.set(msg.localId, mid);
|
|
675
|
+
}
|
|
676
|
+
state.messageIds.set(msg.id, mid);
|
|
677
|
+
|
|
678
|
+
changed.add(mid);
|
|
679
|
+
} else if (msg.role === 'agent') {
|
|
680
|
+
// Check if we've seen this agent message before
|
|
681
|
+
if (state.messageIds.has(msg.id)) {
|
|
682
|
+
continue;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
// Mark this message as seen
|
|
686
|
+
state.messageIds.set(msg.id, msg.id);
|
|
687
|
+
|
|
688
|
+
// Process usage data if present
|
|
689
|
+
if (msg.usage) {
|
|
690
|
+
processUsageData(state, msg.usage, msg.createdAt);
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
// Process text and thinking content (tool calls handled in Phase 2)
|
|
694
|
+
for (let c of msg.content) {
|
|
695
|
+
if (c.type === 'text' || c.type === 'thinking') {
|
|
696
|
+
let mid = allocateId();
|
|
697
|
+
const isThinking = c.type === 'thinking';
|
|
698
|
+
state.messages.set(mid, {
|
|
699
|
+
id: mid,
|
|
700
|
+
realID: msg.id,
|
|
701
|
+
role: 'agent',
|
|
702
|
+
createdAt: msg.createdAt,
|
|
703
|
+
text: isThinking ? `*${c.thinking}*` : c.text,
|
|
704
|
+
isThinking,
|
|
705
|
+
tool: null,
|
|
706
|
+
event: null,
|
|
707
|
+
meta: msg.meta,
|
|
708
|
+
});
|
|
709
|
+
changed.add(mid);
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
//
|
|
716
|
+
// Phase 2: Process non-sidechain tool calls
|
|
717
|
+
//
|
|
718
|
+
|
|
719
|
+
if (ENABLE_LOGGING) {
|
|
720
|
+
console.log(`[REDUCER] Phase 2: Processing tool calls`);
|
|
721
|
+
}
|
|
722
|
+
for (let msg of nonSidechainMessages) {
|
|
723
|
+
if (msg.role === 'agent') {
|
|
724
|
+
for (let c of msg.content) {
|
|
725
|
+
if (c.type === 'tool-call') {
|
|
726
|
+
// Direct lookup by tool ID (since permission ID = tool ID now)
|
|
727
|
+
const existingMessageId = state.toolIdToMessageId.get(c.id);
|
|
728
|
+
|
|
729
|
+
if (existingMessageId) {
|
|
730
|
+
if (ENABLE_LOGGING) {
|
|
731
|
+
console.log(`[REDUCER] Found existing message for tool ${c.id}`);
|
|
732
|
+
}
|
|
733
|
+
// Update existing message with tool execution details
|
|
734
|
+
const message = state.messages.get(existingMessageId);
|
|
735
|
+
if (message?.tool) {
|
|
736
|
+
message.realID = msg.id;
|
|
737
|
+
message.tool.input = mergeToolInputs(message.tool.input, c.input);
|
|
738
|
+
message.tool.description = c.description;
|
|
739
|
+
message.tool.startedAt = msg.createdAt;
|
|
740
|
+
// If permission was approved and shown as completed (no tool), now it's running
|
|
741
|
+
if (message.tool.permission?.status === 'approved' && message.tool.state === 'completed') {
|
|
742
|
+
message.tool.state = 'running';
|
|
743
|
+
message.tool.completedAt = null;
|
|
744
|
+
message.tool.result = undefined;
|
|
745
|
+
}
|
|
746
|
+
changed.add(existingMessageId);
|
|
747
|
+
|
|
748
|
+
}
|
|
749
|
+
} else {
|
|
750
|
+
if (ENABLE_LOGGING) {
|
|
751
|
+
console.log(`[REDUCER] Creating new message for tool ${c.id}`);
|
|
752
|
+
}
|
|
753
|
+
// Check if there's a stored permission for this tool
|
|
754
|
+
const permission = state.permissions.get(c.id);
|
|
755
|
+
|
|
756
|
+
let toolCall: ToolCall = {
|
|
757
|
+
name: c.name,
|
|
758
|
+
state: 'running' as const,
|
|
759
|
+
input: permission ? mergeToolInputs(permission.arguments, c.input) : c.input,
|
|
760
|
+
createdAt: permission ? permission.createdAt : msg.createdAt, // Use permission timestamp if available
|
|
761
|
+
startedAt: msg.createdAt,
|
|
762
|
+
completedAt: null,
|
|
763
|
+
description: c.description,
|
|
764
|
+
result: undefined,
|
|
765
|
+
};
|
|
766
|
+
|
|
767
|
+
// Add permission info if found
|
|
768
|
+
if (permission) {
|
|
769
|
+
if (ENABLE_LOGGING) {
|
|
770
|
+
console.log(`[REDUCER] Found stored permission for tool ${c.id}`);
|
|
771
|
+
}
|
|
772
|
+
toolCall.permission = {
|
|
773
|
+
id: c.id,
|
|
774
|
+
status: permission.status,
|
|
775
|
+
reason: permission.reason,
|
|
776
|
+
mode: permission.mode,
|
|
777
|
+
allowedTools: permission.allowedTools,
|
|
778
|
+
decision: permission.decision
|
|
779
|
+
};
|
|
780
|
+
|
|
781
|
+
// Update state based on permission status
|
|
782
|
+
if (permission.status !== 'approved') {
|
|
783
|
+
toolCall.state = 'error';
|
|
784
|
+
toolCall.completedAt = permission.completedAt || msg.createdAt;
|
|
785
|
+
if (permission.reason) {
|
|
786
|
+
toolCall.result = { error: permission.reason };
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
let mid = allocateId();
|
|
792
|
+
state.messages.set(mid, {
|
|
793
|
+
id: mid,
|
|
794
|
+
realID: msg.id,
|
|
795
|
+
role: 'agent',
|
|
796
|
+
createdAt: msg.createdAt,
|
|
797
|
+
text: null,
|
|
798
|
+
tool: toolCall,
|
|
799
|
+
event: null,
|
|
800
|
+
meta: msg.meta,
|
|
801
|
+
});
|
|
802
|
+
|
|
803
|
+
state.toolIdToMessageId.set(c.id, mid);
|
|
804
|
+
changed.add(mid);
|
|
805
|
+
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
//
|
|
813
|
+
// Phase 3: Process non-sidechain tool results
|
|
814
|
+
//
|
|
815
|
+
|
|
816
|
+
for (let msg of nonSidechainMessages) {
|
|
817
|
+
if (msg.role === 'agent') {
|
|
818
|
+
for (let c of msg.content) {
|
|
819
|
+
if (c.type === 'tool-result') {
|
|
820
|
+
// Find the message containing this tool
|
|
821
|
+
let messageId = state.toolIdToMessageId.get(c.tool_use_id);
|
|
822
|
+
if (!messageId) {
|
|
823
|
+
continue;
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
let message = state.messages.get(messageId);
|
|
827
|
+
if (!message || !message.tool) {
|
|
828
|
+
continue;
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
if (message.tool.state !== 'running') {
|
|
832
|
+
continue;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
// Update tool state and result
|
|
836
|
+
message.tool.state = c.is_error ? 'error' : 'completed';
|
|
837
|
+
message.tool.result = c.content;
|
|
838
|
+
message.tool.completedAt = msg.createdAt;
|
|
839
|
+
|
|
840
|
+
// Update permission data if provided by backend
|
|
841
|
+
if (c.permissions) {
|
|
842
|
+
// Merge with existing permission to preserve decision field from agentState
|
|
843
|
+
if (message.tool.permission) {
|
|
844
|
+
// Preserve existing decision if not provided in tool result
|
|
845
|
+
const existingDecision = message.tool.permission.decision;
|
|
846
|
+
message.tool.permission = {
|
|
847
|
+
...message.tool.permission,
|
|
848
|
+
id: c.tool_use_id,
|
|
849
|
+
status: c.permissions.result === 'approved' ? 'approved' : 'denied',
|
|
850
|
+
date: c.permissions.date,
|
|
851
|
+
mode: c.permissions.mode,
|
|
852
|
+
allowedTools: c.permissions.allowedTools,
|
|
853
|
+
decision: c.permissions.decision || existingDecision
|
|
854
|
+
};
|
|
855
|
+
} else {
|
|
856
|
+
message.tool.permission = {
|
|
857
|
+
id: c.tool_use_id,
|
|
858
|
+
status: c.permissions.result === 'approved' ? 'approved' : 'denied',
|
|
859
|
+
date: c.permissions.date,
|
|
860
|
+
mode: c.permissions.mode,
|
|
861
|
+
allowedTools: c.permissions.allowedTools,
|
|
862
|
+
decision: c.permissions.decision
|
|
863
|
+
};
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
if (message.tool.name === 'TodoWrite' && !c.is_error) {
|
|
868
|
+
updateLatestTodos(state, message.tool.result?.newTodos, msg.createdAt);
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
changed.add(messageId);
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
//
|
|
878
|
+
// Phase 4: Process sidechains and store them in state
|
|
879
|
+
//
|
|
880
|
+
|
|
881
|
+
// For each sidechain message, store it in the state and mark the Task as changed
|
|
882
|
+
for (const msg of sidechainMessages) {
|
|
883
|
+
if (!msg.sidechainId) continue;
|
|
884
|
+
|
|
885
|
+
// Skip if we already processed this message
|
|
886
|
+
if (state.messageIds.has(msg.id)) continue;
|
|
887
|
+
|
|
888
|
+
// Mark as processed
|
|
889
|
+
state.messageIds.set(msg.id, msg.id);
|
|
890
|
+
|
|
891
|
+
// Get or create the sidechain array for this Task
|
|
892
|
+
const existingSidechain = state.sidechains.get(msg.sidechainId) || [];
|
|
893
|
+
const owner = getSidechainOwner(state, msg.sidechainId);
|
|
894
|
+
const ownerPrompt = getVisibleSidechainPrompt(owner);
|
|
895
|
+
|
|
896
|
+
// Process and add new sidechain messages
|
|
897
|
+
if (msg.role === 'agent' && msg.content[0]?.type === 'sidechain') {
|
|
898
|
+
// This is the sidechain root - create a user message
|
|
899
|
+
if (isDuplicateSidechainPrompt(existingSidechain, ownerPrompt, msg.content[0].prompt)) {
|
|
900
|
+
state.sidechains.set(msg.sidechainId, existingSidechain);
|
|
901
|
+
continue;
|
|
902
|
+
}
|
|
903
|
+
let mid = allocateId();
|
|
904
|
+
let userMsg: ReducerMessage = {
|
|
905
|
+
id: mid,
|
|
906
|
+
realID: msg.id,
|
|
907
|
+
role: 'user',
|
|
908
|
+
createdAt: msg.createdAt,
|
|
909
|
+
text: msg.content[0].prompt,
|
|
910
|
+
tool: null,
|
|
911
|
+
event: null,
|
|
912
|
+
meta: msg.meta,
|
|
913
|
+
};
|
|
914
|
+
state.messages.set(mid, userMsg);
|
|
915
|
+
existingSidechain.push(userMsg);
|
|
916
|
+
} else if (msg.role === 'agent') {
|
|
917
|
+
// Process agent content in sidechain
|
|
918
|
+
for (let c of msg.content) {
|
|
919
|
+
if (c.type === 'text' || c.type === 'thinking') {
|
|
920
|
+
const text = c.type === 'thinking' ? c.thinking : c.text;
|
|
921
|
+
if (c.type === 'text' && isDuplicateSidechainPrompt(existingSidechain, ownerPrompt, text)) {
|
|
922
|
+
continue;
|
|
923
|
+
}
|
|
924
|
+
let mid = allocateId();
|
|
925
|
+
const isThinking = c.type === 'thinking';
|
|
926
|
+
let textMsg: ReducerMessage = {
|
|
927
|
+
id: mid,
|
|
928
|
+
realID: msg.id,
|
|
929
|
+
role: 'agent',
|
|
930
|
+
createdAt: msg.createdAt,
|
|
931
|
+
text: isThinking ? `*${c.thinking}*` : c.text,
|
|
932
|
+
isThinking,
|
|
933
|
+
tool: null,
|
|
934
|
+
event: null,
|
|
935
|
+
meta: msg.meta,
|
|
936
|
+
};
|
|
937
|
+
state.messages.set(mid, textMsg);
|
|
938
|
+
existingSidechain.push(textMsg);
|
|
939
|
+
} else if (c.type === 'tool-call') {
|
|
940
|
+
// Check if there's already a permission message for this tool
|
|
941
|
+
const existingPermissionMessageId = state.toolIdToMessageId.get(c.id);
|
|
942
|
+
|
|
943
|
+
let mid = allocateId();
|
|
944
|
+
let toolCall: ToolCall = {
|
|
945
|
+
name: c.name,
|
|
946
|
+
state: 'running' as const,
|
|
947
|
+
input: c.input,
|
|
948
|
+
createdAt: msg.createdAt,
|
|
949
|
+
startedAt: null,
|
|
950
|
+
completedAt: null,
|
|
951
|
+
description: c.description,
|
|
952
|
+
result: undefined
|
|
953
|
+
};
|
|
954
|
+
|
|
955
|
+
// If there's a permission message, copy its permission info
|
|
956
|
+
if (existingPermissionMessageId) {
|
|
957
|
+
const permissionMessage = state.messages.get(existingPermissionMessageId);
|
|
958
|
+
if (permissionMessage?.tool?.permission) {
|
|
959
|
+
toolCall.permission = { ...permissionMessage.tool.permission };
|
|
960
|
+
// Update the permission message to show it's running
|
|
961
|
+
if (permissionMessage.tool.state !== 'completed' && permissionMessage.tool.state !== 'error') {
|
|
962
|
+
permissionMessage.tool.state = 'running';
|
|
963
|
+
permissionMessage.tool.startedAt = msg.createdAt;
|
|
964
|
+
permissionMessage.tool.description = c.description;
|
|
965
|
+
changed.add(existingPermissionMessageId);
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
let toolMsg: ReducerMessage = {
|
|
971
|
+
id: mid,
|
|
972
|
+
realID: msg.id,
|
|
973
|
+
role: 'agent',
|
|
974
|
+
createdAt: msg.createdAt,
|
|
975
|
+
text: null,
|
|
976
|
+
tool: toolCall,
|
|
977
|
+
event: null,
|
|
978
|
+
meta: msg.meta,
|
|
979
|
+
};
|
|
980
|
+
state.messages.set(mid, toolMsg);
|
|
981
|
+
existingSidechain.push(toolMsg);
|
|
982
|
+
|
|
983
|
+
// Map sidechain tool separately to avoid overwriting permission mapping
|
|
984
|
+
state.sidechainToolIdToMessageId.set(c.id, mid);
|
|
985
|
+
} else if (c.type === 'tool-result') {
|
|
986
|
+
// Process tool result in sidechain - update BOTH messages
|
|
987
|
+
|
|
988
|
+
// Update the sidechain tool message
|
|
989
|
+
let sidechainMessageId = state.sidechainToolIdToMessageId.get(c.tool_use_id);
|
|
990
|
+
if (sidechainMessageId) {
|
|
991
|
+
let sidechainMessage = state.messages.get(sidechainMessageId);
|
|
992
|
+
if (sidechainMessage && sidechainMessage.tool && sidechainMessage.tool.state === 'running') {
|
|
993
|
+
sidechainMessage.tool.state = c.is_error ? 'error' : 'completed';
|
|
994
|
+
sidechainMessage.tool.result = c.content;
|
|
995
|
+
sidechainMessage.tool.completedAt = msg.createdAt;
|
|
996
|
+
|
|
997
|
+
// Update permission data if provided by backend
|
|
998
|
+
if (c.permissions) {
|
|
999
|
+
// Merge with existing permission to preserve decision field from agentState
|
|
1000
|
+
if (sidechainMessage.tool.permission) {
|
|
1001
|
+
const existingDecision = sidechainMessage.tool.permission.decision;
|
|
1002
|
+
sidechainMessage.tool.permission = {
|
|
1003
|
+
...sidechainMessage.tool.permission,
|
|
1004
|
+
id: c.tool_use_id,
|
|
1005
|
+
status: c.permissions.result === 'approved' ? 'approved' : 'denied',
|
|
1006
|
+
date: c.permissions.date,
|
|
1007
|
+
mode: c.permissions.mode,
|
|
1008
|
+
allowedTools: c.permissions.allowedTools,
|
|
1009
|
+
decision: c.permissions.decision || existingDecision
|
|
1010
|
+
};
|
|
1011
|
+
} else {
|
|
1012
|
+
sidechainMessage.tool.permission = {
|
|
1013
|
+
id: c.tool_use_id,
|
|
1014
|
+
status: c.permissions.result === 'approved' ? 'approved' : 'denied',
|
|
1015
|
+
date: c.permissions.date,
|
|
1016
|
+
mode: c.permissions.mode,
|
|
1017
|
+
allowedTools: c.permissions.allowedTools,
|
|
1018
|
+
decision: c.permissions.decision
|
|
1019
|
+
};
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
// Also update the main permission message if it exists
|
|
1026
|
+
let permissionMessageId = state.toolIdToMessageId.get(c.tool_use_id);
|
|
1027
|
+
if (permissionMessageId) {
|
|
1028
|
+
let permissionMessage = state.messages.get(permissionMessageId);
|
|
1029
|
+
if (permissionMessage && permissionMessage.tool && permissionMessage.tool.state === 'running') {
|
|
1030
|
+
permissionMessage.tool.state = c.is_error ? 'error' : 'completed';
|
|
1031
|
+
permissionMessage.tool.result = c.content;
|
|
1032
|
+
permissionMessage.tool.completedAt = msg.createdAt;
|
|
1033
|
+
|
|
1034
|
+
// Update permission data if provided by backend
|
|
1035
|
+
if (c.permissions) {
|
|
1036
|
+
// Merge with existing permission to preserve decision field from agentState
|
|
1037
|
+
if (permissionMessage.tool.permission) {
|
|
1038
|
+
const existingDecision = permissionMessage.tool.permission.decision;
|
|
1039
|
+
permissionMessage.tool.permission = {
|
|
1040
|
+
...permissionMessage.tool.permission,
|
|
1041
|
+
id: c.tool_use_id,
|
|
1042
|
+
status: c.permissions.result === 'approved' ? 'approved' : 'denied',
|
|
1043
|
+
date: c.permissions.date,
|
|
1044
|
+
mode: c.permissions.mode,
|
|
1045
|
+
allowedTools: c.permissions.allowedTools,
|
|
1046
|
+
decision: c.permissions.decision || existingDecision
|
|
1047
|
+
};
|
|
1048
|
+
} else {
|
|
1049
|
+
permissionMessage.tool.permission = {
|
|
1050
|
+
id: c.tool_use_id,
|
|
1051
|
+
status: c.permissions.result === 'approved' ? 'approved' : 'denied',
|
|
1052
|
+
date: c.permissions.date,
|
|
1053
|
+
mode: c.permissions.mode,
|
|
1054
|
+
allowedTools: c.permissions.allowedTools,
|
|
1055
|
+
decision: c.permissions.decision
|
|
1056
|
+
};
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
changed.add(permissionMessageId);
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
// Update the sidechain in state
|
|
1068
|
+
state.sidechains.set(msg.sidechainId, existingSidechain);
|
|
1069
|
+
|
|
1070
|
+
// Find the Task tool message that owns this sidechain and mark it as changed
|
|
1071
|
+
// msg.sidechainId is the realID of the Task message
|
|
1072
|
+
for (const [internalId, message] of state.messages) {
|
|
1073
|
+
if (message.realID === msg.sidechainId && message.tool) {
|
|
1074
|
+
changed.add(internalId);
|
|
1075
|
+
break;
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
//
|
|
1081
|
+
// Phase 5: Process mode-switch messages
|
|
1082
|
+
//
|
|
1083
|
+
|
|
1084
|
+
for (let msg of nonSidechainMessages) {
|
|
1085
|
+
if (msg.role === 'event') {
|
|
1086
|
+
let mid = allocateId();
|
|
1087
|
+
state.messages.set(mid, {
|
|
1088
|
+
id: mid,
|
|
1089
|
+
realID: msg.id,
|
|
1090
|
+
role: 'agent',
|
|
1091
|
+
createdAt: msg.createdAt,
|
|
1092
|
+
event: msg.content,
|
|
1093
|
+
tool: null,
|
|
1094
|
+
text: null,
|
|
1095
|
+
meta: msg.meta,
|
|
1096
|
+
});
|
|
1097
|
+
changed.add(mid);
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
//
|
|
1102
|
+
// Collect changed messages (only root-level messages)
|
|
1103
|
+
//
|
|
1104
|
+
|
|
1105
|
+
for (let id of changed) {
|
|
1106
|
+
let existing = state.messages.get(id);
|
|
1107
|
+
if (!existing) continue;
|
|
1108
|
+
|
|
1109
|
+
let message = convertReducerMessageToMessage(existing, state);
|
|
1110
|
+
if (message) {
|
|
1111
|
+
newMessages.push(message);
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
//
|
|
1116
|
+
// Debug changes
|
|
1117
|
+
//
|
|
1118
|
+
|
|
1119
|
+
if (ENABLE_LOGGING) {
|
|
1120
|
+
console.log(JSON.stringify(messages, null, 2));
|
|
1121
|
+
console.log(`[REDUCER] Changed messages: ${changed.size}`);
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
return {
|
|
1125
|
+
messages: newMessages,
|
|
1126
|
+
todos: state.latestTodos?.todos,
|
|
1127
|
+
usage: state.latestUsage ? {
|
|
1128
|
+
inputTokens: state.latestUsage.inputTokens,
|
|
1129
|
+
outputTokens: state.latestUsage.outputTokens,
|
|
1130
|
+
cacheCreation: state.latestUsage.cacheCreation,
|
|
1131
|
+
cacheRead: state.latestUsage.cacheRead,
|
|
1132
|
+
contextSize: state.latestUsage.contextSize
|
|
1133
|
+
} : undefined,
|
|
1134
|
+
hasReadyEvent: hasReadyEvent || undefined
|
|
1135
|
+
};
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
//
|
|
1139
|
+
// Helpers
|
|
1140
|
+
//
|
|
1141
|
+
|
|
1142
|
+
function allocateId() {
|
|
1143
|
+
return Math.random().toString(36).substring(2, 15);
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
function processUsageData(state: ReducerState, usage: UsageData, timestamp: number) {
|
|
1147
|
+
// Only update if this is newer than the current latest usage
|
|
1148
|
+
if (!state.latestUsage || timestamp > state.latestUsage.timestamp) {
|
|
1149
|
+
state.latestUsage = {
|
|
1150
|
+
inputTokens: usage.input_tokens,
|
|
1151
|
+
outputTokens: usage.output_tokens,
|
|
1152
|
+
cacheCreation: usage.cache_creation_input_tokens || 0,
|
|
1153
|
+
cacheRead: usage.cache_read_input_tokens || 0,
|
|
1154
|
+
contextSize: (usage.cache_creation_input_tokens || 0) + (usage.cache_read_input_tokens || 0) + usage.input_tokens,
|
|
1155
|
+
timestamp: timestamp
|
|
1156
|
+
};
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
|
|
1161
|
+
function convertReducerMessageToMessage(reducerMsg: ReducerMessage, state: ReducerState): Message | null {
|
|
1162
|
+
if (reducerMsg.role === 'user' && reducerMsg.text !== null) {
|
|
1163
|
+
return {
|
|
1164
|
+
id: reducerMsg.id,
|
|
1165
|
+
localId: null,
|
|
1166
|
+
createdAt: reducerMsg.createdAt,
|
|
1167
|
+
kind: 'user-text',
|
|
1168
|
+
text: reducerMsg.text,
|
|
1169
|
+
...(reducerMsg.meta?.displayText && { displayText: reducerMsg.meta.displayText }),
|
|
1170
|
+
...(reducerMsg.claudeUuid && { claudeUuid: reducerMsg.claudeUuid }),
|
|
1171
|
+
meta: reducerMsg.meta
|
|
1172
|
+
};
|
|
1173
|
+
} else if (reducerMsg.role === 'agent' && reducerMsg.text !== null) {
|
|
1174
|
+
return {
|
|
1175
|
+
id: reducerMsg.id,
|
|
1176
|
+
localId: null,
|
|
1177
|
+
createdAt: reducerMsg.createdAt,
|
|
1178
|
+
kind: 'agent-text',
|
|
1179
|
+
text: reducerMsg.text,
|
|
1180
|
+
...(reducerMsg.isThinking && { isThinking: true }),
|
|
1181
|
+
meta: reducerMsg.meta
|
|
1182
|
+
};
|
|
1183
|
+
} else if (reducerMsg.role === 'agent' && reducerMsg.tool !== null) {
|
|
1184
|
+
// Convert children recursively
|
|
1185
|
+
let childMessages: Message[] = [];
|
|
1186
|
+
let children = reducerMsg.realID ? state.sidechains.get(reducerMsg.realID) || [] : [];
|
|
1187
|
+
for (let child of children) {
|
|
1188
|
+
let childMessage = convertReducerMessageToMessage(child, state);
|
|
1189
|
+
if (childMessage) {
|
|
1190
|
+
childMessages.push(childMessage);
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
return {
|
|
1195
|
+
id: reducerMsg.id,
|
|
1196
|
+
localId: null,
|
|
1197
|
+
createdAt: reducerMsg.createdAt,
|
|
1198
|
+
kind: 'tool-call',
|
|
1199
|
+
tool: { ...reducerMsg.tool },
|
|
1200
|
+
children: childMessages,
|
|
1201
|
+
meta: reducerMsg.meta
|
|
1202
|
+
};
|
|
1203
|
+
} else if (reducerMsg.role === 'agent' && reducerMsg.event !== null) {
|
|
1204
|
+
return {
|
|
1205
|
+
id: reducerMsg.id,
|
|
1206
|
+
createdAt: reducerMsg.createdAt,
|
|
1207
|
+
kind: 'agent-event',
|
|
1208
|
+
event: reducerMsg.event,
|
|
1209
|
+
meta: reducerMsg.meta
|
|
1210
|
+
};
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
return null;
|
|
1214
|
+
}
|