From 252ccd2e4c080c279e25fbcefdda64cf0a9f28a7 Mon Sep 17 00:00:00 2001 From: Tiago Valente Date: Sat, 10 Oct 2026 10:16:57 -0700 Subject: [PATCH] CheatSpecter 0.3.0 Browser-based real-time modding tool for offline single-player games on a jailbroken PS5, served by a payload on the console. - Value search, memory and code views, find what writes to a value - Cheats as patches, held values, injected code, calls and scripts - .cspector cheat files, saved on the PS5 or on your device - Community tables in JSON, SHN and MC4 from three repositories - Game library with names, logos and sizes; start a game from the browser - MCP server for assistants --- .gitignore | 8 + LICENSE | 674 ++++ README.md | 213 ++ Start CheatSpecter.bat | 15 + Start CheatSpecter.command | 21 + bridge/demo-library.mjs | 96 + bridge/server.mjs | 558 ++++ cheats/PPSA99999_01.000.000.json | 41 + components.json | 22 + index.html | 16 + mcp/server.ts | 792 +++++ mcp/tsconfig.json | 5 + mock/mock-ps5.mjs | 974 ++++++ package-lock.json | 3465 +++++++++++++++++++++ package.json | 49 + payload/README.md | 74 + payload/src/assets.h | 19 + payload/src/main.c | 1426 +++++++++ public/ghost.svg | 8 + scripts/build-mcp.mjs | 134 + scripts/build-payload.mjs | 53 + scripts/dev.mjs | 11 + scripts/embed-assets.mjs | 64 + scripts/send-payload.mjs | 48 + src/components/kibo-ui/banner/index.tsx | 142 + src/components/kibo-ui/dropzone/index.tsx | 202 ++ src/components/kibo-ui/pill/index.tsx | 166 + src/components/kibo-ui/spinner/index.tsx | 271 ++ src/components/kibo-ui/status/index.tsx | 62 + src/components/ui/alert.tsx | 65 + src/components/ui/avatar.tsx | 106 + src/components/ui/badge.tsx | 47 + src/components/ui/button.tsx | 63 + src/components/ui/card.tsx | 91 + src/components/ui/dialog.tsx | 156 + src/components/ui/dropdown-menu.tsx | 256 ++ src/components/ui/input.tsx | 20 + src/components/ui/label.tsx | 21 + src/components/ui/select.tsx | 187 ++ src/components/ui/spinner.tsx | 15 + src/components/ui/switch.tsx | 32 + src/components/ui/table.tsx | 115 + src/components/ui/tabs.tsx | 90 + src/components/ui/textarea.tsx | 17 + src/lib/bytes.ts | 94 + src/lib/catalog.ts | 263 ++ src/lib/cheats.ts | 182 ++ src/lib/library.ts | 229 ++ src/lib/locations.ts | 215 ++ src/lib/make.ts | 51 + src/lib/pointerscan.ts | 108 + src/lib/ps5debug.ts | 1021 ++++++ src/lib/scanner.ts | 583 ++++ src/lib/script.ts | 194 ++ src/lib/session.ts | 200 ++ src/lib/storage.ts | 30 + src/lib/table.ts | 604 ++++ src/lib/tablestore.ts | 127 + src/lib/tracer.ts | 200 ++ src/lib/trainer.ts | 227 ++ src/lib/transport.ts | 160 + src/lib/utils.ts | 6 + src/lib/x86.ts | 250 ++ src/lib/x86.worker.ts | 54 + src/lib/x86client.ts | 37 + src/main.tsx | 5 + src/styles.css | 121 + src/ui/App.tsx | 240 ++ src/ui/CheatsTab.tsx | 416 +++ src/ui/CodeTab.tsx | 444 +++ src/ui/ConsoleView.tsx | 349 +++ src/ui/EntryEditor.tsx | 367 +++ src/ui/LibraryView.tsx | 243 ++ src/ui/MemoryTab.tsx | 326 ++ src/ui/OwnCheats.tsx | 273 ++ src/ui/PointerFinder.tsx | 126 + src/ui/ScannerTab.tsx | 559 ++++ src/ui/bits.tsx | 89 + src/ui/workbench.tsx | 337 ++ test/formats.test.mjs | 121 + test/library.test.mjs | 155 + test/mcp.test.mjs | 181 ++ test/payload.test.mjs | 351 +++ test/protocol.test.mjs | 448 +++ test/workbench.test.mjs | 513 +++ tsconfig.json | 17 + vite.config.ts | 26 + 87 files changed, 21452 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 Start CheatSpecter.bat create mode 100755 Start CheatSpecter.command create mode 100644 bridge/demo-library.mjs create mode 100644 bridge/server.mjs create mode 100644 cheats/PPSA99999_01.000.000.json create mode 100644 components.json create mode 100644 index.html create mode 100644 mcp/server.ts create mode 100644 mcp/tsconfig.json create mode 100644 mock/mock-ps5.mjs create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 payload/README.md create mode 100644 payload/src/assets.h create mode 100644 payload/src/main.c create mode 100644 public/ghost.svg create mode 100644 scripts/build-mcp.mjs create mode 100644 scripts/build-payload.mjs create mode 100644 scripts/dev.mjs create mode 100644 scripts/embed-assets.mjs create mode 100644 scripts/send-payload.mjs create mode 100644 src/components/kibo-ui/banner/index.tsx create mode 100644 src/components/kibo-ui/dropzone/index.tsx create mode 100644 src/components/kibo-ui/pill/index.tsx create mode 100644 src/components/kibo-ui/spinner/index.tsx create mode 100644 src/components/kibo-ui/status/index.tsx create mode 100644 src/components/ui/alert.tsx create mode 100644 src/components/ui/avatar.tsx create mode 100644 src/components/ui/badge.tsx create mode 100644 src/components/ui/button.tsx create mode 100644 src/components/ui/card.tsx create mode 100644 src/components/ui/dialog.tsx create mode 100644 src/components/ui/dropdown-menu.tsx create mode 100644 src/components/ui/input.tsx create mode 100644 src/components/ui/label.tsx create mode 100644 src/components/ui/select.tsx create mode 100644 src/components/ui/spinner.tsx create mode 100644 src/components/ui/switch.tsx create mode 100644 src/components/ui/table.tsx create mode 100644 src/components/ui/tabs.tsx create mode 100644 src/components/ui/textarea.tsx create mode 100644 src/lib/bytes.ts create mode 100644 src/lib/catalog.ts create mode 100644 src/lib/cheats.ts create mode 100644 src/lib/library.ts create mode 100644 src/lib/locations.ts create mode 100644 src/lib/make.ts create mode 100644 src/lib/pointerscan.ts create mode 100644 src/lib/ps5debug.ts create mode 100644 src/lib/scanner.ts create mode 100644 src/lib/script.ts create mode 100644 src/lib/session.ts create mode 100644 src/lib/storage.ts create mode 100644 src/lib/table.ts create mode 100644 src/lib/tablestore.ts create mode 100644 src/lib/tracer.ts create mode 100644 src/lib/trainer.ts create mode 100644 src/lib/transport.ts create mode 100644 src/lib/utils.ts create mode 100644 src/lib/x86.ts create mode 100644 src/lib/x86.worker.ts create mode 100644 src/lib/x86client.ts create mode 100644 src/main.tsx create mode 100644 src/styles.css create mode 100644 src/ui/App.tsx create mode 100644 src/ui/CheatsTab.tsx create mode 100644 src/ui/CodeTab.tsx create mode 100644 src/ui/ConsoleView.tsx create mode 100644 src/ui/EntryEditor.tsx create mode 100644 src/ui/LibraryView.tsx create mode 100644 src/ui/MemoryTab.tsx create mode 100644 src/ui/OwnCheats.tsx create mode 100644 src/ui/PointerFinder.tsx create mode 100644 src/ui/ScannerTab.tsx create mode 100644 src/ui/bits.tsx create mode 100644 src/ui/workbench.tsx create mode 100644 test/formats.test.mjs create mode 100644 test/library.test.mjs create mode 100644 test/mcp.test.mjs create mode 100644 test/payload.test.mjs create mode 100644 test/protocol.test.mjs create mode 100644 test/workbench.test.mjs create mode 100644 tsconfig.json create mode 100644 vite.config.ts diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..353f86b --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +node_modules/ +dist/ +.DS_Store +*.log +payload/build/ +payload/*.elf +mcp/build/ +mcp/*.mcpb diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/README.md b/README.md new file mode 100644 index 0000000..a6af75c --- /dev/null +++ b/README.md @@ -0,0 +1,213 @@ +# CheatSpecter + +A real-time modding tool for jailbroken PS5 consoles that runs in a web +browser. Open it on a Mac, Windows or Linux machine, or on your phone, and it +talks to the [ps5debug-NG](https://github.com/Pharaoh2k/ps5debug-NG) payload +running on the console. + +For single-player games you own. There is nothing here for online play. + +## What it does + +For people who just want cheats: + +- **Find the console.** Consoles running the debugger are discovered on the + network; no IP typing unless discovery is blocked. +- **See what is running.** Name, icon, title ID and version of the game on + screen. +- **Your game library.** Every installed game with its platform (PS5 or PS4) + and size, and a Start button that boots it from the page. +- **Cheats as switches.** Matching cheat tables are looked up online for the + running game and shown as toggles. Before a cheat is switched on, the bytes + in the game's memory are compared with what the table expects; a cheat for + the wrong build is left off instead of corrupting the game. +- **Import** table files: CheatSpecter's own `.cspecter` format and the + community JSON, SHN and MC4 formats. +- **Save your own cheats** to the PS5 or to the device you are on. On the PS5 + they are kept as `/data/cheatspecter/cheats/-<version>.cspecter` + and load by themselves whenever that game is running, from any device. + +The library, game names and icons, starting games and saving to the PS5 need +the CheatSpecter payload on the console (`payload/cheatspecter.elf`), because +the debugger cannot do those things. Everything else works with ps5debug-NG +alone. + +For people who make them: + +- **Find a value**, known or unknown ("a bar with no number"), narrow it down + as it changes, edit it, hold it. "Auto" searches the common number types at + once when you do not know how the game stores it. +- **Find what writes to it.** A hardware watchpoint lists the instructions + that touch a value, and one click turns "the instruction that lowers my + ammo" into a saved cheat. +- **Memory view**: live hex, the selected bytes read as every number type, + follow pointers, write values or raw bytes. +- **Code view**: disassembly, byte-pattern search, and per-instruction actions + (disable it, hook it, follow a call, copy a signature). +- **Make it survive restarts**: a pointer-path search from the game's + executable to a value on the heap. +- **Your own table**, with five kinds of entry: byte patches (located by + signature so they survive game updates, and able to change several places + under one switch), held values, injected assembly + through a code cave, calls to the game's own functions, and scripts + (JavaScript with a small API for reading, writing, calling and switching + other entries). Export it to share, or as a GoldHEN table where the format + allows. + +The maker features need ps5debug-NG specifically; with the original ps5debug +the table switches still work. + +**What has run on a real PS5** (firmware 13.60, ps5debug-NG 1.3.2): finding +the running game, its name and icon, the game library, loading community +tables, known-value searches, watchpoints, byte patches located by offset and +by pattern, and saving and auto-loading `.cspecter` files on the console. + +**Only tested against the built-in mock console so far:** injected code, +function calls, scripts, the pointer-path search, unknown-value searches, +starting a game from the library, and PS4 titles. + +## Things that can crash a game + +These come from how debugging a live process works, not from bugs to be fixed +later. The app says so at the point of use; they are collected here. + +- **Tracing** attaches a debugger to the game. If the browser tab is closed + mid-trace, the console detaches without disarming the watchpoint and the + game may die at the next hit. Press Stop first. +- **Injected code** is written while the game keeps running. Switch a hook on + at a quiet moment. A hook replaces at least five bytes; if that spans + several instructions and the game jumps into the middle of them, it crashes. +- **Function calls** borrow a game thread. The function must return within + about two seconds, and one that returns -1 is retried by the console up to + seven times. +- **Scripts and imported entries that run code** are held for review before + first use. Read them. Only use tables from people you trust. + +## Run it + +Double-click **Start CheatSpecter.command** (macOS) or **Start +CheatSpecter.bat** (Windows). It installs on first run, starts the bridge and +opens the browser. Needs [Node.js](https://nodejs.org) 20.19 or newer. + +From a terminal: + +```sh +npm install +npm start # real console +npm run demo # adds a pretend PS5 so you can click around without one +``` + +Tracing ("what writes to this") makes the console connect back to this +computer on TCP port 755, so the firewall has to let that in; macOS will ask +the first time. `npm run demo` uses a different port and is for the pretend +console only. + +The start-up message lists the address to open from a phone on the same Wi-Fi. + +On the PS5, load ps5debug-NG first (etaHEN can start it from its toolbox). It +shows a "loaded" notification when ready. + +## How it fits together + +``` + Browser (any device) Computer PS5 +┌──────────────────────┐ ┌──────────────────┐ ┌──────────────────────┐ +│ web app │ │ bridge/server.mjs│ │ ps5debug-NG │ +│ protocol client │◄─►│ WebSocket ⇄ TCP │◄─►│ TCP 744 │ +│ scanner, cheats │ WS│ serves the app │TCP│ │ +└──────────┬───────────┘ └──────────────────┘ └──────────────────────┘ + │ HTTPS + ▼ + cheat table collections (GitHub) +``` + +Browsers cannot open raw TCP sockets, so something has to relay. There are two +ways to run that relay, and the web app is identical in both: + +- **On a computer** (`bridge/server.mjs`), as drawn above. This is what the + launcher starts, and what has been exercised most. +- **On the console itself** (`payload/`). A small ELF serves the app and + relays to the debugger locally, so nothing is installed anywhere and any + device just opens `http://<PS5 IP>:8744`. See `payload/README.md`. + +Cheat tables are fetched by the browser, so the console itself never needs +internet access. + +| Path | What it is | +| --- | --- | +| `src/lib/ps5debug.ts` | The debugger's wire protocol | +| `src/lib/scanner.ts` | Known-value, unknown-value and Auto scans | +| `mcp/server.ts` | The same library as MCP tools for Claude | +| `src/lib/cheats.ts` | Community cheat tables: parsing, state detection, applying | +| `src/lib/table.ts` | CheatSpecter's own table format and the runner that applies it | +| `src/lib/locations.ts` | Signatures, offsets and pointer paths, resolved to addresses | +| `src/lib/tracer.ts` | "What writes to this address" | +| `src/lib/pointerscan.ts` | Pointer-path search | +| `src/lib/script.ts` | The script API and its sandbox | +| `src/lib/x86.ts` | Disassembly, relocation and signatures (iced-x86, in a worker) | +| `src/lib/catalog.ts` | Online table lookup and offline cache | +| `src/ui/` | The interface (React, Tailwind) | +| `src/components/` | shadcn/ui and [Kibo UI](https://www.kibo-ui.com) components, added with the shadcn CLI | +| `bridge/server.mjs` | WebSocket-to-TCP relay, discovery, static files | +| `payload/` | The on-console ELF: the same relay in C, with the app embedded | +| `mock/mock-ps5.mjs` | Pretend console with a tiny simulated game | +| `cheats/` | Drop table files here to have them offered alongside the online ones | +| `test/` | End-to-end tests: client → bridge → mock | + +## Development + +```sh +npm run dev # Vite with hot reload + bridge + demo console +npm test # needs Node 22.18+ (the tests import the TypeScript directly) +npm run typecheck +``` + +## Where cheat tables come from + +Tables are read at runtime from these community collections, in their original +location. Nothing from them is copied into this repository. + +- [etaHEN PS5 Cheats](https://github.com/etaHEN/PS5_Cheats) +- [GoldHEN Cheat Repository](https://github.com/GoldHEN/GoldHEN_Cheat_Repository) +- [HEN Cheats Collection](https://github.com/TeeKay87/HEN-Cheats-Collection) + +All three formats they publish are read: JSON, SHN and MC4. When a repository +has the same table in several formats, the JSON one is used. + +## Using it from Claude (MCP) + +`npm run mcp` builds `mcp/cheatspecter-<version>.mcpb`, a desktop extension +for the Claude app. Open the file to install it and enter the PS5's address +when asked. Claude then has tools to see what is running, search and read +memory, find the code that changes a value, disassemble, and save cheats to +the same `.cspecter` file the web app loads. It runs on your computer and +talks to the payload on the console; nothing is installed on the PS5. + +To run it by hand instead: `CHEATSPECTER_HOST=<ps5 address> node mcp/build/server/index.mjs` +speaks MCP over stdin/stdout. + +## The .cspecter format + +A `.cspecter` file is minified JSON: + +```json +{"format":"cheatspecter","formatVersion":1, + "game":{"name":"…","titleId":"PPSA07391","version":"01.009.000"}, + "cheats":[{"name":"Infinite ammo","type":"patch","at":{"kind":"module","offset":"0x2040"},"on":"909090","off":"FF4B28"}]} +``` + +`type` is one of `patch`, `value`, `inject`, `call` or `script`. A patch can +carry `"more": [{"at": …, "on": "…", "off": "…"}]` for further places changed by +the same switch. A formatted copy loads the same as a minified one. + +## Safety notes + +- The bridge only relays to private network addresses on the debugger's port, + and only accepts WebSocket connections from the page it served. +- Anyone on your network can reach the debugger directly on port 744 anyway; + the bridge does not make that better or worse. Use a network you trust. + +## License + +GPL-3.0-only, matching ps5debug-NG, whose protocol this implements and whose +handler logic the mock console follows. diff --git a/Start CheatSpecter.bat b/Start CheatSpecter.bat new file mode 100644 index 0000000..74906e0 --- /dev/null +++ b/Start CheatSpecter.bat @@ -0,0 +1,15 @@ +@echo off +rem Double-click to start CheatSpecter on Windows. +cd /d "%~dp0" +where node >nul 2>nul +if errorlevel 1 ( + echo CheatSpecter needs Node.js. Install it from https://nodejs.org and open this again. + pause + exit /b 1 +) +if not exist node_modules ( + echo First run: installing, about a minute... + call npm install || (pause & exit /b 1) +) +call npm start -- --open +pause diff --git a/Start CheatSpecter.command b/Start CheatSpecter.command new file mode 100755 index 0000000..7bb269e --- /dev/null +++ b/Start CheatSpecter.command @@ -0,0 +1,21 @@ +#!/bin/bash +# Double-click to start CheatSpecter on macOS. Add "demo" to try it without a console: +# ./Start\ CheatSpecter.command demo +cd "$(dirname "$0")" || exit 1 + +if ! command -v node >/dev/null 2>&1; then + echo "CheatSpecter needs Node.js. Install it from https://nodejs.org and open this again." + read -r -p "Press Return to close." + exit 1 +fi + +if [ ! -d node_modules ]; then + echo "First run: installing (about a minute)..." + npm install || { read -r -p "Install failed. Press Return to close."; exit 1; } +fi + +if [ "$1" = "demo" ]; then + npm run demo -- --open +else + npm start -- --open +fi diff --git a/bridge/demo-library.mjs b/bridge/demo-library.mjs new file mode 100644 index 0000000..85c0694 --- /dev/null +++ b/bridge/demo-library.mjs @@ -0,0 +1,96 @@ +// The demo console's game library: what the on-console payload would answer +// for /api/library and /api/appmeta/..., so the library screen can be tried +// without a PS5. Also used by the tests as a source of well-formed files. + +/** Builds a PS4 param.sfo from string and number entries. */ +export function buildSfo(entries) { + const keys = Object.keys(entries).sort(); + const enc = new TextEncoder(); + const rows = keys.map((key) => { + const value = entries[key]; + if (typeof value === 'number') { + const data = new Uint8Array(4); + new DataView(data.buffer).setUint32(0, value, true); + return { key, fmt: 0x0404, data, len: 4, max: 4 }; + } + const text = enc.encode(value); + const max = (text.length + 1 + 3) & ~3; + const data = new Uint8Array(max); + data.set(text); + return { key, fmt: 0x0204, data, len: text.length + 1, max }; + }); + const keyBytes = rows.map((r) => enc.encode(r.key + '\0')); + const keyTableStart = 20 + 16 * rows.length; + const keyTableSize = keyBytes.reduce((n, k) => n + k.length, 0); + const dataStart = (keyTableStart + keyTableSize + 3) & ~3; + const out = new Uint8Array(dataStart + rows.reduce((n, r) => n + r.max, 0)); + const view = new DataView(out.buffer); + out.set([0x00, 0x50, 0x53, 0x46]); + view.setUint32(4, 0x0101, true); + view.setUint32(8, keyTableStart, true); + view.setUint32(12, dataStart, true); + view.setUint32(16, rows.length, true); + let keyOff = 0; + let dataOff = 0; + rows.forEach((r, i) => { + const at = 20 + 16 * i; + view.setUint16(at, keyOff, true); + view.setUint16(at + 2, r.fmt, true); + view.setUint32(at + 4, r.len, true); + view.setUint32(at + 8, r.max, true); + view.setUint32(at + 12, dataOff, true); + out.set(keyBytes[i], keyTableStart + keyOff); + out.set(r.data, dataStart + dataOff); + keyOff += keyBytes[i].length; + dataOff += r.max; + }); + return out; +} + +export function buildParamJson(titleId, name, version) { + return JSON.stringify({ + titleId, + contentId: `IV9999-${titleId}_00-0000000000000000`, + contentVersion: version, + localizedParameters: { defaultLanguage: 'en-US', 'en-US': { titleName: name } }, + }); +} + +const GIB = 1024 ** 3; + +export const DEMO_TITLES = [ + { id: 'PPSA99999', meta: 'json', name: 'Specter Run', version: '01.000.000', size: 41.6 * GIB, path: '/user/app/PPSA99999' }, + { id: 'PPSA20417', meta: 'json', name: 'Neon Circuit: Midnight Tour', version: '01.012.000', size: 87.3 * GIB, path: '/user/app/PPSA20417' }, + { id: 'PPSA31082', meta: 'json', name: 'Hollow Harbor', version: '01.004.000', size: 23.9 * GIB, path: '/mnt/ext0/user/app/PPSA31082' }, + { id: 'CUSA58230', meta: 'sfo', name: 'Pellet Kingdom Remastered', version: '01.07', size: 12.2 * GIB, path: '/user/app/CUSA58230' }, + { id: 'CUSA60944', meta: 'sfo', name: 'Lantern Road', version: '01.00', size: 0, path: '' }, +]; + +/** Answers a library request the way the payload would. Returns null for "not found". */ +export function demoLibraryResponse(pathname) { + if (pathname === '/api/library') { + const titles = DEMO_TITLES.map(({ id, meta, size, path }) => ({ id, meta, size: Math.round(size), path })); + return { type: 'application/json; charset=utf-8', body: JSON.stringify({ titles }) }; + } + const m = /^\/api\/appmeta\/([A-Z]{4}\d{5})\/(param\.json|param\.sfo|icon0\.png)$/.exec(pathname); + const title = m && DEMO_TITLES.find((t) => t.id === m[1]); + if (!title) return null; + if (m[2] === 'icon0.png') { + // A stand-in for the game's icon: its initials on a tile. Browsers go by the content type, not the name. + const initials = title.name.split(/\s+/).slice(0, 2).map((w) => w[0]).join('').toUpperCase(); + const hue = [...title.id].reduce((n, c) => n + c.charCodeAt(0), 0) % 360; + const svg = + `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><rect width="512" height="512" fill="hsl(${hue} 55% 22%)"/>` + + `<circle cx="256" cy="256" r="150" fill="hsl(${hue} 70% 45%)"/>` + + `<text x="256" y="300" font-family="system-ui,sans-serif" font-size="130" font-weight="700" text-anchor="middle" fill="#fff">${initials}</text></svg>`; + return { type: 'image/svg+xml', body: svg }; + } + if (m[2] === 'param.json' && title.meta === 'json') { + return { type: 'application/json; charset=utf-8', body: buildParamJson(title.id, title.name, title.version) }; + } + if (m[2] === 'param.sfo' && title.meta === 'sfo') { + const sfo = buildSfo({ TITLE: title.name, TITLE_ID: title.id, APP_VER: title.version, CATEGORY: 'gd', PARENTAL_LEVEL: 1 }); + return { type: 'application/octet-stream', body: Buffer.from(sfo) }; + } + return null; +} diff --git a/bridge/server.mjs b/bridge/server.mjs new file mode 100644 index 0000000..6b2c08a --- /dev/null +++ b/bridge/server.mjs @@ -0,0 +1,558 @@ +// CheatSpecter dev bridge. +// +// Browsers cannot open raw TCP sockets, and the PS5 debugger only speaks raw +// TCP. This small server sits between them on a computer: it serves the web +// app and relays a WebSocket to the debugger's TCP port, byte for byte. +// +// The on-console payload will replace this with the same three things: +// GET / the web app +// GET /api/info { mode, version } +// WS /ws binary frames <-> debugger TCP stream +// WS /events debugger stop reports (the console connects back to us +// on TCP 755 when a debugger attaches; those bytes are +// forwarded here) +// +// Extras that only make sense on a computer: LAN discovery, a local cheats +// folder, and a built-in demo console (--demo). +// +// node bridge/server.mjs [--demo] [--open] [--port 8744] + +import http from 'node:http'; +import net from 'node:net'; +import dgram from 'node:dgram'; +import os from 'node:os'; +import fs from 'node:fs'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { spawn } from 'node:child_process'; +import { WebSocketServer } from 'ws'; +import { DEMO_TITLES, demoLibraryResponse } from './demo-library.mjs'; + +const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..'); +const DIST = path.join(ROOT, 'dist'); +const CHEATS_DIR = path.join(ROOT, 'cheats'); +const TABLE_MAX = 4 << 20; +const VERSION = JSON.parse(fs.readFileSync(path.join(ROOT, 'package.json'), 'utf8')).version; + +const DEBUGGER_PORT = 744; +const DISCOVERY_PORT = 1010; +const EVENT_PORT = 755; +/** Where the CheatSpecter payload on the console answers. */ +const DEFAULT_PAYLOAD_PORT = 8744; +const DISCOVERY_MAGIC = Buffer.from([0xaa, 0xaa, 0xff, 0xff]); // 0xFFFFAAAA little-endian + +const MIME = { + '.html': 'text/html; charset=utf-8', + '.js': 'text/javascript; charset=utf-8', + '.css': 'text/css; charset=utf-8', + '.svg': 'image/svg+xml', + '.json': 'application/json; charset=utf-8', + '.png': 'image/png', + '.ico': 'image/x-icon', + '.webmanifest': 'application/manifest+json', + '.wasm': 'application/wasm', +}; + +// ---- which addresses the bridge will relay to -------------------------------- + +/** + * The bridge only relays to consoles on the local network. Without this it + * would be an open proxy for anything that can reach it. + */ +export function isPrivateAddress(host) { + if (net.isIPv4(host)) { + const [a, b] = host.split('.').map(Number); + return a === 10 || a === 127 || (a === 192 && b === 168) || (a === 172 && b >= 16 && b <= 31) || (a === 169 && b === 254); + } + return false; +} + +/** + * A page from another site must not be able to drive the bridge, so the + * WebSocket is only accepted from the app this server itself served. + */ +function sameOrigin(req) { + const origin = req.headers.origin; + if (!origin) return true; // not a browser (tests, scripts on this machine) + try { + return new URL(origin).host === req.headers.host; + } catch { + return false; + } +} + +// ---- discovery --------------------------------------------------------------- + +function broadcastAddresses() { + const out = new Set(['255.255.255.255']); + for (const list of Object.values(os.networkInterfaces())) { + for (const i of list ?? []) { + if (i.family !== 'IPv4' || i.internal) continue; + const ip = i.address.split('.').map(Number); + const mask = i.netmask.split('.').map(Number); + out.add(ip.map((octet, n) => (octet | (~mask[n] & 0xff)) & 0xff).join('.')); + } + } + return [...out]; +} + +/** Asks the LAN "is there a debugger here?" and collects whoever echoes. */ +function discover(extraProbes, waitMs = 900) { + return new Promise((resolve) => { + const found = new Map(); + const sock = dgram.createSocket({ type: 'udp4', reuseAddr: true }); + const finish = () => { + try { + sock.close(); + } catch { + // already closed + } + resolve([...found.values()]); + }; + sock.on('error', finish); + sock.on('message', (msg, rinfo) => { + if (msg.length !== 4 || !msg.equals(DISCOVERY_MAGIC)) return; + const probe = extraProbes.find((p) => p.udpPort === rinfo.port && p.host === rinfo.address); + if (probe) found.set(`${probe.host}:${probe.port}`, { host: probe.host, port: probe.port, label: probe.label }); + else if (rinfo.port === DISCOVERY_PORT) found.set(rinfo.address, { host: rinfo.address, port: DEBUGGER_PORT, label: 'PS5' }); + }); + sock.bind(0, () => { + try { + sock.setBroadcast(true); + } catch { + // some platforms refuse; unicast probes still work + } + for (const addr of broadcastAddresses()) sock.send(DISCOVERY_MAGIC, DISCOVERY_PORT, addr, () => {}); + for (const p of extraProbes) sock.send(DISCOVERY_MAGIC, p.udpPort, p.host, () => {}); + setTimeout(finish, waitMs); + }); + }); +} + +// ---- http -------------------------------------------------------------------- + +function sendJson(res, code, body) { + const data = JSON.stringify(body); + res.writeHead(code, { 'content-type': MIME['.json'], 'cache-control': 'no-store' }); + res.end(data); +} + +function serveFile(res, file, cache = 'no-cache') { + fs.readFile(file, (err, data) => { + if (err) { + res.writeHead(404, { 'content-type': 'text/plain; charset=utf-8' }); + res.end('Not found'); + return; + } + res.writeHead(200, { + 'content-type': MIME[path.extname(file).toLowerCase()] ?? 'application/octet-stream', + 'cache-control': cache, + }); + res.end(data); + }); +} + +/** Resolves a URL path inside a folder, refusing anything that escapes it. */ +function safeJoin(base, urlPath) { + let rel; + try { + rel = decodeURIComponent(urlPath); + } catch { + return null; + } + const full = path.resolve(base, '.' + path.posix.normalize('/' + rel)); + return full === base || full.startsWith(base + path.sep) ? full : null; +} + +/** Community tables dropped into the cheats/ folder: JSON, SHN or MC4. */ +const LOCAL_TABLE_RE = /\.(json|shn|mc4)$/i; + +function localCheatIndex() { + let files = []; + try { + files = fs.readdirSync(CHEATS_DIR).filter((f) => LOCAL_TABLE_RE.test(f)); + } catch { + return ''; + } + const lines = []; + for (const f of files) { + let name = ''; + try { + name = String(JSON.parse(fs.readFileSync(path.join(CHEATS_DIR, f), 'utf8').replace(/^/, '')).name ?? ''); + } catch { + // listed anyway; the app reports the parse error when it is opened + } + lines.push(`${f}=${name}`); + } + return lines.join('\n'); +} + +/** + * @param {object} [opts] + * @param {number} [opts.port] + * @param {string} [opts.host] + * @param {{host:string, port:number, udpPort:number, label:string}|null} [opts.demo] + * @param {number|null} [opts.eventPort] where consoles connect back with debugger events (default 755, null = off) + */ +export function startBridge(opts = {}) { + const demo = opts.demo ?? null; + const PAYLOAD_PORT = opts.payloadPort ?? DEFAULT_PAYLOAD_PORT; + /** The demo console's saved cheat files, kept only while the bridge runs. */ + const demoTables = new Map(); + const allowed = (host, port) => + (isPrivateAddress(host) && port === DEBUGGER_PORT) || (demo && host === demo.host && port === demo.port); + + // ---- debugger events ---- + // On attach the console opens a TCP connection back to the machine that sent + // the attach, always to port 755. Whatever arrives is passed to the browsers + // that asked for events from that console. + const eventPort = opts.eventPort === undefined ? EVENT_PORT : opts.eventPort; + const eventSubs = new Map(); // console address -> Set<WebSocket> + let eventsError = eventPort === null ? 'Debugger events are turned off' : null; + const eventServer = net.createServer((sock) => { + const from = (sock.remoteAddress ?? '').replace(/^::ffff:/, ''); + sock.on('error', () => {}); + sock.on('data', (chunk) => { + for (const ws of eventSubs.get(from) ?? []) { + if (ws.readyState === ws.OPEN) ws.send(chunk, { binary: true }); + } + }); + // The console closes this when the session ends (detach, game exit, error). + sock.on('close', () => { + for (const ws of eventSubs.get(from) ?? []) { + if (ws.readyState === ws.OPEN) ws.close(4005, 'The console ended the debugging session'); + } + }); + }); + const eventsReady = new Promise((resolve) => { + if (eventPort === null) return resolve(); + eventServer.once('error', (err) => { + eventsError = + err.code === 'EADDRINUSE' + ? `Port ${eventPort} is in use by another program (another debugger tool?)` + : err.code === 'EACCES' + ? `This system does not let CheatSpecter listen on port ${eventPort} without administrator rights` + : `Could not listen on port ${eventPort} (${err.code})`; + resolve(); + }); + eventServer.listen(eventPort, '0.0.0.0', () => resolve()); + }); + + /** + * The game library, game names, "start this game" and the cheat files saved + * on the PS5 are all handled by the CheatSpecter payload on the console (the + * debugger can do none of them), so these requests are passed on to it. + */ + async function consoleApi(req, res, url) { + const p = url.pathname; + const host = url.searchParams.get('host') ?? ''; + const launching = p.startsWith('/api/launch/'); + const table = /^\/api\/tables\/([A-Z]{4}\d{5})(?:\/([0-9A-Za-z][0-9A-Za-z.]{0,15}))?$/.exec(p); + const saving = !!table && !!table[2] && req.method === 'PUT'; + const methodOk = launching ? req.method === 'POST' : saving || req.method === 'GET'; + if (!methodOk || !sameOrigin(req)) { + res.writeHead(sameOrigin(req) ? 405 : 403); + res.end(); + return; + } + + let body; + if (saving) { + const chunks = []; + let size = 0; + for await (const chunk of req) { + size += chunk.length; + if (size > TABLE_MAX) { + res.writeHead(413); + res.end(); + return; + } + chunks.push(chunk); + } + body = Buffer.concat(chunks); + } + + if (demo && host === demo.host) { + if (launching) { + const known = DEMO_TITLES.some((t) => p === `/api/launch/${t.id}`); + const running = p === '/api/launch/PPSA99999'; + sendJson(res, running ? 200 : known ? 500 : 404, running + ? { ok: true } + : { ok: false, error: known ? 'The demo console only has one game it can actually run' : 'That game is not on this console' }); + return; + } + if (table) { + const [, tid, version] = table; + if (!version) { + const versions = [...demoTables.keys()].filter((k) => k.startsWith(`${tid}-`)).map((k) => k.slice(10)); + sendJson(res, 200, { folder: '/data/cheatspecter/cheats', versions }); + } else if (saving) { + demoTables.set(`${tid}-${version}`, body); + res.writeHead(204); + res.end(); + } else if (demoTables.has(`${tid}-${version}`)) { + res.writeHead(200, { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' }); + res.end(demoTables.get(`${tid}-${version}`)); + } else { + res.writeHead(404); + res.end(); + } + return; + } + const answer = demoLibraryResponse(p); + if (!answer) { + res.writeHead(404); + res.end(); + return; + } + res.writeHead(200, { 'content-type': answer.type, 'cache-control': 'no-store' }); + res.end(answer.body); + return; + } + if (!isPrivateAddress(host) || !(table || /^\/api\/(library|appmeta\/[A-Z]{4}\d{5}\/[a-z0-9.]+|launch\/[A-Z]{4}\d{5})$/.test(p))) { + res.writeHead(400); + res.end(); + return; + } + try { + const upstream = await fetch(`http://${host}:${PAYLOAD_PORT}${p}`, { + method: req.method, + body, + signal: AbortSignal.timeout(launching ? 30_000 : 20_000), + }); + const answer = Buffer.from(await upstream.arrayBuffer()); + res.writeHead(upstream.status, { + 'content-type': upstream.headers.get('content-type') ?? 'application/octet-stream', + 'cache-control': upstream.headers.get('cache-control') ?? 'no-store', + 'x-content-type-options': 'nosniff', + }); + res.end(answer); + } catch { + // Nothing answering on the payload's port: it has not been loaded on this console. + sendJson(res, 502, { ok: false, error: 'payload-missing' }); + } + } + + const server = http.createServer((req, res) => { + const url = new URL(req.url ?? '/', 'http://localhost'); + const p = url.pathname; + + if (p.startsWith('/api/tables/') || p === '/api/library' || p.startsWith('/api/appmeta/') || p.startsWith('/api/launch/')) { + void consoleApi(req, res, url); + return; + } + if (req.method !== 'GET' && req.method !== 'HEAD') { + res.writeHead(405); + res.end(); + return; + } + if (p === '/api/info') { + sendJson(res, 200, { + mode: 'bridge', + version: VERSION, + events: eventsError === null, + ...(demo ? { demo: { host: demo.host, port: demo.port, label: demo.label } } : {}), + }); + return; + } + if (p === '/api/discover') { + discover(demo ? [demo] : []).then((list) => sendJson(res, 200, list)); + return; + } + if (p === '/api/local-cheats') { + res.writeHead(200, { 'content-type': 'text/plain; charset=utf-8', 'cache-control': 'no-store' }); + res.end(localCheatIndex()); + return; + } + if (p.startsWith('/local-cheats/')) { + const file = safeJoin(CHEATS_DIR, p.slice('/local-cheats/'.length)); + if (!file || !LOCAL_TABLE_RE.test(file)) { + res.writeHead(404); + res.end(); + return; + } + serveFile(res, file, 'no-store'); + return; + } + + const file = safeJoin(DIST, p === '/' ? 'index.html' : p.slice(1)); + if (!file) { + res.writeHead(404); + res.end(); + return; + } + if (!fs.existsSync(DIST)) { + res.writeHead(503, { 'content-type': 'text/plain; charset=utf-8' }); + res.end('The web app has not been built yet. Run "npm run build" (or "npm start", which does it for you).'); + return; + } + // Hashed asset names never change content, so they can be cached hard. + serveFile(res, file, p.startsWith('/assets/') ? 'public, max-age=31536000, immutable' : 'no-cache'); + }); + + const wss = new WebSocketServer({ noServer: true, perMessageDeflate: false }); + + server.on('upgrade', (req, socket, head) => { + const url = new URL(req.url ?? '/', 'http://localhost'); + if ((url.pathname !== '/ws' && url.pathname !== '/events') || !sameOrigin(req)) { + socket.write('HTTP/1.1 403 Forbidden\r\n\r\n'); + socket.destroy(); + return; + } + wss.handleUpgrade(req, socket, head, (ws) => (url.pathname === '/ws' ? relay(ws, url) : subscribe(ws, url))); + }); + + function subscribe(ws, url) { + const host = url.searchParams.get('host') ?? ''; + if (!isPrivateAddress(host)) { + ws.close(4003, 'That address is not a console on your local network'); + return; + } + if (eventsError) { + ws.close(4004, eventsError); + return; + } + if (!eventSubs.has(host)) eventSubs.set(host, new Set()); + eventSubs.get(host).add(ws); + ws.on('close', () => eventSubs.get(host)?.delete(ws)); + ws.on('error', () => {}); + } + + function relay(ws, url) { + const host = url.searchParams.get('host') ?? ''; + const port = Number(url.searchParams.get('port') ?? DEBUGGER_PORT); + if (!allowed(host, port)) { + ws.close(4003, 'That address is not a console on your local network'); + return; + } + + const tcp = net.connect({ host, port }); + tcp.setNoDelay(true); + let open = false; + const pending = []; + + const timer = setTimeout(() => { + if (!open) tcp.destroy(new Error('timeout')); + }, 5000); + + tcp.on('connect', () => { + open = true; + clearTimeout(timer); + for (const chunk of pending) tcp.write(chunk); + pending.length = 0; + }); + tcp.on('data', (chunk) => { + if (ws.readyState !== ws.OPEN) return; + ws.send(chunk, { binary: true }); + // Slow browser, fast console: stop reading until the socket drains. + if (ws.bufferedAmount > 8 * 1024 * 1024) { + tcp.pause(); + const resume = () => { + if (ws.readyState !== ws.OPEN) return; + if (ws.bufferedAmount < 1024 * 1024) tcp.resume(); + else setTimeout(resume, 20); + }; + setTimeout(resume, 20); + } + }); + tcp.on('error', (err) => { + clearTimeout(timer); + const reason = !open + ? err.code === 'ECONNREFUSED' + ? 'The console refused the connection. Is the ps5debug payload loaded?' + : 'Could not reach the console. Check that it is on and on the same network.' + : 'Lost the connection to the console'; + if (ws.readyState === ws.OPEN || ws.readyState === ws.CONNECTING) ws.close(4001, reason); + }); + tcp.on('close', () => { + clearTimeout(timer); + if (ws.readyState === ws.OPEN) ws.close(4002, 'The console closed the connection'); + }); + + ws.on('message', (data, isBinary) => { + if (!isBinary) return; + if (open) tcp.write(data); + else pending.push(data); + }); + ws.on('close', () => tcp.destroy()); + ws.on('error', () => tcp.destroy()); + } + + const ready = eventsReady.then( + () => + new Promise((resolve, reject) => { + server.once('error', reject); + server.listen(opts.port ?? 8744, opts.host ?? '0.0.0.0', () => resolve(server.address().port)); + }), + ); + + return { + ready, + server, + close() { + for (const c of wss.clients) c.terminate(); + server.closeAllConnections?.(); + if (eventServer.listening) eventServer.close(); + return new Promise((resolve) => server.close(() => resolve())); + }, + }; +} + +// ---- command line ------------------------------------------------------------ + +function lanAddresses() { + const out = []; + for (const list of Object.values(os.networkInterfaces())) { + for (const i of list ?? []) if (i.family === 'IPv4' && !i.internal) out.push(i.address); + } + return out; +} + +function openBrowser(url) { + const cmd = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'cmd' : 'xdg-open'; + const args = process.platform === 'win32' ? ['/c', 'start', '', url] : [url]; + try { + spawn(cmd, args, { stdio: 'ignore', detached: true }).on('error', () => {}).unref(); + } catch { + // the URL is printed either way + } +} + +if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) { + const args = process.argv.slice(2); + const flag = (name) => args.includes(name); + const portArg = args.indexOf('--port'); + const port = portArg >= 0 ? Number(args[portArg + 1]) : Number(process.env.PORT ?? 8744); + + let demo = null; + // In demo mode nothing real will connect back, so use an unprivileged port + // that works on every system. + const DEMO_EVENT_PORT = 17755; + if (flag('--demo')) { + const { startMock, MOCK_TCP_PORT, MOCK_UDP_PORT } = await import('../mock/mock-ps5.mjs'); + // A real console takes a while to scan; the pause makes the demo show progress too. + const mock = startMock({ scanDelayMs: 250, eventPort: DEMO_EVENT_PORT }); + await mock.ready; + demo = { host: '127.0.0.1', port: MOCK_TCP_PORT, udpPort: MOCK_UDP_PORT, label: 'Demo console' }; + } + + const bridge = startBridge({ port, demo, eventPort: demo ? DEMO_EVENT_PORT : EVENT_PORT }); + bridge.ready + .then((actual) => { + const local = `http://localhost:${actual}`; + console.log(`\n CheatSpecter ${VERSION}${demo ? ' (demo console running)' : ''}\n`); + console.log(` On this computer: ${local}`); + for (const ip of lanAddresses()) console.log(` Phone or tablet: http://${ip}:${actual}`); + console.log('\n Leave this window open while you use it. Close it to stop.\n'); + if (flag('--open')) openBrowser(local); + }) + .catch((err) => { + if (err.code === 'EADDRINUSE') { + console.error(`\n Port ${port} is already in use. CheatSpecter may already be running: http://localhost:${port}\n`); + if (flag('--open')) openBrowser(`http://localhost:${port}`); + } else { + console.error(err); + } + process.exit(1); + }); +} diff --git a/cheats/PPSA99999_01.000.000.json b/cheats/PPSA99999_01.000.000.json new file mode 100644 index 0000000..e260391 --- /dev/null +++ b/cheats/PPSA99999_01.000.000.json @@ -0,0 +1,41 @@ +{ + "name": "Specter Test Game", + "id": "PPSA99999", + "version": "01.000.000", + "process": "eboot.bin", + "mods": [ + { + "name": "Infinite Health", + "description": "Health stops draining.", + "type": "checkbox", + "memory": [ + { "offset": "1000", "on": "909090909090", "off": "898190030000" } + ] + }, + { + "name": "Infinite Ammo", + "description": "Shots no longer use ammo.", + "type": "checkbox", + "memory": [ + { "offset": "2040", "on": "909090", "off": "FF4B28" } + ] + }, + { + "name": "Free Purchases", + "description": "Gold is not spent.", + "type": "checkbox", + "memory": [ + { "offset": "30A0", "on": "90909090", "off": "F30F5CC1" } + ] + }, + { + "name": "Wrong Build Example", + "description": "Deliberately does not match the demo game, to show what a version mismatch looks like.", + "type": "checkbox", + "memory": [ + { "offset": "5000", "on": "9090", "off": "74AB" } + ] + } + ], + "credits": ["CheatSpecter demo"] +} diff --git a/components.json b/components.json new file mode 100644 index 0000000..9c3d479 --- /dev/null +++ b/components.json @@ -0,0 +1,22 @@ +{ + "$schema": "https://ui.shadcn.com/schema.json", + "style": "new-york", + "rsc": false, + "tsx": true, + "tailwind": { + "config": "", + "css": "src/styles.css", + "baseColor": "neutral", + "cssVariables": true, + "prefix": "" + }, + "aliases": { + "components": "@/components", + "utils": "@/lib/utils", + "ui": "@/components/ui", + "lib": "@/lib", + "hooks": "@/hooks" + }, + "iconLibrary": "lucide", + "registries": { "@kibo-ui": "https://www.kibo-ui.com/r/{name}.json" } +} diff --git a/index.html b/index.html new file mode 100644 index 0000000..1197118 --- /dev/null +++ b/index.html @@ -0,0 +1,16 @@ +<!doctype html> +<html lang="en" class="dark"> + <head> + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" /> + <meta name="theme-color" content="#070707" /> + <meta name="color-scheme" content="dark" /> + <title>CheatSpecter + + + + +
+ + + diff --git a/mcp/server.ts b/mcp/server.ts new file mode 100644 index 0000000..fcb4580 --- /dev/null +++ b/mcp/server.ts @@ -0,0 +1,792 @@ +// CheatSpecter as an MCP server. +// +// Runs on a computer, talks to the CheatSpecter payload on a PS5 over the +// local network, and offers the workbench as tools: see what is running, +// read and write memory, search for values, find what code touches a value, +// disassemble, and keep the user's cheat file up to date. +// +// It is the same library the web app uses, so anything found here ends up in +// the same .cspecter file the app loads. +// +// The protocol (JSON-RPC over stdin/stdout, one message per line) is small +// enough to speak directly, which keeps this free of dependencies. + +import { createRequire } from 'node:module'; +import readline from 'node:readline'; + +import { bytesToHex, hexToBytes } from '../src/lib/bytes.ts'; +import { parseParamJson, parseParamSfo, formatSize } from '../src/lib/library.ts'; +import { createGameContext, findPattern, resolveLocation } from '../src/lib/locations.ts'; +import type { GameContext } from '../src/lib/locations.ts'; +import type { MapEntry } from '../src/lib/ps5debug.ts'; +import { PROT } from '../src/lib/ps5debug.ts'; +import { AutoScan, COMPARE_KINDS, ScanSession, VALUE_KINDS, compareKind, decodeValue, encodeValue, scannableRegions, valueKind } from '../src/lib/scanner.ts'; +import type { Scan, ScanRegion } from '../src/lib/scanner.ts'; +import { Session, formatFirmware } from '../src/lib/session.ts'; +import type { Game } from '../src/lib/session.ts'; +import { TableRunner, describeEntry, emptyTable, isAction, newId, parseOwnTable, saveFileText } from '../src/lib/table.ts'; +import type { Entry, OwnTable } from '../src/lib/table.ts'; +import { fileVersion, pickVersion, tableFileName } from '../src/lib/tablestore.ts'; +import { Tracer } from '../src/lib/tracer.ts'; +import { asAsync, createX86, signatureFromCode } from '../src/lib/x86.ts'; + +declare const __VERSION__: string; +const VERSION = typeof __VERSION__ === 'string' ? __VERSION__ : 'dev'; +const PAYLOAD_PORT = Number(process.env.CHEATSPECTER_PORT ?? 8744); + +const log = (...args: unknown[]) => process.stderr.write(`[cheatspecter] ${args.join(' ')}\n`); + +// The app's transport uses the browser's WebSocket. Newer Node versions have +// one built in; older ones get the same thing from the `ws` package. +if (typeof (globalThis as { WebSocket?: unknown }).WebSocket !== 'function') { + const ws = (await import('ws' as string)) as { WebSocket: unknown }; + (globalThis as { WebSocket?: unknown }).WebSocket = ws.WebSocket; +} + +const require = createRequire(import.meta.url); +const x86 = createX86(require('iced-x86')); + +// ---- the console --------------------------------------------------------------- + +class ToolError extends Error {} + +let host = (process.env.CHEATSPECTER_HOST ?? '').trim(); +let session: Session | null = null; + +interface GameState { + game: Game; + name: string; + ctx: GameContext; + runner: TableRunner; + scan: Scan | null; + table: OwnTable | null; +} +let state: GameState | null = null; + +function base(): string { + if (!host) { + throw new ToolError( + 'No PS5 address is set. Call console_status with "host" set to the console\'s IP address (it is in the notification the CheatSpecter payload shows when it starts, e.g. 192.168.1.50).', + ); + } + return `http://${host}:${PAYLOAD_PORT}`; +} + +async function http(path: string, init?: RequestInit): Promise { + try { + return await fetch(base() + path, { ...init, signal: AbortSignal.timeout(30_000) }); + } catch (e) { + if (e instanceof ToolError) throw e; + throw new ToolError(`The CheatSpecter payload at ${host}:${PAYLOAD_PORT} did not answer. Is the PS5 on, and is cheatspecter.elf loaded?`); + } +} + +async function connect(): Promise { + if (session) return session; + const url = `${base().replace(/^http/, 'ws')}/ws`; + try { + const s = await Session.connect(null, url); + s.onLost = (reason) => { + log('connection lost:', reason); + if (session === s) { + session = null; + state = null; + } + }; + session = s; + return s; + } catch (e) { + throw new ToolError( + `Could not reach the debugger through the payload at ${host}:${PAYLOAD_PORT} (${e instanceof Error ? e.message : String(e)}). Both ps5debug-NG and cheatspecter.elf need to be loaded on the PS5.`, + ); + } +} + +async function titleName(titleId: string): Promise { + try { + const json = await http(`/api/appmeta/${titleId}/param.json`); + if (json.ok) return parseParamJson(await json.text())?.name ?? ''; + const sfo = await http(`/api/appmeta/${titleId}/param.sfo`); + if (sfo.ok) return parseParamSfo(new Uint8Array(await sfo.arrayBuffer()))?.name ?? ''; + } catch { + // The name is a nicety. + } + return ''; +} + +/** The running game, with everything tied to it. Rebuilt when another game (or another launch) is found. */ +async function current(): Promise { + const s = await connect(); + const game = await s.currentGame(); + if (!game) { + state = null; + throw new ToolError('No game is running on the PS5. Start one (launch_game can do it) and try again.'); + } + if (state && state.game.pid === game.pid && state.game.titleId === game.titleId) return state; + const ctx = createGameContext({ + pid: game.pid, + dbg: () => session!.main, + scanDbg: () => session!.scan, + x86: asAsync(x86), + // An assembler error ends the connection it was sent on, so each one gets its own. + assemble: async (at, text) => { + const dbg = await session!.openDebugger(); + try { + return await dbg.assemble(at, text); + } finally { + if (!dbg.closed) dbg.close(); + } + }, + }); + state = { game, name: await titleName(game.titleId), ctx, runner: new TableRunner(ctx), scan: null, table: null }; + return state; +} + +// ---- addresses and values -------------------------------------------------------- + +const hexAddr = (a: bigint) => '0x' + a.toString(16).toUpperCase(); + +interface Module { + name: string; + start: bigint; + end: bigint; +} + +function modules(maps: MapEntry[]): Module[] { + const byName = new Map(); + for (const m of maps) { + if (!m.name || m.name === '(aux)') continue; + const have = byName.get(m.name); + if (!have) byName.set(m.name, { name: m.name, start: m.start, end: m.end }); + else { + if (m.start < have.start) have.start = m.start; + if (m.end > have.end) have.end = m.end; + } + } + return [...byName.values()].sort((a, b) => (a.start < b.start ? -1 : 1)); +} + +/** "0x1234", "1234", or "module+0x1234" ("game" is the game's own executable). */ +async function address(st: GameState, text: unknown): Promise { + if (typeof text !== 'string' || !text.trim()) throw new ToolError('An address is needed, e.g. "0x880012340" or "game+0x1A2B".'); + const t = text.trim(); + const plus = t.lastIndexOf('+'); + const num = (h: string) => { + const clean = h.trim().replace(/^0x/i, ''); + if (!/^[0-9a-f]+$/i.test(clean)) throw new ToolError(`"${h}" is not a hex number`); + return BigInt('0x' + clean); + }; + if (plus < 0) return num(t); + const name = t.slice(0, plus).trim().toLowerCase(); + const offset = num(t.slice(plus + 1)); + if (name === 'game' || name === 'eboot' || name === 'eboot.bin') return (await resolveLocation(st.ctx, { kind: 'module', offset: '0' })) + offset; + const all = modules(await st.ctx.maps()); + const found = all.find((m) => m.name.toLowerCase() === name) ?? all.find((m) => m.name.toLowerCase().startsWith(name)); + if (!found) throw new ToolError(`No module called "${name}" is loaded. list_modules shows the names.`); + return found.start + offset; +} + +/** An address the way a reader wants it: raw, plus which module it is in. */ +async function where(st: GameState, a: bigint): Promise { + const m = modules(await st.ctx.maps()).find((x) => a >= x.start && a < x.end); + return m ? `${hexAddr(a)} (${m.name}+0x${(a - m.start).toString(16).toUpperCase()})` : hexAddr(a); +} + +function int(value: unknown, fallback: number, min: number, max: number): number { + const n = typeof value === 'number' ? value : typeof value === 'string' && value.trim() !== '' ? Number(value) : fallback; + if (!Number.isFinite(n)) return fallback; + return Math.max(min, Math.min(max, Math.floor(n))); +} + +const str = (v: unknown): string => (typeof v === 'string' ? v : v === undefined || v === null ? '' : String(v)); + +// ---- long jobs ----------------------------------------------------------------- +// +// A search over a big game takes longer than a tool call is allowed to. Long +// work runs in the background; the call waits a while and, if it is not done, +// says so, and scan_status picks the result up later. + +interface Job { + what: string; + progress: string; + done: boolean; + result?: string; + error?: string; + promise: Promise; +} +let job: Job | null = null; +const WAIT_MS = 40_000; + +async function runJob(what: string, work: (progress: (text: string) => void) => Promise): Promise { + if (job && !job.done) throw new ToolError(`Still busy with: ${job.what} (${job.progress}). Call scan_status to wait for it.`); + const mine: Job = { what, progress: 'starting', done: false, promise: Promise.resolve() }; + mine.promise = work((text) => (mine.progress = text)).then( + (result) => { + mine.result = result; + mine.done = true; + }, + (e) => { + mine.error = e instanceof Error ? e.message : String(e); + mine.done = true; + }, + ); + job = mine; + return waitJob(); +} + +async function waitJob(): Promise { + const mine = job; + if (!mine) return 'Nothing is running.'; + await Promise.race([mine.promise, new Promise((r) => setTimeout(r, WAIT_MS))]); + if (!mine.done) return `Still running: ${mine.what} (${mine.progress}). Call scan_status to get the result.`; + if (job === mine) job = null; + if (mine.error !== undefined) throw new ToolError(mine.error); + return mine.result ?? ''; +} + +// ---- cheat files --------------------------------------------------------------- + +async function loadTable(st: GameState, refresh = false): Promise { + if (st.table && !refresh) return st.table; + const previous = st.table; + const list = await http(`/api/tables/${st.game.titleId}`); + const versions = list.ok ? (((await list.json()) as { versions?: string[] }).versions ?? []) : []; + const version = pickVersion(versions, st.game.version); + let table = emptyTable(st.game.titleId, st.game.version, st.name); + if (version) { + const res = await http(`/api/tables/${st.game.titleId}/${version}`); + if (res.ok) table = parseOwnTable(await res.text(), { own: true }); + } + table = { ...table, titleId: st.game.titleId, version: st.game.version, name: table.name || st.name }; + // The file does not record identities, so a cheat read again is matched to the one + // already known by name. That keeps track of which ones this session switched on. + for (const entry of table.entries) { + const known = previous?.entries.find((e) => e.name === entry.name); + if (known) entry.id = known.id; + } + st.table = table; + await st.runner.adopt(table.entries).catch(() => false); + return table; +} + +async function saveTable(st: GameState, table: OwnTable): Promise { + const res = await http(`/api/tables/${table.titleId}/${fileVersion(table.version)}`, { + method: 'PUT', + headers: { 'content-type': 'application/json' }, + body: saveFileText(table), + }); + if (!res.ok) throw new ToolError(`The console could not save the cheat file (HTTP ${res.status}).`); + st.table = table; +} + +function findEntry(table: OwnTable, name: unknown): Entry { + const wanted = str(name).trim().toLowerCase(); + const entry = table.entries.find((e) => e.name.toLowerCase() === wanted) ?? table.entries.find((e) => e.id === str(name)); + if (!entry) throw new ToolError(`There is no cheat called "${str(name)}". list_cheats shows what exists.`); + return entry; +} + +const CHEAT_FORMAT = `A cheat is a JSON object with "name", "type" and, optionally, "note". +Locations ("at") are one of: + {"kind":"signature","pattern":"45 8B 65 48 ?? 8D","offset":8} a byte pattern in the code plus a distance past it; survives restarts and most updates. Do not include the bytes the patch changes in the pattern. + {"kind":"module","offset":"0x3E5AB37"} an offset into the game's own executable (not other modules) + {"kind":"pointer","base":"0x2F4A10","offsets":["0x8","0x340"]} a pointer path starting in the game's executable + {"kind":"address","address":"0x880012340"} a raw address, valid only until the game restarts +Types: + patch {"at":…, "on":"909090", "off":"FF4B28", "more":[{"at":…,"on":"…","off":"…"}]} bytes to write and the originals; "more" adds further places to the same switch + value {"at":…, "valueType":"u32", "value":"9999", "freeze":true} set a value, or hold it there + inject {"at":…, "code":"mov dword ptr [rbx+0x390], 100", "placement":"before"} run assembly at a point in the code ("before", "after" or "replace" the instructions there) + call {"fn":…, "args":["0x1","2"]} call a function in the game + script {"code":"await cs.write(await cs.pointer('game+10100', 0x340), 'u32', 100);"} a small program`; + +// ---- tools --------------------------------------------------------------------- + +type Args = Record; +interface Tool { + name: string; + description: string; + inputSchema: { type: 'object'; properties: Record; required?: string[] }; + run: (args: Args) => Promise; +} + +const S = (description: string, extra: Record = {}) => ({ type: 'string', description, ...extra }); +const N = (description: string) => ({ type: 'number', description }); +const B = (description: string) => ({ type: 'boolean', description }); +const ADDR = 'Hex address, or "module+offset" such as "game+0x1A2B" or "Il2CppUserAssemblies.prx+0x76769D".'; + +function describeHits(st: GameState, scan: Scan, hits: { address: bigint; value: Uint8Array; kind?: { id: string } }[]): string { + if (hits.length === 0) return ''; + return hits + .map((h) => { + const kind = h.kind ? valueKind(h.kind.id) : scan.kind; + return `${hexAddr(h.address)} ${decodeValue(kind, h.value)}${scan instanceof AutoScan ? ` (${kind.id})` : ''}`; + }) + .join('\n'); +} + +async function scanSummary(st: GameState, limit = 20): Promise { + const scan = st.scan; + if (!scan) return 'No search is open.'; + const n = scan.matches; + const dropped = scan instanceof AutoScan && scan.dropped.length ? `\nLeft out: ${scan.dropped.map((d) => `${d.kind.id} (${d.reason})`).join(', ')}` : ''; + if (n === 0) return `0 matches after pass ${scan.passes}. The search is over; start a new one.${dropped}`; + const shown = n <= 500 ? describeHits(st, scan, await scan.hits(limit)) : ''; + return `${n.toLocaleString('en-US')} matches after pass ${scan.passes}.${dropped}${shown ? `\nFirst ${Math.min(n, limit)} (address, value at the last pass):\n${shown}` : n > 500 ? '\nToo many to list; change the value in the game and narrow with scan_next.' : ''}`; +} + +const tools: Tool[] = [ + { + name: 'console_status', + description: + 'Connects to the PS5 and reports what is running: debugger, firmware, the game on screen (name, title ID, version, process ID). Call this first. Pass "host" once to set or change the console\'s IP address.', + inputSchema: { type: 'object', properties: { host: S("The PS5's IP address, e.g. 192.168.1.50. Only needed the first time or when it changes.") } }, + run: async (a) => { + const wanted = str(a.host).trim(); + if (wanted && wanted !== host) { + if (!/^[a-z0-9.-]+$/i.test(wanted)) throw new ToolError('That does not look like an address.'); + session?.close(); + session = null; + state = null; + host = wanted; + } + const info = await http('/api/info'); + const payload = info.ok ? ((await info.json()) as { version?: string }) : {}; + const s = await connect(); + const lines = [ + `PS5 at ${host}: firmware ${s.firmware ? formatFirmware(s.firmware) : 'unknown'}, ${s.branding.brand || 'debugger (no name reported)'}`, + `CheatSpecter payload ${payload.version ?? 'unknown'}, MCP server ${VERSION}`, + ]; + const game = await s.currentGame(); + if (!game) lines.push('No game is running.'); + else { + const st = await current(); + const table = await loadTable(st).catch(() => null); + lines.push(`Running: ${st.name || game.titleId} (${game.titleId}, version ${game.version || 'unknown'}, pid ${game.pid})`); + lines.push(table && table.entries.length ? `Cheat file ${tableFileName(game.titleId, game.version)}: ${table.entries.length} cheats (list_cheats)` : 'No cheats saved for this game yet.'); + } + return lines.join('\n'); + }, + }, + { + name: 'list_games', + description: 'Lists the games installed on the PS5 with name, platform (PS5 or PS4), size and title ID.', + inputSchema: { type: 'object', properties: {} }, + run: async () => { + const res = await http('/api/library'); + if (!res.ok) throw new ToolError(`The payload could not list the library (HTTP ${res.status}).`); + const { titles } = (await res.json()) as { titles: { id: string; meta: string; size: number; partial?: boolean; path: string }[] }; + const rows = []; + for (const t of titles) { + const size = formatSize(t.size); + rows.push(`${t.id} ${t.meta === 'sfo' ? 'PS4' : 'PS5'} ${(size ? (t.partial ? 'over ' : '') + size : 'size unknown').padStart(12)} ${(await titleName(t.id)) || '(no name)'}`); + } + return rows.length ? rows.join('\n') : 'The console did not report any installed games.'; + }, + }, + { + name: 'launch_game', + description: 'Starts a game on the PS5 by title ID. This closes whatever game is running, losing anything it has not saved, so confirm with the user first if a game is running.', + inputSchema: { type: 'object', properties: { title_id: S('e.g. PPSA07391') }, required: ['title_id'] }, + run: async (a) => { + const id = str(a.title_id).trim().toUpperCase(); + if (!/^[A-Z]{4}\d{5}$/.test(id)) throw new ToolError('A title ID looks like PPSA07391.'); + const res = await http(`/api/launch/${id}`, { method: 'POST' }); + const doc = (await res.json().catch(() => ({}))) as { ok?: boolean; error?: string; code?: string }; + if (!res.ok || !doc.ok) throw new ToolError(`${doc.error ?? `The console did not start it (HTTP ${res.status})`}${doc.code ? ` (${doc.code})` : ''}`); + state = null; + return `Asked the PS5 to start ${id}. It takes a few seconds; console_status shows when it is running.`; + }, + }, + { + name: 'list_modules', + description: "Lists the running game's loaded modules (its executable and libraries) with their address ranges, and how much writable memory there is.", + inputSchema: { type: 'object', properties: {} }, + run: async () => { + const st = await current(); + const maps = await st.ctx.maps(true); + const writable = scannableRegions(maps).reduce((n, r) => n + r.length, 0); + // Code modules only: the map also names hundreds of stacks and shared-memory blocks nobody patches. + const code = modules(maps).filter((m) => /^executable$|\.(s?prx|elf|self|bin)$/i.test(m.name)); + const rows = code.map((m) => `${hexAddr(m.start).padEnd(14)} ${formatSize(Number(m.end - m.start)).padStart(9)} ${m.name}`); + return `${rows.join('\n')}\n\nWritable memory a search covers: ${formatSize(writable)}`; + }, + }, + { + name: 'read_memory', + description: 'Reads memory from the running game. Returns a hex dump, or decoded values when "as" is a type.', + inputSchema: { + type: 'object', + properties: { + address: S(ADDR), + length: N('Bytes to read (default 64, at most 4096). With "as", the number of values instead.'), + as: S('Decode as this type instead of a hex dump.', { enum: VALUE_KINDS.map((k) => k.id) }), + }, + required: ['address'], + }, + run: async (a) => { + const st = await current(); + const at = await address(st, a.address); + if (a.as) { + const kind = valueKind(str(a.as)); + const count = int(a.length, 1, 1, 512); + const bytes = await st.ctx.dbg().read(st.game.pid, at, count * kind.size); + const rows = []; + for (let i = 0; i < count; i++) rows.push(`${hexAddr(at + BigInt(i * kind.size))} ${decodeValue(kind, bytes.subarray(i * kind.size, (i + 1) * kind.size))}`); + return rows.join('\n'); + } + const bytes = await st.ctx.dbg().read(st.game.pid, at, int(a.length, 64, 1, 4096)); + const rows = []; + for (let i = 0; i < bytes.length; i += 16) { + const line = bytes.subarray(i, i + 16); + const text = [...line].map((b) => (b >= 0x20 && b < 0x7f ? String.fromCharCode(b) : '.')).join(''); + rows.push(`${hexAddr(at + BigInt(i)).padEnd(14)} ${bytesToHex(line, ' ').padEnd(47)} ${text}`); + } + return rows.join('\n'); + }, + }, + { + name: 'write_memory', + description: 'Writes to the running game\'s memory: either raw bytes ("hex") or a typed value ("value" with "type"). Code can be patched this way too. Read the bytes first so they can be put back.', + inputSchema: { + type: 'object', + properties: { + address: S(ADDR), + hex: S('Bytes to write, e.g. "90 90 90".'), + value: S('A value to write, e.g. "9999" or "0.5".'), + type: S('The type of "value".', { enum: VALUE_KINDS.map((k) => k.id) }), + }, + required: ['address'], + }, + run: async (a) => { + const st = await current(); + const at = await address(st, a.address); + const bytes = a.hex ? hexToBytes(str(a.hex)) : a.value !== undefined ? encodeValue(valueKind(str(a.type) || 'u32'), str(a.value)) : null; + if (!bytes || bytes.length === 0) throw new ToolError('Give either "hex" or "value" (with "type").'); + const before = await st.ctx.dbg().read(st.game.pid, at, bytes.length); + await st.ctx.dbg().write(st.game.pid, at, bytes); + const after = await st.ctx.dbg().read(st.game.pid, at, bytes.length); + return `${hexAddr(at)}: was ${bytesToHex(before, ' ')}, now ${bytesToHex(after, ' ')}${bytesToHex(after) === bytesToHex(bytes) ? '' : ' (the write did not stick)'}`; + }, + }, + { + name: 'scan_start', + description: + 'Starts a search of the game\'s writable memory for a value. Follow with scan_next after the value changes in the game, until few matches remain. Type "auto" tries 4 bytes, float and double at once. A big game takes over a minute; if the answer is "still running", call scan_status.', + inputSchema: { + type: 'object', + properties: { + type: S('Value type.', { enum: ['auto', ...VALUE_KINDS.map((k) => k.id)] }), + compare: S('How to compare (default "exact").', { enum: COMPARE_KINDS.filter((c) => c.first && c.id !== 'unknown').map((c) => c.id) }), + value: S('The value, e.g. "1137". For "between", the lower bound.'), + value2: S('Upper bound for "between".'), + min: S('Only search addresses at or above this (hex).'), + max: S('Only search addresses below this (hex).'), + }, + required: ['type', 'value'], + }, + run: async (a) => { + const st = await current(); + const cmp = compareKind(str(a.compare) || 'exact'); + if (!cmp.first || cmp.id === 'unknown') throw new ToolError('A first search needs a value: exact, bigger, smaller or between.'); + let regions: ScanRegion[] = scannableRegions(await st.ctx.maps(true)); + if (a.min) regions = regions.filter((r) => r.start >= BigInt(str(a.min).startsWith('0x') ? str(a.min) : '0x' + str(a.min))); + if (a.max) regions = regions.filter((r) => r.start < BigInt(str(a.max).startsWith('0x') ? str(a.max) : '0x' + str(a.max))); + if (regions.length === 0) throw new ToolError('There is no writable memory in that range.'); + const total = regions.reduce((n, r) => n + r.length, 0); + await st.scan?.end().catch(() => undefined); + st.scan = null; + let scan: Scan; + let encoded: Uint8Array = new Uint8Array(0); + if (str(a.type) === 'auto') { + const all = new AutoScan(() => session!.scan, st.game.pid); + all.input(str(a.value), str(a.value2)); + scan = all; + } else { + const kind = valueKind(str(a.type)); + const one = encodeValue(kind, str(a.value)); + encoded = cmp.inputs === 2 ? Uint8Array.from([...one, ...encodeValue(kind, str(a.value2))]) : one; + scan = new ScanSession(() => session!.scan, st.game.pid, kind); + } + return runJob(`searching ${formatSize(total)}`, async (progress) => { + await scan.first(regions, cmp, encoded, (p) => progress(`${Math.round(p.fraction * 100)}%, ${p.matches.toLocaleString('en-US')} matches so far${p.detail ? ' ' + p.detail : ''}`)); + st.scan = scan; + return scanSummary(st); + }); + }, + }, + { + name: 'scan_next', + description: + 'Narrows the open search. Use "exact" with the new value, or increased / decreased / changed / unchanged when only the direction is known. Running "unchanged" while nothing happens in the game clears out values that move by themselves.', + inputSchema: { + type: 'object', + properties: { + compare: S('How the value compares now.', { enum: COMPARE_KINDS.filter((c) => c.id !== 'unknown').map((c) => c.id) }), + value: S('The value now, for exact / bigger / smaller / between.'), + value2: S('Upper bound for "between".'), + }, + required: ['compare'], + }, + run: async (a) => { + const st = await current(); + const scan = st.scan; + if (!scan) throw new ToolError('No search is open. Start one with scan_start.'); + const cmp = compareKind(str(a.compare)); + let encoded: Uint8Array = new Uint8Array(0); + if (scan instanceof AutoScan) scan.input(str(a.value), str(a.value2)); + else if (cmp.inputs > 0) { + const one = encodeValue(scan.kind, str(a.value)); + encoded = cmp.inputs === 2 ? Uint8Array.from([...one, ...encodeValue(scan.kind, str(a.value2))]) : one; + } else encoded = new Uint8Array(scan.kind.size); + return runJob(`checking ${scan.matches.toLocaleString('en-US')} candidates`, async (progress) => { + await scan.next(cmp, encoded, (p) => progress(`${Math.round(p.fraction * 100)}%`)); + return scanSummary(st); + }); + }, + }, + { + name: 'scan_status', + description: 'Waits for a search that was still running and returns its result, or shows the open search\'s matches with their current values.', + inputSchema: { type: 'object', properties: { limit: N('How many matches to list (default 20, at most 200).') } }, + run: async (a) => { + if (job) return waitJob(); + const st = await current(); + const scan = st.scan; + if (!scan) return 'No search is open.'; + const limit = int(a.limit, 20, 1, 200); + const hits = await scan.hits(limit); + const rows = []; + for (const h of hits) { + const kind = h.kind ?? scan.kind; + const now = await st.ctx.dbg().read(st.game.pid, h.address, kind.size); + rows.push(`${hexAddr(h.address)} was ${decodeValue(kind, h.value)} now ${decodeValue(kind, now)}${scan instanceof AutoScan ? ` (${kind.id})` : ''}`); + } + return `${scan.matches.toLocaleString('en-US')} matches after pass ${scan.passes}.\n${rows.join('\n')}`; + }, + }, + { + name: 'watch', + description: + 'Finds the code that touches a value: sets a hardware watchpoint for a few seconds and reports each instruction that wrote to (or read) the address, with registers. The user has to make the value change in the game while this runs. The game hitches briefly on each hit.', + inputSchema: { + type: 'object', + properties: { + address: S(ADDR), + size: N('Bytes to watch: 1, 2, 4 or 8 (default 4).'), + kind: S('"write" (default) or "readwrite".', { enum: ['write', 'readwrite'] }), + seconds: N('How long to watch (default 20, at most 35).'), + max_hits: N('Stop after this many hits (default 40). Keep it low for values that change constantly.'), + }, + required: ['address'], + }, + run: async (a) => { + const st = await current(); + const at = await address(st, a.address); + const size = int(a.size, 4, 1, 8); + if (![1, 2, 4, 8].includes(size)) throw new ToolError('Size must be 1, 2, 4 or 8.'); + const seconds = int(a.seconds, 20, 1, 35); + const tracer = new Tracer(st.ctx, { openDebugger: () => session!.openDebugger(), openEvents: () => session!.openEvents() }); + tracer.maxHits = int(a.max_hits, 40, 1, 400); + let ended: string | undefined; + let finished = false; + await tracer.start(at, size as 1 | 2 | 4 | 8, str(a.kind) === 'readwrite' ? 'readwrite' : 'write', (_hits, why) => { + if (why !== undefined || !tracer.running) { + ended = why; + finished = true; + } + }); + const until = Date.now() + seconds * 1000; + while (!finished && Date.now() < until && tracer.total < tracer.maxHits) await new Promise((r) => setTimeout(r, 150)); + await tracer.stop().catch(() => undefined); + const hits = tracer.list(); + if (hits.length === 0) return `Nothing touched ${hexAddr(at)} in ${seconds} seconds.${ended ? ' ' + ended : ''} The value has to change in the game while this runs.`; + const out = [`${tracer.total} hits from ${hits.length} place${hits.length === 1 ? '' : 's'} in the code:`]; + for (const h of hits) { + const insn = h.insn; + out.push(''); + out.push(`${insn ? await where(st, insn.address) : `before ${await where(st, h.rip)}`} x${h.count}`); + if (insn) out.push(` ${bytesToHex(insn.bytes, ' ')} ${insn.text}`); + out.push(` ${Object.entries(h.regs).filter(([k]) => !['rflags', 'cs', 'ss', 'err', 'trapno', 'fs', 'gs', 'es', 'ds'].includes(k)).map(([k, v]) => `${k}=${(v as bigint).toString(16)}`).join(' ')}`); + } + if (ended) out.push('', ended); + return out.join('\n'); + }, + }, + { + name: 'disassemble', + description: 'Disassembles code in the running game (x86-64, Intel syntax). Also suggests a byte pattern that locates the first instruction, for use in a cheat.', + inputSchema: { type: 'object', properties: { address: S(ADDR), count: N('Instructions to show (default 24, at most 200).') }, required: ['address'] }, + run: async (a) => { + const st = await current(); + const at = await address(st, a.address); + const count = int(a.count, 24, 1, 200); + const bytes = await st.ctx.dbg().read(st.game.pid, at, Math.min(4096, count * 15)); + const insns = x86.disassemble(bytes, at, count); + const rows = insns.map((i) => `${hexAddr(i.address).padEnd(14)} ${bytesToHex(i.bytes, ' ').padEnd(32)} ${i.text}`); + let sig = ''; + try { + sig = signatureFromCode(insns, 12).text; + } catch { + // No pattern to suggest for this stretch. + } + return `${await where(st, at)}\n${rows.join('\n')}${sig ? `\n\nPattern for the start of this code: ${sig} (check it with find_pattern)` : ''}`; + }, + }, + { + name: 'find_pattern', + description: 'Searches the game\'s code for a byte pattern ("89 81 ?? ?? 00 00", ?? matches anything) and says where it is and whether it is unique. A cheat should only use a unique pattern.', + inputSchema: { type: 'object', properties: { pattern: S('Bytes in hex with ?? wildcards.') }, required: ['pattern'] }, + run: async (a) => { + const st = await current(); + const match = await findPattern(st.ctx, str(a.pattern)); + if (!match) return 'Not found in the game\'s code.'; + return `${await where(st, match.address)} ${match.unique ? 'unique' : 'NOT unique (matches in more than one place; lengthen the pattern)'}`; + }, + }, + { + name: 'list_cheats', + description: "Shows the cheats saved for the running game (the .cspecter file on the PS5, the same one the CheatSpecter web app loads), and which are switched on.", + inputSchema: { type: 'object', properties: { json: B('Also include each cheat as JSON, for editing.') } }, + run: async (a) => { + const st = await current(); + const table = await loadTable(st, true); + if (table.entries.length === 0) return `No cheats saved for ${st.name || st.game.titleId} yet. add_cheat creates one.`; + const rows = table.entries.map((e) => { + const status = isAction(e) ? 'action' : st.runner.isOn(e.id) ? 'ON' : 'off'; + const { id: _id, unreviewed: _u, ...rest } = e; + return `[${status}] ${e.name}: ${describeEntry(e)}${e.note ? `\n ${e.note}` : ''}${a.json ? `\n ${JSON.stringify(rest)}` : ''}`; + }); + return `${tableFileName(table.titleId, table.version)} for ${table.name || table.titleId}:\n${rows.join('\n')}`; + }, + }, + { + name: 'add_cheat', + description: `Saves a cheat for the running game to its .cspecter file on the PS5, replacing any cheat with the same name. It then shows up as a switch in the CheatSpecter web app. Test with set_cheat afterwards.\n\n${CHEAT_FORMAT}`, + inputSchema: { type: 'object', properties: { cheat: { type: 'object', description: 'The cheat, in the format described above.' } }, required: ['cheat'] }, + run: async (a) => { + const st = await current(); + const raw = a.cheat && typeof a.cheat === 'object' ? (a.cheat as Record) : null; + if (!raw || !str(raw.name).trim()) throw new ToolError('The cheat needs at least a "name" and a "type".'); + // Through the same checks as a file the app loads. + const probe = parseOwnTable(JSON.stringify({ format: 'cheatspecter', formatVersion: 1, game: {}, cheats: [{ ...raw, reviewed: true }] }), { own: true }); + const entry = probe.entries[0]; + if (!entry) throw new ToolError(`That is not a cheat CheatSpecter understands.\n\n${CHEAT_FORMAT}`); + const table = await loadTable(st); + const old = table.entries.find((e) => e.name.toLowerCase() === entry.name.toLowerCase()); + if (old && st.runner.isOn(old.id)) await st.runner.disable(old).catch(() => undefined); + entry.id = old?.id ?? newId(); + const entries = old ? table.entries.map((e) => (e === old ? entry : e)) : [...table.entries, entry]; + await saveTable(st, { ...table, entries }); + return `Saved "${entry.name}" (${describeEntry(entry)}) to ${tableFileName(table.titleId, table.version)}. ${old ? 'It replaced the cheat of the same name. ' : ''}It is off; set_cheat switches it on.`; + }, + }, + { + name: 'remove_cheat', + description: 'Deletes a cheat from the running game\'s file, switching it off first.', + inputSchema: { type: 'object', properties: { name: S('The cheat\'s name.') }, required: ['name'] }, + run: async (a) => { + const st = await current(); + const table = await loadTable(st); + const entry = findEntry(table, a.name); + if (st.runner.isOn(entry.id)) await st.runner.disable(entry); + await saveTable(st, { ...table, entries: table.entries.filter((e) => e !== entry) }); + return `Removed "${entry.name}".`; + }, + }, + { + name: 'set_cheat', + description: 'Switches a saved cheat on or off in the running game (or runs it, if it is a one-off action). A cheat that does not match the game\'s code is refused unless "force" is set.', + inputSchema: { type: 'object', properties: { name: S('The cheat\'s name.'), on: B('true to switch on or run, false to switch off.'), force: B('Apply even if the original bytes do not match.') }, required: ['name', 'on'] }, + run: async (a) => { + const st = await current(); + const table = await loadTable(st); + const entry = findEntry(table, a.name); + if (entry.type === 'script') throw new ToolError('Scripts run in the CheatSpecter web app, not here.'); + if (a.on === false || a.on === 'false') { + if (!st.runner.isOn(entry.id)) return `"${entry.name}" is already off.`; + await st.runner.disable(entry); + return `"${entry.name}" is off.`; + } + try { + await st.runner.enable(entry, { force: a.force === true }); + } catch (e) { + if (e instanceof Error && e.name === 'MismatchError') { + throw new ToolError(`"${entry.name}" does not match this version of the game (the bytes it expects are not there), so nothing was changed.`); + } + throw e; + } + const result = st.runner.result(entry.id); + return isAction(entry) ? `Ran "${entry.name}".${result ? ' ' + result : ''}` : `"${entry.name}" is on.`; + }, + }, +]; + +// ---- protocol ------------------------------------------------------------------ + +const send = (message: unknown) => process.stdout.write(JSON.stringify(message) + '\n'); + +/** Tool calls run one at a time: they share one console connection. */ +let queue: Promise = Promise.resolve(); + +async function handle(message: { id?: number | string; method?: string; params?: Record }): Promise { + const { id, method, params } = message; + const reply = (result: unknown) => id !== undefined && send({ jsonrpc: '2.0', id, result }); + const fail = (code: number, text: string) => id !== undefined && send({ jsonrpc: '2.0', id, error: { code, message: text } }); + switch (method) { + case 'initialize': + reply({ + protocolVersion: typeof params?.protocolVersion === 'string' ? params.protocolVersion : '2024-11-05', + capabilities: { tools: {} }, + serverInfo: { name: 'cheatspecter', version: VERSION }, + instructions: + 'Tools for a jailbroken PS5 running the CheatSpecter payload, for single-player games the user owns. Start with console_status. The usual way to make a cheat: scan_start for a value the user can see, have them change it in the game, scan_next until few matches remain, watch the address while they change it again to find the code, disassemble around it, try a change with write_memory, then add_cheat so it becomes a switch in the CheatSpecter app. Prefer cheats located by a unique byte pattern.', + }); + return; + case 'ping': + reply({}); + return; + case 'tools/list': + reply({ tools: tools.map(({ name, description, inputSchema }) => ({ name, description, inputSchema })) }); + return; + case 'tools/call': { + const tool = tools.find((t) => t.name === params?.name); + if (!tool) { + fail(-32602, `Unknown tool: ${String(params?.name)}`); + return; + } + const run = async () => { + try { + const text = await tool.run((params?.arguments as Args) ?? {}); + reply({ content: [{ type: 'text', text }] }); + } catch (e) { + if (!(e instanceof ToolError)) log(`${tool.name} failed:`, e instanceof Error ? (e.stack ?? e.message) : String(e)); + reply({ content: [{ type: 'text', text: e instanceof Error ? e.message : String(e) }], isError: true }); + } + }; + queue = queue.then(run, run); + return; + } + default: + // Notifications need no answer; unknown requests get the standard error. + if (id !== undefined) fail(-32601, `Method not found: ${String(method)}`); + } +} + +const lines = readline.createInterface({ input: process.stdin, crlfDelay: Infinity }); +lines.on('line', (line) => { + if (!line.trim()) return; + let message; + try { + message = JSON.parse(line); + } catch { + send({ jsonrpc: '2.0', id: null, error: { code: -32700, message: 'Parse error' } }); + return; + } + void handle(message); +}); +lines.on('close', () => { + session?.close(); + // Let anything in flight finish writing, then leave. + void queue.finally(() => process.exit(0)); +}); +log(`MCP server ${VERSION} ready${host ? `, console at ${host}` : ', no console address set yet'}`); diff --git a/mcp/tsconfig.json b/mcp/tsconfig.json new file mode 100644 index 0000000..4e2a539 --- /dev/null +++ b/mcp/tsconfig.json @@ -0,0 +1,5 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { "types": ["node"], "lib": ["ES2022", "DOM", "DOM.Iterable"] }, + "include": ["server.ts"] +} diff --git a/mock/mock-ps5.mjs b/mock/mock-ps5.mjs new file mode 100644 index 0000000..f473547 --- /dev/null +++ b/mock/mock-ps5.mjs @@ -0,0 +1,974 @@ +// A pretend PS5 running ps5debug-NG, for developing and testing without a +// console. It speaks the same wire protocol on a TCP port and simulates one +// small "game" whose memory you can scan and patch. +// +// The handlers follow the debugger's own source (scan.c, proc.c, auth.c, +// console.c in ps5debug-NG v1.3.2) closely, including the multi-status +// replies, so the client is exercised against the real framing. +// +// node mock/mock-ps5.mjs # TCP 7440, UDP discovery 10100 + +import net from 'node:net'; +import dgram from 'node:dgram'; +import { pathToFileURL } from 'node:url'; + +export const MOCK_TCP_PORT = 7440; +export const MOCK_UDP_PORT = 10100; + +const PACKET_MAGIC = 0xffaabbcc; +const ST = { SUCCESS: 0x40000000, ERROR: 0xf0000002, DATA_NULL: 0xf0000003 }; +const bitswap32 = (x) => (((x >>> 1) & 0x55555555) | ((x << 1) & 0xaaaaaaaa)) >>> 0; + +// ---- the pretend game ------------------------------------------------------- + +export const GAME = { + pid: 91, + titleId: 'PPSA99999', + contentId: 'UP9999-PPSA99999_00-SPECTERTESTGAME0', + name: 'eboot.bin', + version: '01.000.000', + imageBase: 0x4b3a8c0000n, + heapBase: 0x880000000n, + // Offsets into the image. Each holds a short instruction the game "runs". + code: { + healthDrain: { offset: 0x1000, bytes: Buffer.from('898190030000', 'hex') }, + ammoSpend: { offset: 0x2040, bytes: Buffer.from('FF4B28', 'hex') }, + goldSpend: { offset: 0x30a0, bytes: Buffer.from('F30F5CC1', 'hex') }, + scoreAdd: { offset: 0x3200, bytes: Buffer.from('8387808803000A', 'hex') }, + }, + // Functions the mock can "call": add(a, b) and setGold(amount). + funcs: { add: 0x4000, setGold: 0x4100 }, + // Offsets into the heap. The player object starts at 0x12000. + player: 0x12000, + vars: { health: 0x12340, ammo: 0x12344, unlocks: 0x12400, gold: 0x20010, score: 0x38880 }, + // Static pointers in the image's data segment (imageBase + 0x10000 + offset): + // [data + 0x100] -> player + // [[data + 0x200] + 0x8] -> player + dataBase: 0x4b3a8d0000n, + statics: { player: 0x100, world: 0x200 }, + world: 0x31000, +}; + +function createGame() { + // int3 padding with real instructions at the interesting offsets, each + // followed by a ret, so it disassembles cleanly. + const image = Buffer.alloc(0x10000, 0xcc); + for (const c of Object.values(GAME.code)) { + c.bytes.copy(image, c.offset); + image[c.offset + c.bytes.length] = 0xc3; + } + Buffer.from('488D0437C3', 'hex').copy(image, GAME.funcs.add); // lea rax,[rdi+rsi]; ret + Buffer.from('F3480F2AC7C3', 'hex').copy(image, GAME.funcs.setGold); // cvtsi2ss xmm0,rdi; ret + + const heap = Buffer.alloc(0x40000); + heap.writeUInt32LE(100, GAME.vars.health); + heap.writeUInt32LE(30, GAME.vars.ammo); + heap.writeFloatLE(2500, GAME.vars.gold); + heap.writeUInt32LE(0, GAME.vars.score); + // Decoys, so a first scan for 100 finds more than one hit. + for (const off of [0x400, 0x9000, 0x1a2b0, 0x30000, 0x3fff0]) heap.writeUInt32LE(100, off); + + const stack = Buffer.alloc(0x8000); + const data = Buffer.alloc(0x4000); + data.writeBigUInt64LE(GAME.heapBase + BigInt(GAME.player), GAME.statics.player); + data.writeBigUInt64LE(GAME.heapBase + BigInt(GAME.world), GAME.statics.world); + heap.writeBigUInt64LE(GAME.heapBase + BigInt(GAME.player), GAME.world + 8); + + const regions = [ + { name: 'executable', start: GAME.imageBase, buf: image, prot: 5 }, + { name: 'executable', start: GAME.dataBase, buf: data, prot: 3 }, + { name: 'libkernel.sprx', start: 0x800000000n, buf: Buffer.alloc(0x4000, 0x90), prot: 5 }, + { name: '', start: GAME.heapBase, buf: heap, prot: 3 }, + { name: 'main stack', start: 0x7ef000000n, buf: stack, prot: 3 }, + ]; + + const intact = (c) => image.subarray(c.offset, c.offset + c.bytes.length).equals(c.bytes); + + // The "game loop": each tick runs the instructions that are still there. + // NOP one out and the matching value stops moving. Each step names the + // memory it writes, so a debugger watchpoint can stop the game right after. + const steps = [ + { + code: GAME.code.healthDrain, + at: GAME.vars.health, + size: 4, + run() { + const h = heap.readUInt32LE(GAME.vars.health); + heap.writeUInt32LE(h <= 1 ? 100 : h - 1, GAME.vars.health); + }, + }, + { + code: GAME.code.ammoSpend, + at: GAME.vars.ammo, + size: 4, + run() { + const a = heap.readUInt32LE(GAME.vars.ammo); + heap.writeUInt32LE(a === 0 ? 30 : a - 1, GAME.vars.ammo); + }, + }, + { + code: GAME.code.goldSpend, + at: GAME.vars.gold, + size: 4, + run() { + const g = heap.readFloatLE(GAME.vars.gold); + heap.writeFloatLE(g < 10 ? 2500 : g - 2.5, GAME.vars.gold); + }, + }, + { + code: GAME.code.scoreAdd, + at: GAME.vars.score, + size: 4, + run() { + heap.writeUInt32LE((heap.readUInt32LE(GAME.vars.score) + 10) >>> 0, GAME.vars.score); + }, + }, + ]; + + /** + * @param {(step: {address: bigint, size: number, rip: bigint}) => boolean} [onWrite] + * called after each write; returning true stops the rest of the frame + */ + function tick(onWrite) { + for (const step of steps) { + if (!intact(step.code)) continue; + step.run(); + const stop = onWrite?.({ + address: GAME.heapBase + BigInt(step.at), + size: step.size, + rip: GAME.imageBase + BigInt(step.code.offset + step.code.bytes.length), + }); + if (stop) return; + } + } + + function locate(addr, len) { + for (const r of regions) { + const end = r.start + BigInt(r.buf.length); + if (addr >= r.start && addr + BigInt(len) <= end) return { r, off: Number(addr - r.start) }; + } + return null; + } + + /** Like the console: unreadable memory comes back as zeros. */ + function read(addr, len) { + const out = Buffer.alloc(len); + for (const r of regions) { + const rEnd = r.start + BigInt(r.buf.length); + const lo = addr > r.start ? addr : r.start; + const hi = addr + BigInt(len) < rEnd ? addr + BigInt(len) : rEnd; + if (lo < hi) r.buf.copy(out, Number(lo - addr), Number(lo - r.start), Number(hi - r.start)); + } + return out; + } + + function write(addr, data) { + const hit = locate(addr, data.length); + if (!hit) return false; + data.copy(hit.r.buf, hit.off); + return true; + } + + let nextAlloc = 0x200000000n; + /** Maps new memory. With a hint it lands on the first free page at or above it. */ + function alloc(length, hint) { + const size = Math.max(0x4000, (length + 0x3fff) & ~0x3fff); + let start; + if (hint) { + start = (hint + 0x3fffn) & ~0x3fffn; + const overlaps = (st) => regions.some((r) => st < r.start + BigInt(r.buf.length) && r.start < st + BigInt(size)); + while (overlaps(start)) start += 0x4000n; + } else { + start = nextAlloc; + nextAlloc += BigInt(size) + 0x100000n; + } + regions.push({ name: '', start, buf: Buffer.alloc(size), prot: 7, allocated: true }); + return start; + } + + function free(addr) { + const i = regions.findIndex((r) => r.allocated && r.start === addr); + if (i < 0) return false; + regions.splice(i, 1); + return true; + } + + return { regions, read, write, tick, heap, image, data, alloc, free }; +} + +// ---- scan comparison (scan_compare.c) -------------------------------------- + +const SIZES = [1, 1, 2, 2, 4, 4, 8, 8, 4, 8]; + +function num(valType, buf, off) { + switch (valType) { + case 0: return buf.readUInt8(off); + case 1: return buf.readInt8(off); + case 2: return buf.readUInt16LE(off); + case 3: return buf.readInt16LE(off); + case 4: return buf.readUInt32LE(off); + case 5: return buf.readInt32LE(off); + case 6: return buf.readBigUInt64LE(off); + case 7: return buf.readBigInt64LE(off); + case 8: return buf.readFloatLE(off); + case 9: return buf.readDoubleLE(off); + default: throw new Error('bad value type'); + } +} + +function fuzzyEqual(a, b, min) { + if (a === b) return true; + const diff = Math.abs(a - b); + if (a === 0 || b === 0) return min * 1e-6 > diff; + const sum = Math.abs(a) + Math.abs(b); + if (min > sum) return min * 1e-6 > diff; + return 1e-6 > diff / sum; +} + +function compareValues(cmp, valType, size, scan, mem, memOff, prev, prevOff) { + if (cmp >= 4 && cmp <= 10 && !prev) return false; + const m = () => num(valType, mem, memOff); + const s = () => num(valType, scan, 0); + const p = () => num(valType, prev, prevOff); + switch (cmp) { + case 0: + if (valType === 8) return scan.readUInt32LE(0) === 0 ? mem.readUInt32LE(memOff) === 0 : fuzzyEqual(s(), m(), 1.17549435e-38); + if (valType === 9) return scan.readBigUInt64LE(0) === 0n ? mem.readBigUInt64LE(memOff) === 0n : fuzzyEqual(s(), m(), 2.2250738585072014e-308); + return scan.subarray(0, size).equals(mem.subarray(memOff, memOff + size)); + case 2: return m() > s(); + case 3: return m() < s(); + case 4: return m() >= s() && m() <= p(); // prev points at the upper bound + case 5: return m() > p(); + case 7: return m() < p(); + case 9: return !mem.subarray(memOff, memOff + size).equals(prev.subarray(prevOff, prevOff + size)); + case 10: return mem.subarray(memOff, memOff + size).equals(prev.subarray(prevOff, prevOff + size)); + default: return false; + } +} + +// rescans: g_cmptype_needs_value / _extra / _previous +const NEEDS_VALUE = [1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0]; +const NEEDS_EXTRA = [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; +const NEEDS_PREV = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0]; + +// ---- auth (auth.c) ---------------------------------------------------------- + +function makeLfsr(a, b, c, d) { + let s1 = a, s2 = b, s3 = c, s4 = d; + return () => { + s1 = (((s1 << 18) & 0xfff80000) ^ ((s1 ^ (s1 << 6)) >>> 13)) >>> 0; + s2 = (((s2 << 2) & 0xffffffe0) ^ ((s2 ^ (s2 << 2)) >>> 27)) >>> 0; + s3 = (((s3 << 7) & 0xfffff800) ^ ((s3 ^ (s3 << 13)) >>> 21)) >>> 0; + s4 = (((s4 << 13) & 0xfff00000) ^ ((s4 ^ (s4 << 3)) >>> 12)) >>> 0; + return (s1 ^ s2 ^ s3 ^ s4) >>> 0; + }; +} + +function keystream() { + const next = makeLfsr(200, 300, 400, 500); + const out = Buffer.alloc(256); + for (let i = 0; i < 256; i++) out[i] = next() & 0xff; + return out; +} + +// ---- a stand-in for the console's assembler --------------------------------------- + +/** + * The real payload embeds Keystone. The mock understands just enough to test + * the plumbing: nop, ret, int3, and raw bytes via "db" / ".byte". + */ +function mockAssemble(text) { + const out = []; + let count = 0; + for (const raw of text.split(/[\n;]/)) { + const line = raw.replace(/(\/\/|#).*$/, '').trim().toLowerCase(); + if (!line || /^[a-z_][a-z0-9_]*:$/.test(line)) continue; + if (line === 'nop') out.push(0x90); + else if (line === 'ret') out.push(0xc3); + else if (line === 'int3') out.push(0xcc); + else if (/^(db|\.byte)\s/.test(line)) { + for (const tok of line.replace(/^(db|\.byte)\s+/, '').split(/[\s,]+/).filter(Boolean)) { + const v = Number(tok.endsWith('h') ? '0x' + tok.slice(0, -1) : tok); + if (!Number.isInteger(v) || v < 0 || v > 255) return { error: `invalid operand (${tok})` }; + out.push(v); + } + } else return { error: `invalid mnemonic (${line.split(/\s/)[0]})` }; + count++; + } + return { bytes: Buffer.from(out), count }; +} + +// ---- socket reader ---------------------------------------------------------- + +class Reader { + constructor(sock) { + this.chunks = []; + this.avail = 0; + this.waiter = null; + this.ended = false; + sock.on('data', (d) => { + this.chunks.push(d); + this.avail += d.length; + this.pump(); + }); + const end = () => { + this.ended = true; + this.pump(); + }; + sock.on('end', end); + sock.on('close', end); + sock.on('error', end); + } + read(n) { + return new Promise((resolve, reject) => { + this.waiter = { n, resolve, reject }; + this.pump(); + }); + } + pump() { + const w = this.waiter; + if (!w) return; + if (this.avail >= w.n) { + const all = Buffer.concat(this.chunks); + this.chunks = [all.subarray(w.n)]; + this.avail -= w.n; + this.waiter = null; + w.resolve(all.subarray(0, w.n)); + } else if (this.ended) { + this.waiter = null; + w.reject(new Error('closed')); + } + } +} + +// ---- server ----------------------------------------------------------------- + +/** + * @param {object} [opts] + * @param {number} [opts.tcpPort] + * @param {number} [opts.udpPort] 0 disables discovery + * @param {boolean} [opts.tick] run the game loop (default true) + * @param {boolean} [opts.legacy] behave like the original ps5debug: no capability level + * @param {boolean} [opts.noBranding] never answer BRANDING / FW_VERSION, like a payload that predates them + * @param {boolean} [opts.noNearAlloc] hinted allocations fail, forcing far code caves + * @param {number} [opts.eventPort] where the debugger connects back on attach (real consoles use 755) + * @param {number} [opts.scanDelayMs] pause per scanned range, so progress is visible in the demo + */ +export function startMock(opts = {}) { + const tcpPort = opts.tcpPort ?? MOCK_TCP_PORT; + const udpPort = opts.udpPort ?? MOCK_UDP_PORT; + const game = createGame(); + const state = { authed: false, notifications: [], foreground: true }; + const authLfsr = makeLfsr(0x12345678, 0x9abcdef0, 0x0f1e2d3c, 0x4b5a6978); + + // One debugger session for the whole console, as on the real thing. + const debug = { owner: null, events: null, watch: [null, null, null, null], stopped: false }; + const debugTeardown = () => { + if (debug.events) debug.events.destroy(); + debug.owner = null; + debug.events = null; + debug.watch = [null, null, null, null]; + debug.stopped = false; + }; + /** Runs one frame of the game, honouring watchpoints. */ + const tick = () => { + if (debug.stopped) return; + game.tick((w) => { + if (!debug.owner || !debug.events) return false; + const hit = debug.watch.some((wp) => wp && wp.kind !== 0 && w.address < wp.address + BigInt(wp.size) && wp.address < w.address + BigInt(w.size)); + if (!hit) return false; + // The 1184-byte stop report (PROTOCOL.md 1.9): thread, status, name, registers. + const pkt = Buffer.alloc(1184); + pkt.writeUInt32LE(100123, 0); + pkt.writeUInt32LE((5 << 8) | 0x7f, 4); // stopped by SIGTRAP + pkt.write('MainThread', 8, 39); + pkt.writeBigUInt64LE(w.address - 0x390n, 0x30 + 104); // rcx + pkt.writeBigUInt64LE(w.rip, 0x30 + 136); // rip: just past the writing instruction + pkt.writeBigUInt64LE(1n, 0x420 + 48); // DR6: watchpoint slot 0 fired + debug.stopped = true; + debug.events.write(pkt); + return true; + }); + }; + const timer = opts.tick === false ? null : setInterval(tick, 500); + if (timer) timer.unref?.(); + + async function handle(sock) { + const rd = new Reader(sock); + let turbo = null; // this connection's snapshot scan + sock.on('close', () => { + if (debug.owner === sock) debugTeardown(); + }); + const status = (s) => { + const b = Buffer.alloc(4); + b.writeUInt32LE(bitswap32(s)); + sock.write(b); + }; + const u32 = (v) => { + const b = Buffer.alloc(4); + b.writeUInt32LE(v >>> 0); + sock.write(b); + }; + const sentinel = () => sock.write(Buffer.alloc(8, 0xff)); + // The real server closes the connection whenever a handler fails early + // (main.c: a non-zero handler result ends the client loop). + const fatal = (s) => { + status(s); + sock.end(); + }; + + for (;;) { + const hdr = await rd.read(12); + if (hdr.readUInt32LE(0) !== PACKET_MAGIC) continue; + const cmd = hdr.readUInt32LE(4); + const datalen = hdr.readUInt32LE(8); + if (datalen > 0x100000) { + status(ST.ERROR); + continue; + } + const d = datalen ? await rd.read(datalen) : null; + + switch (cmd) { + case 0xbd000001: { // VERSION + u32(3); + sock.write('1.3'); + break; + } + case 0xbd000500: { // FW_VERSION + if (opts.noBranding) break; + const b = Buffer.alloc(2); + b.writeUInt16LE(1000); + sock.write(b); + break; + } + case 0xbd000501: { // BRANDING + if (opts.noBranding) break; + const s = opts.legacy + ? Buffer.from('ps5debug v1.0b5 (mock)') + : Buffer.concat([Buffer.from('ps5debug-NG by OSR v1.3.2 [mock0000mock0000]'), Buffer.from([0]), Buffer.from('1.1')]); + u32(s.length); + sock.write(s); + break; + } + case 0xbdaacc06: // NOP + status(ST.SUCCESS); + break; + + case 0xbdaa0001: { // PROC_LIST + const procs = [['SceShellCore', 60], ['SceShellUI', 77]]; + if (state.foreground) procs.push([GAME.name, GAME.pid]); + status(ST.SUCCESS); + u32(procs.length); + for (const [name, pid] of procs) { + const e = Buffer.alloc(36); + e.write(name, 0, 31); + e.writeInt32LE(pid, 32); + sock.write(e); + } + break; + } + case 0xbdaa0002: { // PROC_READ + if (!d) { status(ST.DATA_NULL); break; } + const addr = d.readBigUInt64LE(4); + const len = d.readUInt32LE(12); + status(ST.SUCCESS); + sock.write(game.read(addr, len)); + break; + } + case 0xbdaa0003: { // PROC_WRITE (two status words) + if (!d) { status(ST.DATA_NULL); break; } + const addr = d.readBigUInt64LE(4); + const len = d.readUInt32LE(12); + status(ST.SUCCESS); + const data = await rd.read(len); + status(game.write(addr, data) ? ST.SUCCESS : ST.ERROR); + break; + } + case 0xbdaacc04: { // write-multi + if (opts.legacy) break; // the original payload never answers unknown commands + const count = d.readUInt32LE(4); + const wantStatus = d.readUInt32LE(8) & 1; + status(ST.SUCCESS); + const st = Buffer.alloc(count); + let failed = false; + for (let i = 0; i < count; i++) { + const h = await rd.read(12); + const data = await rd.read(h.readUInt32LE(8)); + if (!game.write(h.readBigUInt64LE(0), data)) { + st[i] = 1; + failed = true; + } + } + if (wantStatus) sock.write(st); + status(wantStatus || !failed ? ST.SUCCESS : ST.ERROR); + break; + } + case 0xbdaa0004: { // PROC_MAPS + if (!d || d.readUInt32LE(0) !== GAME.pid || !state.foreground) { fatal(ST.ERROR); return; } + status(ST.SUCCESS); + u32(game.regions.length); + for (const r of game.regions) { + const e = Buffer.alloc(58); + e.write(r.name, 0, 31); + e.writeBigUInt64LE(r.start, 32); + e.writeBigUInt64LE(r.start + BigInt(r.buf.length), 40); + e.writeBigUInt64LE(0n, 48); + e.writeUInt16LE(r.prot, 56); + sock.write(e); + } + break; + } + case 0xbdaa0008: // PROC_PROTECT + status(ST.SUCCESS); + break; + case 0xbdaa000a: { // PROC_INFO + if (!d || d.readUInt32LE(0) !== GAME.pid || !state.foreground) { fatal(ST.DATA_NULL); return; } + const e = Buffer.alloc(188); + e.writeUInt32LE(GAME.pid, 0); + e.write(GAME.name, 4, 39); + e.write('/mnt/sandbox/pfsmnt/PPSA99999-app0/eboot.bin', 44, 63); + e.write(GAME.titleId, 108, 15); + e.write(GAME.contentId, 124, 63); + status(ST.SUCCESS); + sock.write(e); + break; + } + case 0xbdaaccff: { // PROC_AUTH + if (!d || d.readUInt32LE(0) !== 0xbb40e64d) { fatal(ST.DATA_NULL); return; } + status(ST.SUCCESS); + const challenge = Buffer.alloc(64); + for (let i = 0; i < 64; i++) { + const r = authLfsr(); + challenge[i] = (r + Math.floor(r / 255)) & 0xff; + } + const ks = keystream(); + const len = Buffer.alloc(2); + len.writeUInt16LE(64); + sock.write(len); + sock.write(challenge); + const response = await rd.read(64); + let ok = true; + for (let i = 0; i < 64; i++) if (response[i] !== (challenge[i] ^ ks[i])) ok = false; + if (!ok) { fatal(ST.DATA_NULL); return; } + if (d.readUInt32LE(4) & 2) state.authed = true; + status(ST.SUCCESS); + break; + } + case 0xbdaacc01: { // SCAN_START + if (!state.authed || !d) { fatal(ST.DATA_NULL); return; } + const address = d.readBigUInt64LE(4); + const length = d.readUInt32LE(12); + const valType = d[16], cmp = d[17], alignment = d[18]; + const lenData = d.readUInt32LE(19); + if (cmp > 12 || lenData === 0) { fatal(ST.DATA_NULL); return; } + const needsValue = (((1 << cmp) & 0x114f) !== 0) || cmp === 4; + const size = SIZES[valType] ?? lenData; + status(ST.SUCCESS); + const pattern = needsValue ? await rd.read(lenData) : null; + status(ST.SUCCESS); + if (opts.scanDelayMs) await new Promise((r) => setTimeout(r, opts.scanDelayMs)); + const step = alignment || size; + const mem = game.read(address, length); + const upper = cmp === 4 ? pattern : null; + let block = []; + let blockLen = 0; + const flush = () => { + if (!blockLen) return; + const h = Buffer.alloc(8); + h.writeBigUInt64LE(BigInt(blockLen)); + sock.write(Buffer.concat([h, ...block])); + block = []; + blockLen = 0; + }; + for (let j = 0; j + size <= length; j += step) { + if (compareValues(cmp, valType, size, pattern, mem, j, upper, size)) { + if (blockLen > 0x3ffe8 - size) flush(); + const rec = Buffer.alloc(4 + size); + rec.writeUInt32LE(j, 0); + mem.copy(rec, 4, j, j + size); + block.push(rec); + blockLen += rec.length; + } + } + flush(); + sentinel(); + status(ST.SUCCESS); + break; + } + case 0xbdaacc02: { // SCAN_COUNT + if (!state.authed || !d) { fatal(ST.DATA_NULL); return; } + const base = d.readBigUInt64LE(4); + const valType = d[12], cmp = d[13]; + const lenData = d.readUInt32LE(14); + if (cmp > 12) { fatal(ST.DATA_NULL); return; } + const needsValue = NEEDS_VALUE[cmp] || NEEDS_EXTRA[cmp]; + const withPrev = !!NEEDS_PREV[cmp]; + const size = SIZES[valType] ?? lenData; + status(ST.SUCCESS); + const pattern = needsValue && lenData ? await rd.read(lenData) : null; + const entrySize = withPrev ? 4 + size : 4; + for (;;) { + const chunkLen = (await rd.read(4)).readUInt32LE(0); + if (chunkLen === 0xffffffff) break; + if (chunkLen === 0) { sentinel(); continue; } + if (chunkLen > 0x40000) break; + const chunk = await rd.read(chunkLen); + const out = []; + for (let off = 0; off + entrySize <= chunkLen; off += entrySize) { + const entryOffset = chunk.readUInt32LE(off); + const mem = game.read(base + BigInt(entryOffset), size); + const prev = withPrev ? chunk : cmp === 4 && pattern && lenData >= 2 * size ? pattern : null; + const prevOff = withPrev ? off + 4 : size; + if (compareValues(cmp, valType, size, pattern, mem, 0, prev, prevOff)) { + const rec = Buffer.alloc(4 + size); + rec.writeUInt32LE(entryOffset, 0); + mem.copy(rec, 4); + out.push(rec); + } + } + if (out.length) { + const body = Buffer.concat(out); + const h = Buffer.alloc(8); + h.writeBigUInt64LE(BigInt(body.length)); + sock.write(h); + sock.write(body); + } + sentinel(); + } + status(ST.SUCCESS); + break; + } + case 0xbddd0004: { // NOTIFY + if (!d) { status(ST.DATA_NULL); break; } + const text = await rd.read(d.readUInt32LE(4)); + state.notifications.push(text.toString('utf8').replace(/\0+$/, '')); + status(ST.SUCCESS); + break; + } + case 0xbddd0006: { // foreground app + if (opts.legacy) break; + const e = Buffer.alloc(140); + if (state.foreground) { + e.writeUInt32LE(GAME.pid, 0); + e.write(GAME.titleId, 4, 15); + e.write(GAME.contentId, 20, 63); + e.write(GAME.name, 84, 39); + e.write(GAME.version, 124, 15); + } + status(ST.SUCCESS); + sock.write(e); + break; + } + case 0xbdaa0006: { // PROC_CALL + if (!d) { fatal(ST.DATA_NULL); return; } + const rip = d.readBigUInt64LE(12); + const rdi = d.readBigUInt64LE(20), rsi = d.readBigUInt64LE(28); + let rax; + if (rip === GAME.imageBase + BigInt(GAME.funcs.add)) rax = BigInt.asUintN(64, rdi + rsi); + else if (rip === GAME.imageBase + BigInt(GAME.funcs.setGold)) { + game.heap.writeFloatLE(Number(rdi), GAME.vars.gold); + rax = 0n; + } else { status(ST.ERROR); break; } + const r = Buffer.alloc(12); + r.writeUInt32LE(GAME.pid, 0); + r.writeBigUInt64LE(rax, 4); + status(ST.SUCCESS); + sock.write(r); + break; + } + case 0xbdaa000b: { // PROC_ALLOC + if (!d) { fatal(ST.DATA_NULL); return; } + const r = Buffer.alloc(8); + r.writeBigUInt64LE(game.alloc(d.readUInt32LE(4), null)); + status(ST.SUCCESS); + sock.write(r); + break; + } + case 0xbdaa000e: { // PROC_ALLOC_HINTED + if (!d) { fatal(ST.DATA_NULL); return; } + const r = Buffer.alloc(8); + if (opts.noNearAlloc) { + // The real handler still sends the (zeroed) result after an error status. + status(ST.ERROR); + sock.write(r); + break; + } + r.writeBigUInt64LE(game.alloc(d.readUInt32LE(12), d.readBigUInt64LE(4))); + status(ST.SUCCESS); + sock.write(r); + break; + } + case 0xbdaa000c: { // PROC_FREE + if (!d) { fatal(ST.DATA_NULL); return; } + status(game.free(d.readBigUInt64LE(4)) ? ST.SUCCESS : ST.ERROR); + break; + } + case 0xbdaa0024: { // assemble + if (opts.legacy) break; + if (!d || d.length < 12) { fatal(ST.DATA_NULL); return; } + const res = mockAssemble(d.subarray(12).toString('utf8')); + const r = Buffer.alloc(8); + if (res.error) { + const msg = Buffer.from(res.error); + r.writeUInt32LE(1, 0); + r.writeUInt32LE(msg.length, 4); + status(ST.ERROR); + sock.write(r); + sock.write(msg); + // The real handler reports failure to the client loop, which closes the connection. + sock.end(); + return; + } else { + r.writeUInt32LE(res.bytes.length, 0); + r.writeUInt32LE(res.count, 4); + status(ST.SUCCESS); + sock.write(r); + sock.write(res.bytes); + } + break; + } + case 0xbdaa0501: { // SCAN_AOB + if (!d) { fatal(ST.DATA_NULL); return; } + const address = d.readBigUInt64LE(4); + const length = d.readUInt32LE(12); + const nth = d[16], unique = d[17]; + const plen = d.readUInt32LE(18); + status(ST.SUCCESS); + const pattern = await rd.read(plen); + const mask = await rd.read(plen); + status(ST.SUCCESS); + const mem = game.read(address, length); + let found = 0n, seen = 0; + for (let i = 0; i + plen <= length; i++) { + let ok = true; + for (let j = 0; j < plen; j++) { + if (mask[j] === 1 && mem[i + j] !== pattern[j]) { ok = false; break; } + } + if (!ok) continue; + seen++; + if (seen === nth) found = address + BigInt(i); + if (unique && seen > 1) { found = 0n; break; } + if (!unique && seen === nth) break; + } + const r = Buffer.alloc(8); + r.writeBigUInt64LE(found); + sock.write(r); + status(ST.SUCCESS); + break; + } + + // ---- turbo scan: only the snapshot (unknown value) flow ---- + case 0xbdaacc10: { // TURBOSCAN_CAPS + if (opts.legacy) break; + const r = Buffer.alloc(16); + r.writeUInt32LE(1, 0); + r.writeUInt32LE(0x04 | 0x08 | 0x10, 4); + r.writeUInt32LE(1, 8); + status(ST.SUCCESS); + sock.write(r); + break; + } + case 0xbdaacc11: { // TURBOSCAN_START + if (!state.authed || !d) { fatal(ST.DATA_NULL); return; } + const valType = d[16], cmp = d[17]; + const lenData = d.readUInt32LE(19); + const flags = d.readUInt32LE(23); + const snapshot = (flags & 4) !== 0; + if (cmp > 12 || (lenData === 0 && !snapshot)) { fatal(ST.DATA_NULL); return; } + if (!snapshot || !(flags & 0x10)) { fatal(ST.DATA_NULL); return; } // the mock only does segmented snapshots + const size = SIZES[valType]; + const needsValue = ((1 << cmp) & 0x114f) !== 0 || cmp === 4; + status(ST.SUCCESS); + if (needsValue && lenData) await rd.read(lenData); + status(ST.SUCCESS); + const nseg = (await rd.read(4)).readUInt32LE(0); + const segs = await rd.read(nseg * 12); + if (opts.scanDelayMs) await new Promise((r) => setTimeout(r, opts.scanDelayMs)); + const records = []; + let total = 0; + for (let i = 0; i < nseg; i++) { + const address = segs.readBigUInt64LE(i * 12); + const length = segs.readUInt32LE(i * 12 + 8); + total += length; + const mem = game.read(address, length); + for (let j = 0; j + size <= length; j += size) { + const v = mem.subarray(j, j + size); + if (!(flags & 8) && v.every((b) => b === 0)) continue; // zero slots are dropped unless asked for + records.push({ address: address + BigInt(j), value: Buffer.from(v) }); + } + } + turbo = { valType, size, records }; + const plan = Buffer.alloc(16); + plan.writeBigUInt64LE(BigInt(Math.floor(total / size)), 0); + plan.writeBigUInt64LE(BigInt(total), 8); + sock.write(plan); + const prog = Buffer.alloc(8); + prog.writeBigUInt64LE(BigInt(total)); + sock.write(prog); + sentinel(); + const sum = Buffer.alloc(12); + sum.writeUInt32LE(1, 0); + sum.writeBigUInt64LE(BigInt(records.length), 4); + sock.write(sum); + status(ST.SUCCESS); + break; + } + case 0xbdaacc12: { // TURBOSCAN_COUNT (server-resident only) + if (!state.authed || !d) { fatal(ST.DATA_NULL); return; } + const valType = d[12], cmp = d[13]; + const lenData = d.readUInt32LE(14); + const flags = d.readUInt32LE(18); + if (cmp > 12 || !(flags & 2)) { fatal(ST.DATA_NULL); return; } + const needsValue = NEEDS_VALUE[cmp] || NEEDS_EXTRA[cmp]; + status(ST.SUCCESS); + const pattern = needsValue && lenData ? await rd.read(lenData) : null; + const kept = []; + if (turbo && turbo.valType === valType) { + for (const rec of turbo.records) { + const mem = game.read(rec.address, turbo.size); + const prev = NEEDS_PREV[cmp] ? rec.value : cmp === 4 ? pattern : null; + if (compareValues(cmp, valType, turbo.size, pattern, mem, 0, prev, NEEDS_PREV[cmp] ? 0 : turbo.size)) { + kept.push({ address: rec.address, value: Buffer.from(mem) }); // baseline refreshed + } + } + turbo.records = kept; + } + sentinel(); + const n = Buffer.alloc(8); + n.writeBigUInt64LE(BigInt(kept.length)); + sock.write(n); + status(ST.SUCCESS); + break; + } + case 0xbdaacc13: { // TURBOSCAN_GET + if (!state.authed || !d) { fatal(ST.DATA_NULL); return; } + const start = d.readUInt32LE(0), count = d.readUInt32LE(4); + const rows = turbo ? turbo.records.slice(start, start + count) : []; + status(ST.SUCCESS); + u32(rows.length); + for (const rec of rows) { + const a = Buffer.alloc(8); + a.writeBigUInt64LE(rec.address); + sock.write(Buffer.concat([a, rec.value, rec.value])); + } + status(ST.SUCCESS); + break; + } + case 0xbdaacc14: // TURBOSCAN_END + if (!state.authed) { fatal(ST.DATA_NULL); return; } + turbo = null; + status(ST.SUCCESS); + break; + + // ---- debugger ---- + case 0xbdbb0001: { // DEBUG_ATTACH + if (opts.legacy) break; + if (debug.owner) { fatal(0xf0000008); return; } // CMD_ALREADY_DEBUG + if (!d || d.readUInt32LE(0) !== GAME.pid) { fatal(ST.ERROR); return; } + // The console connects back to whoever attached, on the event port. + const events = net.connect({ host: sock.remoteAddress.replace(/^::ffff:/, ''), port: opts.eventPort ?? 755 }); + const ok = await new Promise((resolve) => { + events.once('connect', () => resolve(true)); + events.once('error', () => resolve(false)); + }); + if (!ok) { fatal(ST.ERROR); return; } + events.on('error', () => {}); + debug.owner = sock; + debug.events = events; + status(ST.SUCCESS); + break; + } + case 0xbdbb0002: // DEBUG_DETACH + // Recorded so tests can check the client disarmed its watchpoints first. + state.detachedWithWatchArmed = debug.watch.some(Boolean); + debugTeardown(); + status(ST.SUCCESS); + break; + case 0xbdbb0004: { // DEBUG_SET_WATCHPOINT + if (!debug.owner) { fatal(ST.ERROR); return; } + if (!d) { fatal(ST.DATA_NULL); return; } + const index = d.readUInt32LE(0); + if (index > 3) { fatal(0xf000000a); return; } // CMD_INVALID_INDEX + const size = [1, 2, 8, 4][d.readUInt32LE(8) & 3]; + debug.watch[index] = d.readUInt32LE(4) ? { address: d.readBigUInt64LE(16), size, kind: d.readUInt32LE(12) } : null; + status(ST.SUCCESS); + break; + } + case 0xbdbb0003: { // DEBUG_SET_BREAKPOINT (accepted, never triggers in the mock) + if (!debug.owner) { fatal(ST.ERROR); return; } + if (!d || d.readUInt32LE(0) > 29) { fatal(0xf000000a); return; } + status(ST.SUCCESS); + break; + } + case 0xbdbb0010: { // DEBUG_CONTINUE + if (!d) { fatal(ST.DATA_NULL); return; } + if (!debug.owner) { status(ST.ERROR); break; } + if (d[0] === 0) debug.stopped = false; + status(ST.SUCCESS); + break; + } + + default: + // Unknown commands get no reply at all, like the real payload. + break; + } + } + } + + const sockets = new Set(); + const server = net.createServer((sock) => { + sock.setNoDelay(true); + sockets.add(sock); + sock.on('close', () => sockets.delete(sock)); + sock.on('error', () => {}); + handle(sock).catch(() => sock.destroy()); + }); + + let udp = null; + if (udpPort) { + udp = dgram.createSocket({ type: 'udp4', reuseAddr: true }); + udp.on('message', (msg, rinfo) => { + if (msg.length === 4 && msg.readUInt32LE(0) === 0xffffaaaa) udp.send(msg, rinfo.port, rinfo.address); + }); + udp.on('error', () => {}); + udp.bind(udpPort, '127.0.0.1'); + udp.unref(); + } + + const ready = new Promise((resolve, reject) => { + server.once('error', reject); + server.listen(tcpPort, '127.0.0.1', () => resolve(server.address().port)); + }); + + return { + ready, + game, + state, + debug, + /** Runs one frame by hand (tests start the mock with tick: false). */ + tick, + /** Makes the game receive a signal that has nothing to do with a watchpoint, as a crash would. */ + raise(signal) { + if (!debug.owner || !debug.events) return; + const pkt = Buffer.alloc(1184); + pkt.writeUInt32LE(100123, 0); + pkt.writeUInt32LE((signal << 8) | 0x7f, 4); + pkt.writeBigUInt64LE(GAME.imageBase + 0x5000n, 0x30 + 136); + debug.stopped = true; + debug.events.write(pkt); + }, + close() { + if (timer) clearInterval(timer); + for (const s of sockets) s.destroy(); + if (udp) udp.close(); + return new Promise((resolve) => server.close(() => resolve())); + }, + }; +} + +if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) { + const mock = startMock(); + mock.ready.then((port) => { + console.log(`Mock PS5 listening on 127.0.0.1:${port} (game ${GAME.titleId} v${GAME.version})`); + }); +} diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..969bc80 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,3465 @@ +{ + "name": "cheatspecter", + "version": "0.3.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "cheatspecter", + "version": "0.3.0", + "license": "GPL-3.0-only", + "dependencies": { + "@radix-ui/react-use-controllable-state": "^1.2.6", + "class-variance-authority": "^0.7.1", + "clsx": "^2.1.1", + "iced-x86": "^1.21.0", + "lucide-react": "^1.54.0", + "radix-ui": "^1.7.0", + "react": "^19.3.0", + "react-dom": "^19.3.0", + "react-dropzone": "^20.1.2", + "tailwind-merge": "^3.7.0", + "tw-animate-css": "^1.4.0", + "ws": "^8.18.0" + }, + "devDependencies": { + "@tailwindcss/vite": "^4.3.3", + "@types/node": "^26.6.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.1.2", + "tailwindcss": "^4.3.3", + "typescript": "^5.6.0", + "vite": "^8.3.4" + }, + "engines": { + "node": ">=20.19" + } + }, + "node_modules/@floating-ui/core": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.8.0.tgz", + "integrity": "sha512-0CIZ5itps/8x7BG8dEIhs53BvCUH2PCoogtakwRTut+Arm58sJooJ0AuZhLw2HJYIR5cMLNPBSS728sPho2khQ==", + "license": "MIT", + "dependencies": { + "@floating-ui/utils": "^0.2.12" + } + }, + "node_modules/@floating-ui/dom": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.8.0.tgz", + "integrity": "sha512-yXSrzeHZBTZadLOlfyhCkJHNeLJnHRnRInwdZ40L7ZiaAtrBwoYlsDrX3v5zB1Utk7CLfzcOVnVVWoXEky7Ceg==", + "license": "MIT", + "dependencies": { + "@floating-ui/core": "^1.8.0", + "@floating-ui/utils": "^0.2.12" + } + }, + "node_modules/@floating-ui/react-dom": { + "version": "2.1.9", + "resolved": "https://registry.npmjs.org/@floating-ui/react-dom/-/react-dom-2.1.9.tgz", + "integrity": "sha512-JDjEFGCpImxDCA7JJKviA0M9+RtmJdj0m/NVU5IMgBK+AmZouAQQ7/+2GLH0GXXY0YMw9oXPB8hKdbPYg5QLYg==", + "license": "MIT", + "dependencies": { + "@floating-ui/dom": "^1.8.0" + }, + "peerDependencies": { + "react": ">=16.8.0", + "react-dom": ">=16.8.0" + } + }, + "node_modules/@floating-ui/utils": { + "version": "0.2.12", + "resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.12.tgz", + "integrity": "sha512-HpCo8tmWzLVad5s2d19EhAz5zqrrQ6s69qd6moPMQvkOuSwDT1YgRfWSVuc4ennqrgv3OHppiOGMQ7oC13yIww==", + "license": "MIT" + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.13", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", + "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/remapping": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz", + "integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz", + "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@oxc-project/types": { + "version": "0.153.0", + "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.153.0.tgz", + "integrity": "sha512-jSNrRIyvPVLL5E1z/tS5zLAprosGz/FuI1PWwEOz59j3E4TTTzSpqKb/RDGqJhhW0QHYISGXxq582wGx6T11Tw==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/oxc-project" + } + }, + "node_modules/@radix-ui/number": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@radix-ui/number/-/number-1.1.3.tgz", + "integrity": "sha512-Road2bidD0uu/1BGDOWNdPI06g0lIRy6IF9GZcIrDK2KGItfor8IQwQa+yM2ERgHM1MmHxaxpTzk0/Jp42lNfA==", + "license": "MIT" + }, + "node_modules/@radix-ui/primitive": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/@radix-ui/primitive/-/primitive-1.1.7.tgz", + "integrity": "sha512-rqWnm76nYT8HoNNqEjpgJ7Pw/DrBj5iBTrmEPo6HTX5+VJyBNOqTdv4g89G63HuR5g0AaENoAcH7Is5fF2kZ8Q==", + "license": "MIT" + }, + "node_modules/@radix-ui/react-accessible-icon": { + "version": "1.1.16", + "resolved": "https://registry.npmjs.org/@radix-ui/react-accessible-icon/-/react-accessible-icon-1.1.16.tgz", + "integrity": "sha512-I+T/Hc6SY3WbFVZ9Ne1o0DJbpjQpTpLIBZcVzYiHCQ9z1yGUd/G88u5SKyM6eJ223txAOS7bp7bb9k0Ocfkjwg==", + "license": "MIT", + "dependencies": { + "@radix-ui/react-visually-hidden": "1.2.12" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-accordion": { + "version": "1.2.21", + "resolved": "https://registry.npmjs.org/@radix-ui/react-accordion/-/react-accordion-1.2.21.tgz", + "integrity": "sha512-2fmc6COuKLq2k3P7JZrOt9Zf8HT9nTQhHN5V+A3ih7ftqoyDcoEUrPoLq8ngr7QwTd7hpQ2xoUKWtvy1Xw9RAQ==", + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.1.7", + "@radix-ui/react-collapsible": "1.1.21", + "@radix-ui/react-collection": "1.1.16", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.2.2", + "@radix-ui/react-direction": "1.1.5", + "@radix-ui/react-id": "1.1.4", + "@radix-ui/react-primitive": "2.1.11", + "@radix-ui/react-use-controllable-state": "1.2.6" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-alert-dialog": { + "version": "1.1.24", + "resolved": "https://registry.npmjs.org/@radix-ui/react-alert-dialog/-/react-alert-dialog-1.1.24.tgz", + "integrity": "sha512-dRvB59HhcjIWcCPKzK5Px1yQ8pIULQQrxqgyepCqin7tNXi/xvmC86WkyMOKhuCbjz3+v9Q6oE7/tUN5NQ9dCg==", + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.1.7", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.2.2", + "@radix-ui/react-dialog": "1.2.0", + "@radix-ui/react-primitive": "2.1.11" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-arrow": { + "version": "1.1.16", + "resolved": "https://registry.npmjs.org/@radix-ui/react-arrow/-/react-arrow-1.1.16.tgz", + "integrity": "sha512-nXPI1tzJsnQw8oXvB2r49rO9TIbbJ8VFeaWDiBsqY8+iwO5xb7WjUsrXDagjAgPKTdhW8WODQnAltUhBx8I+sg==", + "license": "MIT", + "dependencies": { + "@radix-ui/react-primitive": "2.1.11" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-aspect-ratio": { + "version": "1.1.16", + "resolved": "https://registry.npmjs.org/@radix-ui/react-aspect-ratio/-/react-aspect-ratio-1.1.16.tgz", + "integrity": "sha512-w2u6oiTzb7WkWwV3ZClX/llYYlTbilUOkHIKkwb+PWWytQ/IdEVRNLIChjbcXy/mkqcKKM3wEhrOilJW+uPHDg==", + "license": "MIT", + "dependencies": { + "@radix-ui/react-primitive": "2.1.11" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-avatar": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/@radix-ui/react-avatar/-/react-avatar-1.2.7.tgz", + "integrity": "sha512-6AizCpbU3Zngojp9vQak8Lt4AXwdKJ2lkRYAfpoETraT+qKVNeRqytiADzneHetFEB0Wu4+qeSfmZEq0PiVDmQ==", + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.1.7", + "@radix-ui/react-context": "1.2.2", + "@radix-ui/react-primitive": "2.1.11", + "@radix-ui/react-use-callback-ref": "1.1.4", + "@radix-ui/react-use-is-hydrated": "0.1.3", + "@radix-ui/react-use-layout-effect": "1.1.4" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-checkbox": { + "version": "1.3.12", + "resolved": "https://registry.npmjs.org/@radix-ui/react-checkbox/-/react-checkbox-1.3.12.tgz", + "integrity": "sha512-gNOS2lLrpQxNLWHhCX0sayfVRiyB5gQp7nQIzpl+PM1Hkab52utsKtD27alAr78uqhpvX51kwqDp71hM5hNSwg==", + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.1.7", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.2.2", + "@radix-ui/react-presence": "1.1.11", + "@radix-ui/react-primitive": "2.1.11", + "@radix-ui/react-use-controllable-state": "1.2.6", + "@radix-ui/react-use-size": "1.1.5" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-collapsible": { + "version": "1.1.21", + "resolved": "https://registry.npmjs.org/@radix-ui/react-collapsible/-/react-collapsible-1.1.21.tgz", + "integrity": "sha512-IzkusZHCZBnED5skW+b+syl8d+e3+zelvxZ2Ed9lfawqEBfa5osPj53sTJ+q/uNmGAj9e7wMYgyzwPu/luWJ4Q==", + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.1.7", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.2.2", + "@radix-ui/react-id": "1.1.4", + "@radix-ui/react-presence": "1.1.11", + "@radix-ui/react-primitive": "2.1.11", + "@radix-ui/react-use-controllable-state": "1.2.6", + "@radix-ui/react-use-layout-effect": "1.1.4" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-collection": { + "version": "1.1.16", + "resolved": "https://registry.npmjs.org/@radix-ui/react-collection/-/react-collection-1.1.16.tgz", + "integrity": "sha512-yEQrjfI5eBbeYEJXOASpm+gs9eNHY8+UjkZ81GzcuwdLrSMOlEM8jnGoGdeGo92oiBMkuwZUhHTsnsrDiJLcyA==", + "license": "MIT", + "dependencies": { + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.2.2", + "@radix-ui/react-primitive": "2.1.11", + "@radix-ui/react-slot": "1.4.0" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-compose-refs": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@radix-ui/react-compose-refs/-/react-compose-refs-1.1.5.tgz", + "integrity": "sha512-+48PbAAbq3didjJxa+OaWY2ZwgAKsNiRGyeHKszblZMQ+kcpd9pAaT11cMkGEie0vsOi3QdeTE6d5Fe3Gn61kA==", + "license": "MIT", + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-context": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@radix-ui/react-context/-/react-context-1.2.2.tgz", + "integrity": "sha512-RHCUGwKHDr0hDGg4X7ma4JG4/+12qxw8rkh5QKdDldlCvtja6nUx1Ef/8HVrJze81lEsgLQlqjzjGNHantgnQA==", + "license": "MIT", + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-context-menu": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/@radix-ui/react-context-menu/-/react-context-menu-2.3.8.tgz", + "integrity": "sha512-s8ABBkEuAOyhDub0Y99f8lVRlVsd28mUnOHtuqGg8LuHnefkmPN5rYzA2g8MAPLjAZMisnDHhN4dBHUM7ZF7Rg==", + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.1.7", + "@radix-ui/react-context": "1.2.2", + "@radix-ui/react-menu": "2.1.25", + "@radix-ui/react-primitive": "2.1.11", + "@radix-ui/react-use-controllable-state": "1.2.6" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-dialog": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@radix-ui/react-dialog/-/react-dialog-1.2.0.tgz", + "integrity": "sha512-l5CX8HdNL+9cc4s7HkNyplumSA3FIx68sg9dttBHKr286fRBwq1MBniDVTeI/tkof92/APntMQvC1YG1Khb0Cg==", + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.1.7", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.2.2", + "@radix-ui/react-dismissable-layer": "1.1.20", + "@radix-ui/react-focus-guards": "1.1.6", + "@radix-ui/react-focus-scope": "1.2.0", + "@radix-ui/react-id": "1.1.4", + "@radix-ui/react-portal": "1.1.18", + "@radix-ui/react-presence": "1.1.11", + "@radix-ui/react-primitive": "2.1.11", + "@radix-ui/react-slot": "1.4.0", + "@radix-ui/react-use-controllable-state": "1.2.6", + "@radix-ui/react-use-layout-effect": "1.1.4", + "aria-hidden": "^1.2.4", + "react-remove-scroll": "^2.7.2" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-direction": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@radix-ui/react-direction/-/react-direction-1.1.5.tgz", + "integrity": "sha512-/NlO/rOqQabmg+GGr86vCmbJVhqTv85NfM9g6Gknf/JVygXeZ6e6HM/RW1omerW9HsFtecwNqgEAKV6UqDsvpA==", + "license": "MIT", + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-dismissable-layer": { + "version": "1.1.20", + "resolved": "https://registry.npmjs.org/@radix-ui/react-dismissable-layer/-/react-dismissable-layer-1.1.20.tgz", + "integrity": "sha512-35WHRrycfnj2m4LvPiKMKHGLM3Y2WvUA744CkRdxjs1BGDX1c8PVMfmiSGTUwnHRbqdtIoxveYTXvcJSt7VfgQ==", + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.1.7", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-primitive": "2.1.11", + "@radix-ui/react-use-callback-ref": "1.1.4", + "@radix-ui/react-use-effect-event": "0.0.5" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-dropdown-menu": { + "version": "2.1.25", + "resolved": "https://registry.npmjs.org/@radix-ui/react-dropdown-menu/-/react-dropdown-menu-2.1.25.tgz", + "integrity": "sha512-45QO76jn/a+cRl6OPgZKCKnIMdfYZaOa6SuAJeKHFiM3orX6bnscuFQJDx3qS4Agp/RE+eKv+9gmUL8t3Ma7bw==", + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.1.7", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.2.2", + "@radix-ui/react-id": "1.1.4", + "@radix-ui/react-menu": "2.1.25", + "@radix-ui/react-primitive": "2.1.11", + "@radix-ui/react-use-controllable-state": "1.2.6" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-focus-guards": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/@radix-ui/react-focus-guards/-/react-focus-guards-1.1.6.tgz", + "integrity": "sha512-RNOJjfZMTyBM6xYmV3IVGXkPjIhcBAuv48POevAXwrGJhkWZ9p1rFoIS1JFooPuT193AZmRsCPhpoVJxx6OPoQ==", + "license": "MIT", + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-focus-scope": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@radix-ui/react-focus-scope/-/react-focus-scope-1.2.0.tgz", + "integrity": "sha512-I5S7vsAOozx2lWSBAyuXjWIJ/A8qx4fjbv6115WoaRYQSb1yZDaeNHonUAQzXyE8oD+0whJHbQRl4HIE2gQ0Xw==", + "license": "MIT", + "dependencies": { + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-primitive": "2.1.11", + "@radix-ui/react-use-callback-ref": "1.1.4" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-form": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@radix-ui/react-form/-/react-form-0.2.0.tgz", + "integrity": "sha512-5ELeC+bQUHXEjU51svw11DynjGFlaUjo5QOUCr5hptvLLtBiqWtva2O3IWdjrFWQwitw6k6KpHHEyI61/kCVeg==", + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.1.7", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.2.2", + "@radix-ui/react-id": "1.1.4", + "@radix-ui/react-label": "2.1.16", + "@radix-ui/react-primitive": "2.1.11" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-hover-card": { + "version": "1.1.24", + "resolved": "https://registry.npmjs.org/@radix-ui/react-hover-card/-/react-hover-card-1.1.24.tgz", + "integrity": "sha512-0w/tZHRo1fv4WsfcyaOdi5eDftFA8wQkr8WCOOuxw7fx9S2ERfshQioM269aFZsmyAHd0X1LWoZ2BQTlA/JYUw==", + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.1.7", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.2.2", + "@radix-ui/react-dismissable-layer": "1.1.20", + "@radix-ui/react-focus-scope": "1.2.0", + "@radix-ui/react-popper": "1.3.8", + "@radix-ui/react-portal": "1.1.18", + "@radix-ui/react-presence": "1.1.11", + "@radix-ui/react-primitive": "2.1.11", + "@radix-ui/react-use-controllable-state": "1.2.6" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-id": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@radix-ui/react-id/-/react-id-1.1.4.tgz", + "integrity": "sha512-TMQp2llA+RYn7JcjnrMnz7wN4pcVttPZnRZo52PLQsoLVKzNlVwUeHmfePgTgRluXFvlD3GD5g5MOVVTJCO0qA==", + "license": "MIT", + "dependencies": { + "@radix-ui/react-use-layout-effect": "1.1.4" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-label": { + "version": "2.1.16", + "resolved": "https://registry.npmjs.org/@radix-ui/react-label/-/react-label-2.1.16.tgz", + "integrity": "sha512-2vTQj72YFmeoTxWKJEMbO/9uQt6zzLgbzi0+nWBffq49oo6KhIDP/D+fA2im0wsxBCAX7QfaF3xgsYBVdDbNFQ==", + "license": "MIT", + "dependencies": { + "@radix-ui/react-primitive": "2.1.11" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-menu": { + "version": "2.1.25", + "resolved": "https://registry.npmjs.org/@radix-ui/react-menu/-/react-menu-2.1.25.tgz", + "integrity": "sha512-e8JaQc0ijBbTx37YVI09Nfq8ThUWJ4L1rvZ3Hvaufehco9/ug9+U3PHz9ue6w3gKd91UcKf9fgDWejeSO+VSKQ==", + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.1.7", + "@radix-ui/react-collection": "1.1.16", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.2.2", + "@radix-ui/react-direction": "1.1.5", + "@radix-ui/react-dismissable-layer": "1.1.20", + "@radix-ui/react-focus-guards": "1.1.6", + "@radix-ui/react-focus-scope": "1.2.0", + "@radix-ui/react-id": "1.1.4", + "@radix-ui/react-popper": "1.3.8", + "@radix-ui/react-portal": "1.1.18", + "@radix-ui/react-presence": "1.1.11", + "@radix-ui/react-primitive": "2.1.11", + "@radix-ui/react-roving-focus": "1.1.20", + "@radix-ui/react-slot": "1.4.0", + "@radix-ui/react-use-callback-ref": "1.1.4", + "aria-hidden": "^1.2.4", + "react-remove-scroll": "^2.7.2" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-menubar": { + "version": "1.1.25", + "resolved": "https://registry.npmjs.org/@radix-ui/react-menubar/-/react-menubar-1.1.25.tgz", + "integrity": "sha512-JIQiKcXsgl6BtwcMe7BMLvCGH2p9Czgcmxl6Ie9Zoi+MW1mmitkcm5We01m/ndLYVI8PpRJnM/RcLV0eOCxaJQ==", + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.1.7", + "@radix-ui/react-collection": "1.1.16", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.2.2", + "@radix-ui/react-direction": "1.1.5", + "@radix-ui/react-id": "1.1.4", + "@radix-ui/react-menu": "2.1.25", + "@radix-ui/react-primitive": "2.1.11", + "@radix-ui/react-roving-focus": "1.1.20", + "@radix-ui/react-use-controllable-state": "1.2.6" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-navigation-menu": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@radix-ui/react-navigation-menu/-/react-navigation-menu-1.3.0.tgz", + "integrity": "sha512-hZqTqDwc8Z5aI4rGIyPqCSJ2JoSNorqX/F1/gqNHkZzWJO6JuYzL7hn5sWOZJjpkfT+cbxWWRbKVU/IeiOM9ag==", + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.1.7", + "@radix-ui/react-collection": "1.1.16", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.2.2", + "@radix-ui/react-direction": "1.1.5", + "@radix-ui/react-dismissable-layer": "1.1.20", + "@radix-ui/react-id": "1.1.4", + "@radix-ui/react-presence": "1.1.11", + "@radix-ui/react-primitive": "2.1.11", + "@radix-ui/react-slot": "1.4.0", + "@radix-ui/react-use-callback-ref": "1.1.4", + "@radix-ui/react-use-controllable-state": "1.2.6", + "@radix-ui/react-use-layout-effect": "1.1.4", + "@radix-ui/react-use-previous": "1.1.4", + "@radix-ui/react-visually-hidden": "1.2.12" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-one-time-password-field": { + "version": "0.1.17", + "resolved": "https://registry.npmjs.org/@radix-ui/react-one-time-password-field/-/react-one-time-password-field-0.1.17.tgz", + "integrity": "sha512-+6jmOqjSNBr7F1uSc7HSDqD3XL54A2qA99I9rIH4JoOD/jDScw8tUmDz6HCAkjytbrE/cdL66i+QkeDyZ0WNyw==", + "license": "MIT", + "dependencies": { + "@radix-ui/number": "1.1.3", + "@radix-ui/primitive": "1.1.7", + "@radix-ui/react-collection": "1.1.16", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.2.2", + "@radix-ui/react-direction": "1.1.5", + "@radix-ui/react-primitive": "2.1.11", + "@radix-ui/react-roving-focus": "1.1.20", + "@radix-ui/react-use-controllable-state": "1.2.6", + "@radix-ui/react-use-effect-event": "0.0.5", + "@radix-ui/react-use-is-hydrated": "0.1.3", + "@radix-ui/react-use-layout-effect": "1.1.4" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-password-toggle-field": { + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/@radix-ui/react-password-toggle-field/-/react-password-toggle-field-0.1.12.tgz", + "integrity": "sha512-+SWSgf3HRpE4zUira+p6t5KUR473PSqewtQgj9qzl3znZPRWPCGycwXNTfHwkiRTD3tEXwNIXJg0i1NTteiULw==", + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.1.7", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.2.2", + "@radix-ui/react-id": "1.1.4", + "@radix-ui/react-primitive": "2.1.11", + "@radix-ui/react-use-controllable-state": "1.2.6", + "@radix-ui/react-use-effect-event": "0.0.5", + "@radix-ui/react-use-is-hydrated": "0.1.3" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-popover": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@radix-ui/react-popover/-/react-popover-1.2.0.tgz", + "integrity": "sha512-e70Nh+0iQ+hRAIM2nAGib5BhaDL2Rjlzxw9kIzsU2nz+t3/t82Z5qtPhY5nTnfj8FbmrU6RRIKH8RF3ynCe+vw==", + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.1.7", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.2.2", + "@radix-ui/react-dismissable-layer": "1.1.20", + "@radix-ui/react-focus-guards": "1.1.6", + "@radix-ui/react-focus-scope": "1.2.0", + "@radix-ui/react-id": "1.1.4", + "@radix-ui/react-popper": "1.3.8", + "@radix-ui/react-portal": "1.1.18", + "@radix-ui/react-presence": "1.1.11", + "@radix-ui/react-primitive": "2.1.11", + "@radix-ui/react-slot": "1.4.0", + "@radix-ui/react-use-controllable-state": "1.2.6", + "@radix-ui/react-use-layout-effect": "1.1.4", + "aria-hidden": "^1.2.4", + "react-remove-scroll": "^2.7.2" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-popper": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/@radix-ui/react-popper/-/react-popper-1.3.8.tgz", + "integrity": "sha512-y92/9iIdG1FyNvow0Y0qP5WJZ7oRTAKDVKCy9kJnhZfItwIKYtt0KKQeOhBKfXz0ETizduKwDRbrQHrTQScs5A==", + "license": "MIT", + "dependencies": { + "@floating-ui/react-dom": "^2.0.0", + "@radix-ui/react-arrow": "1.1.16", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.2.2", + "@radix-ui/react-primitive": "2.1.11", + "@radix-ui/react-use-callback-ref": "1.1.4", + "@radix-ui/react-use-layout-effect": "1.1.4", + "@radix-ui/react-use-rect": "1.1.4", + "@radix-ui/react-use-size": "1.1.5", + "@radix-ui/rect": "1.1.3" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-portal": { + "version": "1.1.18", + "resolved": "https://registry.npmjs.org/@radix-ui/react-portal/-/react-portal-1.1.18.tgz", + "integrity": "sha512-ygFIJ+QXNKf72AAq8x3hd22+ws7pYpmc1S0E4kW0Je+qD4qEb3FvxeKVQRGrVDMOkQaYfsB+Qs+KDh81a1gAOw==", + "license": "MIT", + "dependencies": { + "@radix-ui/react-primitive": "2.1.11", + "@radix-ui/react-use-layout-effect": "1.1.4" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-presence": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/@radix-ui/react-presence/-/react-presence-1.1.11.tgz", + "integrity": "sha512-Z7/atlkab36Z8hm+V8zYc79r0W+tiOB1o0tun1By94JyadkekLQmtEAnBSP9XKXBNQsStoStS4+gX10JpS5akA==", + "license": "MIT", + "dependencies": { + "@radix-ui/react-use-layout-effect": "1.1.4" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-primitive": { + "version": "2.1.11", + "resolved": "https://registry.npmjs.org/@radix-ui/react-primitive/-/react-primitive-2.1.11.tgz", + "integrity": "sha512-RzcaSw5aKl0OPhBJ1wbolKSF6nVvN+0o/QLeIVq+09npiPdnCkPggy2k6gI6yetxl4ZyrlBPYFgCB8BQJZwXcQ==", + "license": "MIT", + "dependencies": { + "@radix-ui/react-slot": "1.4.0" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-progress": { + "version": "1.1.17", + "resolved": "https://registry.npmjs.org/@radix-ui/react-progress/-/react-progress-1.1.17.tgz", + "integrity": "sha512-A+RfMARd9u+UaVbLQDmysGlAGuaFQrF+uxF3v+7+xU8tkKoYxtCSs+6HHnIKJVgam2sGZ7c0hLRPWSnmnFyGJQ==", + "license": "MIT", + "dependencies": { + "@radix-ui/react-context": "1.2.2", + "@radix-ui/react-primitive": "2.1.11" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-radio-group": { + "version": "1.4.8", + "resolved": "https://registry.npmjs.org/@radix-ui/react-radio-group/-/react-radio-group-1.4.8.tgz", + "integrity": "sha512-MaOOZ1TlaYoOeSDnHeVIONss0rp5ngOTY5HJY+Xkq16PAopnj21iU9r9m0O/77cBYu8Ksaq3BcjlaOdpbfbzzg==", + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.1.7", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.2.2", + "@radix-ui/react-direction": "1.1.5", + "@radix-ui/react-presence": "1.1.11", + "@radix-ui/react-primitive": "2.1.11", + "@radix-ui/react-roving-focus": "1.1.20", + "@radix-ui/react-use-controllable-state": "1.2.6", + "@radix-ui/react-use-size": "1.1.5" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-roving-focus": { + "version": "1.1.20", + "resolved": "https://registry.npmjs.org/@radix-ui/react-roving-focus/-/react-roving-focus-1.1.20.tgz", + "integrity": "sha512-+ZjbkU21fTSJdn4nq/IFKUdKS+JSZHORBZ8ma1f6YpOMNzRt0xf3sVAWVK/+ktHCajPy4HYDsyHXZIZmOMxzIA==", + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.1.7", + "@radix-ui/react-collection": "1.1.16", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.2.2", + "@radix-ui/react-direction": "1.1.5", + "@radix-ui/react-id": "1.1.4", + "@radix-ui/react-primitive": "2.1.11", + "@radix-ui/react-use-callback-ref": "1.1.4", + "@radix-ui/react-use-controllable-state": "1.2.6", + "@radix-ui/react-use-is-hydrated": "0.1.3", + "@radix-ui/react-use-layout-effect": "1.1.4" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-scroll-area": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@radix-ui/react-scroll-area/-/react-scroll-area-1.3.0.tgz", + "integrity": "sha512-1WSuAXaahfeLmFX/dfYo/ftg1filMfaWjVye2d40VlgtWMMq/NOVocfukZEXkG+dwrAoNI+qpo9bjhNSJ/XC8g==", + "license": "MIT", + "dependencies": { + "@radix-ui/number": "1.1.3", + "@radix-ui/primitive": "1.1.7", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.2.2", + "@radix-ui/react-direction": "1.1.5", + "@radix-ui/react-presence": "1.1.11", + "@radix-ui/react-primitive": "2.1.11", + "@radix-ui/react-slot": "1.4.0", + "@radix-ui/react-use-callback-ref": "1.1.4", + "@radix-ui/react-use-layout-effect": "1.1.4" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-select": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/@radix-ui/react-select/-/react-select-2.3.8.tgz", + "integrity": "sha512-Tz9xOpV9Rbca5WTk7pzmfAECV3zb++uScT9mP3Px7ziAhH7SlK53b0uwMw8VubPhRK4x7uDKCy5fwevT8I0fAg==", + "license": "MIT", + "dependencies": { + "@radix-ui/number": "1.1.3", + "@radix-ui/primitive": "1.1.7", + "@radix-ui/react-collection": "1.1.16", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.2.2", + "@radix-ui/react-direction": "1.1.5", + "@radix-ui/react-dismissable-layer": "1.1.20", + "@radix-ui/react-focus-guards": "1.1.6", + "@radix-ui/react-focus-scope": "1.2.0", + "@radix-ui/react-id": "1.1.4", + "@radix-ui/react-popper": "1.3.8", + "@radix-ui/react-portal": "1.1.18", + "@radix-ui/react-presence": "1.1.11", + "@radix-ui/react-primitive": "2.1.11", + "@radix-ui/react-slot": "1.4.0", + "@radix-ui/react-use-callback-ref": "1.1.4", + "@radix-ui/react-use-controllable-state": "1.2.6", + "@radix-ui/react-use-layout-effect": "1.1.4", + "@radix-ui/react-use-previous": "1.1.4", + "@radix-ui/react-visually-hidden": "1.2.12", + "aria-hidden": "^1.2.4", + "react-remove-scroll": "^2.7.2" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-separator": { + "version": "1.1.16", + "resolved": "https://registry.npmjs.org/@radix-ui/react-separator/-/react-separator-1.1.16.tgz", + "integrity": "sha512-vugPjGQBXbJVVkftKqv/BVeZ108SyRGT3FR1oa14az6qyLgX8jPhnZYHgdSB7Gw8UJusqwb9eaK6mluOnsn/Vg==", + "license": "MIT", + "dependencies": { + "@radix-ui/react-primitive": "2.1.11" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-slider": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@radix-ui/react-slider/-/react-slider-1.5.0.tgz", + "integrity": "sha512-ZOBLK7KZvGL02V+4VwVbj8NYM4vPrAtyZdrgHSv+AMS9VL+5yAdnQF3DZT4Y8cbCp1Yn4xdp92orvez8fJa77w==", + "license": "MIT", + "dependencies": { + "@radix-ui/number": "1.1.3", + "@radix-ui/primitive": "1.1.7", + "@radix-ui/react-collection": "1.1.16", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.2.2", + "@radix-ui/react-direction": "1.1.5", + "@radix-ui/react-primitive": "2.1.11", + "@radix-ui/react-use-controllable-state": "1.2.6", + "@radix-ui/react-use-layout-effect": "1.1.4", + "@radix-ui/react-use-previous": "1.1.4", + "@radix-ui/react-use-size": "1.1.5" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-slot": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@radix-ui/react-slot/-/react-slot-1.4.0.tgz", + "integrity": "sha512-IuMVHZ+Ah5fkctu3X3qeFrV/ZrBcuWuDTFUUPfS/L5hvoTjzhp/HdWGE14CsQombPdEidsa33HVlYZXi49PZ1Q==", + "license": "MIT", + "dependencies": { + "@radix-ui/react-compose-refs": "1.1.5" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-switch": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/@radix-ui/react-switch/-/react-switch-1.3.8.tgz", + "integrity": "sha512-rr+zuoAeHWK3m6H4HgjOUiu3VsrQ/9JkjwY/uMnTgHJGPe9WNzDP/MOuIV7S+65p42DIxjGL0hAHktqBq82+2A==", + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.1.7", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.2.2", + "@radix-ui/react-primitive": "2.1.11", + "@radix-ui/react-use-controllable-state": "1.2.6", + "@radix-ui/react-use-size": "1.1.5" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-tabs": { + "version": "1.1.22", + "resolved": "https://registry.npmjs.org/@radix-ui/react-tabs/-/react-tabs-1.1.22.tgz", + "integrity": "sha512-GmVH+P3wx1ZPMuH7WajQzygZIbqgnsb5h8z4Ow3sQMuDqgcqISSBNom6MLVNJvfrkuJTtqfXc3ZolHjX+w0CHg==", + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.1.7", + "@radix-ui/react-context": "1.2.2", + "@radix-ui/react-direction": "1.1.5", + "@radix-ui/react-id": "1.1.4", + "@radix-ui/react-presence": "1.1.11", + "@radix-ui/react-primitive": "2.1.11", + "@radix-ui/react-roving-focus": "1.1.20", + "@radix-ui/react-use-controllable-state": "1.2.6" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-toast": { + "version": "1.2.24", + "resolved": "https://registry.npmjs.org/@radix-ui/react-toast/-/react-toast-1.2.24.tgz", + "integrity": "sha512-XR9pDEz9CH0ez98zPXQZOpF46anvbarkoOpjXpPSX7gm21vEl5Tzoe1PSQd3EY1OTOHac4lNq+TPx/2Z7jObdQ==", + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.1.7", + "@radix-ui/react-collection": "1.1.16", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.2.2", + "@radix-ui/react-dismissable-layer": "1.1.20", + "@radix-ui/react-portal": "1.1.18", + "@radix-ui/react-presence": "1.1.11", + "@radix-ui/react-primitive": "2.1.11", + "@radix-ui/react-use-callback-ref": "1.1.4", + "@radix-ui/react-use-controllable-state": "1.2.6", + "@radix-ui/react-use-layout-effect": "1.1.4", + "@radix-ui/react-visually-hidden": "1.2.12" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-toggle": { + "version": "1.1.19", + "resolved": "https://registry.npmjs.org/@radix-ui/react-toggle/-/react-toggle-1.1.19.tgz", + "integrity": "sha512-l7FQHtuZjUJ0vKLdhKu5LzZ8Jw6K60QEC1tC22QNLuXN2PkydSoqEhKTCqwxBFZJ52NTCjzudDvl9sUsZeUbPw==", + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.1.7", + "@radix-ui/react-primitive": "2.1.11", + "@radix-ui/react-use-controllable-state": "1.2.6" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-toggle-group": { + "version": "1.1.20", + "resolved": "https://registry.npmjs.org/@radix-ui/react-toggle-group/-/react-toggle-group-1.1.20.tgz", + "integrity": "sha512-O+Sjiv64DfnByHYtnKEXmn63uUskU/X61vjf69X1v8JFn/ZvuNNLdJTBfYurVTSDv4/RJnJGtGgb/uvuS/rRJw==", + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.1.7", + "@radix-ui/react-context": "1.2.2", + "@radix-ui/react-direction": "1.1.5", + "@radix-ui/react-primitive": "2.1.11", + "@radix-ui/react-roving-focus": "1.1.20", + "@radix-ui/react-toggle": "1.1.19", + "@radix-ui/react-use-controllable-state": "1.2.6" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-toolbar": { + "version": "1.1.20", + "resolved": "https://registry.npmjs.org/@radix-ui/react-toolbar/-/react-toolbar-1.1.20.tgz", + "integrity": "sha512-5gyzL6B5/zjBwU3ATBWAVZ4xXQC5F8E9CB4BmYC1UvZ08pN2OJQoooeIwJtZZ/2rz4sTiQmbGfdDvmU73wRJCQ==", + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.1.7", + "@radix-ui/react-context": "1.2.2", + "@radix-ui/react-direction": "1.1.5", + "@radix-ui/react-primitive": "2.1.11", + "@radix-ui/react-roving-focus": "1.1.20", + "@radix-ui/react-separator": "1.1.16", + "@radix-ui/react-toggle-group": "1.1.20" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-tooltip": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@radix-ui/react-tooltip/-/react-tooltip-1.3.0.tgz", + "integrity": "sha512-4HM4b1Cft1CBXCGDRDG3S/fh8GedBuVOMNh145wMIfTbVqcuv+tyj03nZqYgFevWJMYo58H0s+8P6s6NaUHWtA==", + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.1.7", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.2.2", + "@radix-ui/react-dismissable-layer": "1.1.20", + "@radix-ui/react-id": "1.1.4", + "@radix-ui/react-popper": "1.3.8", + "@radix-ui/react-portal": "1.1.18", + "@radix-ui/react-presence": "1.1.11", + "@radix-ui/react-primitive": "2.1.11", + "@radix-ui/react-slot": "1.4.0", + "@radix-ui/react-use-controllable-state": "1.2.6", + "@radix-ui/react-use-layout-effect": "1.1.4", + "@radix-ui/react-visually-hidden": "1.2.12" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-use-callback-ref": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@radix-ui/react-use-callback-ref/-/react-use-callback-ref-1.1.4.tgz", + "integrity": "sha512-R6OUY2e2fA6Yn6s+VSx5KBV6Nx8LQEhu+cz7LCej18rQ1HLyg9PSC9jP/ZNx0o6FAIK9c0F1kHylzSxKsdlkrQ==", + "license": "MIT", + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-use-controllable-state": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@radix-ui/react-use-controllable-state/-/react-use-controllable-state-1.2.6.tgz", + "integrity": "sha512-uEQJGT97ZA/TgP/Hydw47lHu+/vQj6z/0jA+WeTbK1o9Rx45GImjpD0tc3W5ad3D6XTSR6e1yEO0FvGq6WQfVQ==", + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.1.7", + "@radix-ui/react-use-effect-event": "0.0.5", + "@radix-ui/react-use-layout-effect": "1.1.4" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-use-effect-event": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/@radix-ui/react-use-effect-event/-/react-use-effect-event-0.0.5.tgz", + "integrity": "sha512-7cshFL8HGS/7HEiHH+9kL9HBwp2sa9yX18Knwek6KYWmXwM7pegMgta2AXMQKI+rq3JnfSj9x8wYqFMTdG1Jgg==", + "license": "MIT", + "dependencies": { + "@radix-ui/react-use-layout-effect": "1.1.4" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-use-escape-keydown": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@radix-ui/react-use-escape-keydown/-/react-use-escape-keydown-1.1.5.tgz", + "integrity": "sha512-ge3ipobwSXTj4JyVtswQ7qZj0ZHdtbGuOno/LrgAAeSxtsJ6Vs4Gz5IkPH2bmqpjcLUFoqGhA/mueuIf63UXlA==", + "license": "MIT", + "dependencies": { + "@radix-ui/react-use-callback-ref": "1.1.4" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-use-is-hydrated": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@radix-ui/react-use-is-hydrated/-/react-use-is-hydrated-0.1.3.tgz", + "integrity": "sha512-umO/aJ+82CpOnhDZUTbILCQf7kU/g0iv+oGs/Q8jw7IkhWBzaEP4sA268PhFAJTFetbwp3ICc6ktpI4TqtxcIw==", + "license": "MIT", + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-use-layout-effect": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@radix-ui/react-use-layout-effect/-/react-use-layout-effect-1.1.4.tgz", + "integrity": "sha512-K20DkRkUwDnxEYMBPcg3Y6voLkEy5p5QQmszZgLngKKiC7dzBR/aEuK3w1qlx2JWDUNH6FluahYdgR3BP+QbYw==", + "license": "MIT", + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-use-previous": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@radix-ui/react-use-previous/-/react-use-previous-1.1.4.tgz", + "integrity": "sha512-XoSLhbRbqxFtgJoi2fNHA3C6pDlY34x508vUpUGoFZfvePfHXHbE1lC4FYFMnJWgiCRroSTw6fOsXQoVS9RwZg==", + "license": "MIT", + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-use-rect": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@radix-ui/react-use-rect/-/react-use-rect-1.1.4.tgz", + "integrity": "sha512-cSOCh6JlkmfjLyNcLiu2nB4v+nm+dkZ+Q5KHWk/soo4U7ZLiEQFKHK9/YmtBHjfCEaU43IBKQOc4/uJmCaiCTQ==", + "license": "MIT", + "dependencies": { + "@radix-ui/rect": "1.1.3" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-use-size": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@radix-ui/react-use-size/-/react-use-size-1.1.5.tgz", + "integrity": "sha512-V1McDQkMGzgivwqdu7u96APs7oi0Jvj9LTzgq3WWrDZqxWdAqU9yZnZQqk5OizGFR8badUQwZsrlao7MOlWYOA==", + "license": "MIT", + "dependencies": { + "@radix-ui/react-use-layout-effect": "1.1.4" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-visually-hidden": { + "version": "1.2.12", + "resolved": "https://registry.npmjs.org/@radix-ui/react-visually-hidden/-/react-visually-hidden-1.2.12.tgz", + "integrity": "sha512-/iPLVHRBzKWvekN+5xaDmXw80f+nleYYceomVORrGjuJe0LF2SCbSH4f/LG4hu32q92QSuPZx4hmSACYBVBfzQ==", + "license": "MIT", + "dependencies": { + "@radix-ui/react-primitive": "2.1.11" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/rect": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@radix-ui/rect/-/rect-1.1.3.tgz", + "integrity": "sha512-JtyZR+mqgBibTo8xea3B6ZRmzZiM/YeVBtUkas6zMuXjAlfIFIW2FgqeM9eLyvEaYX66vr6DJMK+4U6LV0KhNw==", + "license": "MIT" + }, + "node_modules/@rolldown/binding-android-arm-eabi": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm-eabi/-/binding-android-arm-eabi-1.2.13.tgz", + "integrity": "sha512-Vu/NICrgdRvUOeaJZIyB2FP63s6fO/4ud5l8dXmxDx9yDyn+mN0y+gsvsVviSli+T361Aqo0h46EuMoobrwawA==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-android-arm64": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.2.13.tgz", + "integrity": "sha512-6LEoIrGy5vvCd2boNnv2soPSUZj/PRvhp8R/t9KlX+mIZxThIE/ZqxrGXxmuNX0FuvQFvLdZr7S4HrYpYBVhEQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-darwin-arm64": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.2.13.tgz", + "integrity": "sha512-CaJSRzlQ6Q+zkDMVA9OkVxBjVoPRCDEE3v0FSJ9kIQBgRjFApA3Si4ijhbNVUji7ZJt+PfO0e46qy4nPInHUPA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-darwin-x64": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.2.13.tgz", + "integrity": "sha512-e4r340I5hxSzJkD3YJBxgzq/rJ3wwxwdLLb2FPt1Zpyem20nrQPT11DDEEkazwxaHumH8wpglsp/Ozgj/wT6mw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-freebsd-x64": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.2.13.tgz", + "integrity": "sha512-hoBWDZ4/K/mJKVMbsgUd1jfpA2DiOrJ54mpegObU9TBHBBrtX4FLIXJJQRDPZ/2Dn91GvPob+Z2hwKJzf4E5SQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm-gnueabihf": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.2.13.tgz", + "integrity": "sha512-oF9fZu3vTWnTiVAkDFxU9PJLt1nh20K9RRpuHsR7ZnE2L7XookBbDBVLojCVSLGbvtSlxeUNnjAj6DbNsKyzbg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm64-gnu": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.2.13.tgz", + "integrity": "sha512-DTpb/+jMiqWMPgphn4ksW1zW+XLJ6dJJ9FMvnIk9I291LhCctMPhMYJrP5t9p6C9qa3KXadDdUEZHBaPh3kNxQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm64-musl": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.2.13.tgz", + "integrity": "sha512-xU+Kvv9N2A3SY35zFh1FWWNjxbadE/BKeqnkXe7vScU4GZsw757BlVmDLITZEq8DPpk6m7uoDYkK7P+x/uU5Ow==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-ppc64-gnu": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.2.13.tgz", + "integrity": "sha512-XMk/hnhh25oQ756Lclb1Q11h4ll0xC0Esa5w4Vzp+mAE2S3AGJgeM0SonrIgY8fHhjarb6hcoTuwoFG0VVP2ig==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-s390x-gnu": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.2.13.tgz", + "integrity": "sha512-U1BoTHYmlywE2n3HUWjzZ+8EQsKr+OwpxYuDWaubx42tUL8QSL7nOqRz/NVHanibbFP3M1Rxuprz/wNcbMKjqw==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-x64-gnu": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.2.13.tgz", + "integrity": "sha512-J4cm80Pc6wEwV5AZ42o62sIQgDk+Y7R2s646jIwuvO+4V46QB58N4vVuMPWCBaNgursXLpmUWJV//WQAkPvHBQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-x64-musl": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.2.13.tgz", + "integrity": "sha512-W0euZS40U4V6JkmEnVCIX9mcsL6cbXQ4X8c2w+MMOIjFg68TXUW+u3RT+2e1t1pv9mg/EP3pDtK3POXdQ7Rxyw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-openharmony-arm64": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.2.13.tgz", + "integrity": "sha512-do/AF/4n9MRshia3a5aXoy8xM2c6mgfT6D7H/dY6my5z+hfCIR4ab7mk4IRj++nsEQpKy39kd0DQnDq+r692tw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-win32-arm64-msvc": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.2.13.tgz", + "integrity": "sha512-6FtUf2cJZobutJdxnGYX8z0vtbgqU0b2v8vfBhkXb9wp2MppMFtkunE+IaOntyi01rkIQoPW2GHABtfzsC0BRQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-win32-x64-msvc": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.2.13.tgz", + "integrity": "sha512-UKhFaZTeTcbKrb3iU82m17jVcPEAoqDkCN5MBqgPyZSwp/cQmib21crTS0DdH7T1B7wZRWEI89YQAOJMet5yhg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/pluginutils": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.1.tgz", + "integrity": "sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@tailwindcss/node": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/node/-/node-4.3.3.tgz", + "integrity": "sha512-/T8IKEsf9VTU6tLjgC7+sv2mOPtQxzE2jMw7u4Tt40Tx+QSZxpzh95/H6cMKoja9XuW7iMdLJYBB0o9G1CaAgg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/remapping": "^2.3.5", + "enhanced-resolve": "^5.24.1", + "jiti": "^2.7.0", + "lightningcss": "1.32.0", + "magic-string": "^0.30.21", + "source-map-js": "^1.2.1", + "tailwindcss": "4.3.3" + } + }, + "node_modules/@tailwindcss/oxide": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide/-/oxide-4.3.3.tgz", + "integrity": "sha512-krXjAikiaFSPaK/FkAQT5UTx3VormQaiZ5hBFlJZ9UFQGB/rwg1MZIhHAG9smMQRTdyJxP6Qt5MwMtdyU5FWrA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 20" + }, + "optionalDependencies": { + "@tailwindcss/oxide-android-arm64": "4.3.3", + "@tailwindcss/oxide-darwin-arm64": "4.3.3", + "@tailwindcss/oxide-darwin-x64": "4.3.3", + "@tailwindcss/oxide-freebsd-x64": "4.3.3", + "@tailwindcss/oxide-linux-arm-gnueabihf": "4.3.3", + "@tailwindcss/oxide-linux-arm64-gnu": "4.3.3", + "@tailwindcss/oxide-linux-arm64-musl": "4.3.3", + "@tailwindcss/oxide-linux-x64-gnu": "4.3.3", + "@tailwindcss/oxide-linux-x64-musl": "4.3.3", + "@tailwindcss/oxide-wasm32-wasi": "4.3.3", + "@tailwindcss/oxide-win32-arm64-msvc": "4.3.3", + "@tailwindcss/oxide-win32-x64-msvc": "4.3.3" + } + }, + "node_modules/@tailwindcss/oxide-android-arm64": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-android-arm64/-/oxide-android-arm64-4.3.3.tgz", + "integrity": "sha512-Y85A2gmPSkl5Ve5qR86GL4HT509cFqQh1aes9p3sSkyTPwt0Pppf3GkwGe4JPACcRYjgJIEhQgM6dBClnr0NYw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-darwin-arm64": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-darwin-arm64/-/oxide-darwin-arm64-4.3.3.tgz", + "integrity": "sha512-BiaWatpBcERQFDlOjRDpIVXuFK5PJez5SA4JMg6VYZdBYU+qKfV/vqjcIs+IYmtitf1xYQZTwXvU/8y4lfZUGw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-darwin-x64": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-darwin-x64/-/oxide-darwin-x64-4.3.3.tgz", + "integrity": "sha512-fAeUqfV5ndhxRwai8cXGzdLvul9utWOmeTkv69unv4ZXixjn61Z+p9lCWdwOwA3TYboG3BwdVuN/RDjhBRl0mw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-freebsd-x64": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-freebsd-x64/-/oxide-freebsd-x64-4.3.3.tgz", + "integrity": "sha512-iyf5bV6+wnAlflVeEy7R25dupxTNECZN5QMI0qNT6eT+EgaGdZcKhGkr5SdoaWiLJ3spLqIY9VCeSGrwmtg4kw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-linux-arm-gnueabihf": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm-gnueabihf/-/oxide-linux-arm-gnueabihf-4.3.3.tgz", + "integrity": "sha512-aAYUprJAJQWWbRrPvtjdroZ56Md+JM8pMiopS6xGEwDfLhqj+2ver2p4nU4Mb3CRqcMmNBjo8KkUgcxhkzVQGQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-linux-arm64-gnu": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm64-gnu/-/oxide-linux-arm64-gnu-4.3.3.tgz", + "integrity": "sha512-nDxldcEENOxZRzC2uu9jrutZdAAQtb+8WWDCSnWL1zvBk1+FN+x6MtDViPB5AJMfttVCUhehGWus3XBPgatM/w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-linux-arm64-musl": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm64-musl/-/oxide-linux-arm64-musl-4.3.3.tgz", + "integrity": "sha512-Md44bD6veX/PC5iyF8cDVnw4HBIANZepRZZ7a8DQOvkfo5WUBwcp6iAuCUz23u+4SUkhJlD3eL7hNdW8ezd/kA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-linux-x64-gnu": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-x64-gnu/-/oxide-linux-x64-gnu-4.3.3.tgz", + "integrity": "sha512-tx7us1muwOKAKWao2v/GaafFeQboE6aj88vC6ziN2NCGcRm8gWUhwjzg+YdVB1e4boAtdtma4L43onunI6NS4w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-linux-x64-musl": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-x64-musl/-/oxide-linux-x64-musl-4.3.3.tgz", + "integrity": "sha512-SJxX60smvHgasZoBy11dX6YRjXJFovwWBoedhbQPOBzgFWBHGB+TVPWB9BxzR7TTxU8FQZAI2AyiNCMzFm8Img==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-wasm32-wasi": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-wasm32-wasi/-/oxide-wasm32-wasi-4.3.3.tgz", + "integrity": "sha512-jx1+rPhY/5Ympkktd656HBWEBLxP7dH06losBLjjf5vgCODXvi9KhtftWcMIwTFIDqBr7cRnQkdLnAG+IOlGvQ==", + "bundleDependencies": [ + "@napi-rs/wasm-runtime", + "@emnapi/core", + "@emnapi/runtime", + "@tybys/wasm-util", + "@emnapi/wasi-threads", + "tslib" + ], + "cpu": [ + "wasm32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/core": "^1.11.1", + "@emnapi/runtime": "^1.11.1", + "@emnapi/wasi-threads": "^1.2.2", + "@napi-rs/wasm-runtime": "^1.1.4", + "@tybys/wasm-util": "^0.10.2", + "tslib": "^2.8.1" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@tailwindcss/oxide-win32-arm64-msvc": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-arm64-msvc/-/oxide-win32-arm64-msvc-4.3.3.tgz", + "integrity": "sha512-3rc292Ca2ceK6Ulcc/bAVnTs/3nDtoPhyEKlgPv+yQJQi/JS/AMJlqzxvlDacL1nekbrcf6bTqp/jV4qgnPxNQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-win32-x64-msvc": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-x64-msvc/-/oxide-win32-x64-msvc-4.3.3.tgz", + "integrity": "sha512-yJ0pwIVc/nYeGoV02WtsN8KYyLQv7kyI2wDnkezyJlGGjkd4QLwDGAwl47YpPJeuI0M0ObaXGSPjvWDPeTPggw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/vite": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/vite/-/vite-4.3.3.tgz", + "integrity": "sha512-yYU8cogLeSh/ms2jh8Fj7jaba/EWa7Ja6GoUqYZaraEuCI5YS6ms6ObZgjjedm+jm6XZjdNRWBpPP6Z86oOxcw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@tailwindcss/node": "4.3.3", + "@tailwindcss/oxide": "4.3.3", + "tailwindcss": "4.3.3" + }, + "peerDependencies": { + "vite": "^5.2.0 || ^6 || ^7 || ^8" + } + }, + "node_modules/@types/node": { + "version": "26.6.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-26.6.5.tgz", + "integrity": "sha512-uMzsv9stDdofIZBx4UGh4Z9ZgXnGC9seRDscilBcTHAeOFk67MZg/k9bWVfO+bk4qZmG+l52hRnLwUiH2LnJTg==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~8.9.0" + } + }, + "node_modules/@types/react": { + "version": "19.3.0", + "resolved": "https://registry.npmjs.org/@types/react/-/react-19.3.0.tgz", + "integrity": "sha512-N0rFCuH9YoxG9/m61l9MfpJKfmLOVU0em7ipIz6TRgSSkvReLB9vL85GB+yr8Bs5leqpvg96JSwF4ZS1s4viQg==", + "devOptional": true, + "license": "MIT", + "dependencies": { + "csstype": "^3.2.2" + } + }, + "node_modules/@types/react-dom": { + "version": "19.3.0", + "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-19.3.0.tgz", + "integrity": "sha512-ZI7bU42mZXXKHn/qNLEw2IrbiINU7X5+vfgdixBHkCNpYWXjKgfQ/P+uyGb5CjOLB9UcnTeg3rylQtV2hym44Q==", + "devOptional": true, + "license": "MIT", + "peerDependencies": { + "@types/react": "^19.3.0" + } + }, + "node_modules/@vitejs/plugin-react": { + "version": "6.1.2", + "resolved": "https://registry.npmjs.org/@vitejs/plugin-react/-/plugin-react-6.1.2.tgz", + "integrity": "sha512-fhJNGUdscQa4HkI0xFxwonWyhnVReCPDbXI7FH7jmzpnVCrFQI7PRrhWecO263610vOrs9tr2Y4xcf8uAdFxbw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@rolldown/pluginutils": "^1.0.1" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "peerDependencies": { + "@rolldown/plugin-babel": "^0.1.7 || ^0.2.0", + "babel-plugin-react-compiler": "^1.0.0", + "oxc-transform-react": "^0.152.0", + "vite": "^8.0.0" + }, + "peerDependenciesMeta": { + "@rolldown/plugin-babel": { + "optional": true + }, + "babel-plugin-react-compiler": { + "optional": true + }, + "oxc-transform-react": { + "optional": true + } + } + }, + "node_modules/aria-hidden": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/aria-hidden/-/aria-hidden-1.2.6.tgz", + "integrity": "sha512-ik3ZgC9dY/lYVVM++OISsaYDeg1tb0VtP5uL3ouh1koGOaUMDPpbFIei4JkFimWUFPn90sbMNMXQAIVOlnYKJA==", + "license": "MIT", + "dependencies": { + "tslib": "^2.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/attr-accept": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/attr-accept/-/attr-accept-4.0.0.tgz", + "integrity": "sha512-hmCnJClmeKNKlsBHgbM8yLZRiQZ4/20UXbLJb6OUT16eWcM5/xNZerr80a/zCYob768KIGq++aLrQNTuwPsIOQ==", + "license": "MIT", + "engines": { + "node": ">= 22" + } + }, + "node_modules/class-variance-authority": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/class-variance-authority/-/class-variance-authority-0.7.1.tgz", + "integrity": "sha512-Ka+9Trutv7G8M6WT6SeiRWz792K5qEqIGEGzXKhAE6xOWAY6pPH8U+9IY3oCMv6kqTmLsv7Xh/2w2RigkePMsg==", + "license": "Apache-2.0", + "dependencies": { + "clsx": "^2.1.1" + }, + "funding": { + "url": "https://polar.sh/cva" + } + }, + "node_modules/clsx": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz", + "integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/csstype": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz", + "integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==", + "devOptional": true, + "license": "MIT" + }, + "node_modules/detect-libc": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", + "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=8" + } + }, + "node_modules/detect-node-es": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/detect-node-es/-/detect-node-es-1.1.0.tgz", + "integrity": "sha512-ypdmJU/TbBby2Dxibuv7ZLW3Bs1QEmM7nHjEANfohJLvE0XVujisn1qPJcZxg+qDucsr+bP6fLD1rPS3AhJ7EQ==", + "license": "MIT" + }, + "node_modules/enhanced-resolve": { + "version": "5.26.0", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.26.0.tgz", + "integrity": "sha512-9vhedylFonb2YGogzUKX6+Ja72gOJbN1QHAqdrvqLwhdl/QWbKopzoUC9EbQNVsAns/bx/4uyqalrQAoy1IByw==", + "dev": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.2.4", + "tapable": "^2.3.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/file-selector": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/file-selector/-/file-selector-5.0.1.tgz", + "integrity": "sha512-v0g/PTeuQgvKCBrVRsfVudvwXlRHSWHEQkVgKawgCGHkEpKA1clp3Om5jvEVhz8G9W/mOYjJH9FhkH4C888PgQ==", + "license": "MIT", + "engines": { + "node": ">= 22" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/get-nonce": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-nonce/-/get-nonce-1.0.1.tgz", + "integrity": "sha512-FJhYRoDaiatfEkUK8HKlicmu/3SGFD51q3itKDGoSTysQJBnfOcxU5GxnhE1E6soB76MbT0MBtnKJuXyAx+96Q==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/iced-x86": { + "version": "1.21.0", + "resolved": "https://registry.npmjs.org/iced-x86/-/iced-x86-1.21.0.tgz", + "integrity": "sha512-zHK5/RREJbD7N2BfbeiHJciHbZKCSwI5c34wASV9/B8vNe+mjOzqK8RIabhMLmqHv3L6UvuFDlpdS/dqleQyeA==", + "license": "MIT" + }, + "node_modules/jiti": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/jiti/-/jiti-2.7.0.tgz", + "integrity": "sha512-AC/7JofJvZGrrneWNaEnJeOLUx+JlGt7tNa0wZiRPT4MY1wmfKjt2+6O2p2uz2+skll8OZZmJMNqeke7kKbNgQ==", + "dev": true, + "license": "MIT", + "bin": { + "jiti": "lib/jiti-cli.mjs" + } + }, + "node_modules/lightningcss": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.32.0.tgz", + "integrity": "sha512-NXYBzinNrblfraPGyrbPoD19C1h9lfI/1mzgWYvXUTe414Gz/X1FD2XBZSZM7rRTrMA8JL3OtAaGifrIKhQ5yQ==", + "dev": true, + "license": "MPL-2.0", + "dependencies": { + "detect-libc": "^2.0.3" + }, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + }, + "optionalDependencies": { + "lightningcss-android-arm64": "1.32.0", + "lightningcss-darwin-arm64": "1.32.0", + "lightningcss-darwin-x64": "1.32.0", + "lightningcss-freebsd-x64": "1.32.0", + "lightningcss-linux-arm-gnueabihf": "1.32.0", + "lightningcss-linux-arm64-gnu": "1.32.0", + "lightningcss-linux-arm64-musl": "1.32.0", + "lightningcss-linux-x64-gnu": "1.32.0", + "lightningcss-linux-x64-musl": "1.32.0", + "lightningcss-win32-arm64-msvc": "1.32.0", + "lightningcss-win32-x64-msvc": "1.32.0" + } + }, + "node_modules/lightningcss-android-arm64": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-android-arm64/-/lightningcss-android-arm64-1.32.0.tgz", + "integrity": "sha512-YK7/ClTt4kAK0vo6w3X+Pnm0D2cf2vPHbhOXdoNti1Ga0al1P4TBZhwjATvjNwLEBCnKvjJc2jQgHXH0NEwlAg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-darwin-arm64": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.32.0.tgz", + "integrity": "sha512-RzeG9Ju5bag2Bv1/lwlVJvBE3q6TtXskdZLLCyfg5pt+HLz9BqlICO7LZM7VHNTTn/5PRhHFBSjk5lc4cmscPQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-darwin-x64": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.32.0.tgz", + "integrity": "sha512-U+QsBp2m/s2wqpUYT/6wnlagdZbtZdndSmut/NJqlCcMLTWp5muCrID+K5UJ6jqD2BFshejCYXniPDbNh73V8w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-freebsd-x64": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.32.0.tgz", + "integrity": "sha512-JCTigedEksZk3tHTTthnMdVfGf61Fky8Ji2E4YjUTEQX14xiy/lTzXnu1vwiZe3bYe0q+SpsSH/CTeDXK6WHig==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm-gnueabihf": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.32.0.tgz", + "integrity": "sha512-x6rnnpRa2GL0zQOkt6rts3YDPzduLpWvwAF6EMhXFVZXD4tPrBkEFqzGowzCsIWsPjqSK+tyNEODUBXeeVHSkw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-gnu": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.32.0.tgz", + "integrity": "sha512-0nnMyoyOLRJXfbMOilaSRcLH3Jw5z9HDNGfT/gwCPgaDjnx0i8w7vBzFLFR1f6CMLKF8gVbebmkUN3fa/kQJpQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-musl": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.32.0.tgz", + "integrity": "sha512-UpQkoenr4UJEzgVIYpI80lDFvRmPVg6oqboNHfoH4CQIfNA+HOrZ7Mo7KZP02dC6LjghPQJeBsvXhJod/wnIBg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-gnu": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.32.0.tgz", + "integrity": "sha512-V7Qr52IhZmdKPVr+Vtw8o+WLsQJYCTd8loIfpDaMRWGUZfBOYEJeyJIkqGIDMZPwPx24pUMfwSxxI8phr/MbOA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-musl": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.32.0.tgz", + "integrity": "sha512-bYcLp+Vb0awsiXg/80uCRezCYHNg1/l3mt0gzHnWV9XP1W5sKa5/TCdGWaR/zBM2PeF/HbsQv/j2URNOiVuxWg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-win32-arm64-msvc": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.32.0.tgz", + "integrity": "sha512-8SbC8BR40pS6baCM8sbtYDSwEVQd4JlFTOlaD3gWGHfThTcABnNDBda6eTZeqbofalIJhFx0qKzgHJmcPTnGdw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-win32-x64-msvc": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.32.0.tgz", + "integrity": "sha512-Amq9B/SoZYdDi1kFrojnoqPLxYhQ4Wo5XiL8EVJrVsB8ARoC1PWW6VGtT0WKCemjy8aC+louJnjS7U18x3b06Q==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lucide-react": { + "version": "1.54.0", + "resolved": "https://registry.npmjs.org/lucide-react/-/lucide-react-1.54.0.tgz", + "integrity": "sha512-kVmnVCBoLztTGe3S76xu8utwxijRLOinknNq9e8btZ0R2fm6WCgxY+weaLiA50odo/yi+apm/4B2A/LsFZhTrw==", + "license": "ISC", + "peerDependencies": { + "@types/react": "*", + "react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/magic-string": { + "version": "0.30.21", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", + "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.5" + } + }, + "node_modules/nanoid": { + "version": "3.3.20", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.20.tgz", + "integrity": "sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/postcss": { + "version": "8.5.29", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.29.tgz", + "integrity": "sha512-49cGhUbXj8Qenv0iTMxA1cFBzxXoctpC9Ujd77t1WcbJIr6nF/eI7g/8MgxrYldFRuAXvja7xQRwavoW7kgrxQ==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.19", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.2" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/radix-ui": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/radix-ui/-/radix-ui-1.7.0.tgz", + "integrity": "sha512-x+z5TV2v6u0QpAQ4dQfNMcvtIdSQ1Op2oqBEyfDXjNldRZbMTP+hcjr5Iie31bep81Axeioa+70Ww7pZDzTEQQ==", + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.1.7", + "@radix-ui/react-accessible-icon": "1.1.16", + "@radix-ui/react-accordion": "1.2.21", + "@radix-ui/react-alert-dialog": "1.1.24", + "@radix-ui/react-arrow": "1.1.16", + "@radix-ui/react-aspect-ratio": "1.1.16", + "@radix-ui/react-avatar": "1.2.7", + "@radix-ui/react-checkbox": "1.3.12", + "@radix-ui/react-collapsible": "1.1.21", + "@radix-ui/react-collection": "1.1.16", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.2.2", + "@radix-ui/react-context-menu": "2.3.8", + "@radix-ui/react-dialog": "1.2.0", + "@radix-ui/react-direction": "1.1.5", + "@radix-ui/react-dismissable-layer": "1.1.20", + "@radix-ui/react-dropdown-menu": "2.1.25", + "@radix-ui/react-focus-guards": "1.1.6", + "@radix-ui/react-focus-scope": "1.2.0", + "@radix-ui/react-form": "0.2.0", + "@radix-ui/react-hover-card": "1.1.24", + "@radix-ui/react-label": "2.1.16", + "@radix-ui/react-menu": "2.1.25", + "@radix-ui/react-menubar": "1.1.25", + "@radix-ui/react-navigation-menu": "1.3.0", + "@radix-ui/react-one-time-password-field": "0.1.17", + "@radix-ui/react-password-toggle-field": "0.1.12", + "@radix-ui/react-popover": "1.2.0", + "@radix-ui/react-popper": "1.3.8", + "@radix-ui/react-portal": "1.1.18", + "@radix-ui/react-presence": "1.1.11", + "@radix-ui/react-primitive": "2.1.11", + "@radix-ui/react-progress": "1.1.17", + "@radix-ui/react-radio-group": "1.4.8", + "@radix-ui/react-roving-focus": "1.1.20", + "@radix-ui/react-scroll-area": "1.3.0", + "@radix-ui/react-select": "2.3.8", + "@radix-ui/react-separator": "1.1.16", + "@radix-ui/react-slider": "1.5.0", + "@radix-ui/react-slot": "1.4.0", + "@radix-ui/react-switch": "1.3.8", + "@radix-ui/react-tabs": "1.1.22", + "@radix-ui/react-toast": "1.2.24", + "@radix-ui/react-toggle": "1.1.19", + "@radix-ui/react-toggle-group": "1.1.20", + "@radix-ui/react-toolbar": "1.1.20", + "@radix-ui/react-tooltip": "1.3.0", + "@radix-ui/react-use-callback-ref": "1.1.4", + "@radix-ui/react-use-controllable-state": "1.2.6", + "@radix-ui/react-use-effect-event": "0.0.5", + "@radix-ui/react-use-escape-keydown": "1.1.5", + "@radix-ui/react-use-is-hydrated": "0.1.3", + "@radix-ui/react-use-layout-effect": "1.1.4", + "@radix-ui/react-use-size": "1.1.5", + "@radix-ui/react-visually-hidden": "1.2.12" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/react": { + "version": "19.3.0", + "resolved": "https://registry.npmjs.org/react/-/react-19.3.0.tgz", + "integrity": "sha512-E8LUcbtBWt20bbl2YoHfx4ZDBdxVTfOKtCZn9cDSJ4l6/nuoApcpIBcj47t2wZoVX8g2ZHuMHbiShgCR1T5Sog==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/react-dom": { + "version": "19.3.0", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.3.0.tgz", + "integrity": "sha512-JDk8dgif51OjFoDE70+OT9ICyYr+69HlmihNwp1+Nsfbna3t5sIiCa9ZJktDmQ4/1b/rn26hIAR2uYXDMr5r0Q==", + "license": "MIT", + "dependencies": { + "scheduler": "^0.28.0" + }, + "peerDependencies": { + "react": "^19.3.0" + } + }, + "node_modules/react-dropzone": { + "version": "20.1.2", + "resolved": "https://registry.npmjs.org/react-dropzone/-/react-dropzone-20.1.2.tgz", + "integrity": "sha512-gj2m31ZmYOZjTuW6CDfx38/WW2JlbuQ/X2Il8cOwIWa7Znp7vQSPJFtRfDbAjusBuoXzAYktI+r2R6iKMaRTPw==", + "license": "MIT", + "dependencies": { + "attr-accept": "^4.0.0", + "file-selector": "^5.0.0" + }, + "engines": { + "node": ">= 22" + }, + "peerDependencies": { + "@types/react": "*", + "react": ">= 18" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/react-remove-scroll": { + "version": "2.7.2", + "resolved": "https://registry.npmjs.org/react-remove-scroll/-/react-remove-scroll-2.7.2.tgz", + "integrity": "sha512-Iqb9NjCCTt6Hf+vOdNIZGdTiH1QSqr27H/Ek9sv/a97gfueI/5h1s3yRi1nngzMUaOOToin5dI1dXKdXiF+u0Q==", + "license": "MIT", + "dependencies": { + "react-remove-scroll-bar": "^2.3.7", + "react-style-singleton": "^2.2.3", + "tslib": "^2.1.0", + "use-callback-ref": "^1.3.3", + "use-sidecar": "^1.1.3" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/react-remove-scroll-bar": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/react-remove-scroll-bar/-/react-remove-scroll-bar-2.3.8.tgz", + "integrity": "sha512-9r+yi9+mgU33AKcj6IbT9oRCO78WriSj6t/cF8DWBZJ9aOGPOTEDvdUDz1FwKim7QXWwmHqtdHnRJfhAxEG46Q==", + "license": "MIT", + "dependencies": { + "react-style-singleton": "^2.2.2", + "tslib": "^2.0.0" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/react-style-singleton": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/react-style-singleton/-/react-style-singleton-2.2.3.tgz", + "integrity": "sha512-b6jSvxvVnyptAiLjbkWLE/lOnR4lfTtDAl+eUC7RZy+QQWc6wRzIV2CE6xBuMmDxc2qIihtDCZD5NPOFl7fRBQ==", + "license": "MIT", + "dependencies": { + "get-nonce": "^1.0.0", + "tslib": "^2.0.0" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/rolldown": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.13.tgz", + "integrity": "sha512-/5apOkwWxtACcQtZ5WlrAsKS4JwXVThQPJZ3RqIruRY9UG9M8e0VlXN068xum/JRKA4aIUoJ13ghe/kGCvidiQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@oxc-project/types": "=0.153.0", + "@rolldown/pluginutils": "^1.0.0" + }, + "bin": { + "rolldown": "bin/cli.mjs" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "optionalDependencies": { + "@rolldown/binding-android-arm-eabi": "1.2.13", + "@rolldown/binding-android-arm64": "1.2.13", + "@rolldown/binding-darwin-arm64": "1.2.13", + "@rolldown/binding-darwin-x64": "1.2.13", + "@rolldown/binding-freebsd-x64": "1.2.13", + "@rolldown/binding-linux-arm-gnueabihf": "1.2.13", + "@rolldown/binding-linux-arm64-gnu": "1.2.13", + "@rolldown/binding-linux-arm64-musl": "1.2.13", + "@rolldown/binding-linux-ppc64-gnu": "1.2.13", + "@rolldown/binding-linux-s390x-gnu": "1.2.13", + "@rolldown/binding-linux-x64-gnu": "1.2.13", + "@rolldown/binding-linux-x64-musl": "1.2.13", + "@rolldown/binding-openharmony-arm64": "1.2.13", + "@rolldown/binding-win32-arm64-msvc": "1.2.13", + "@rolldown/binding-win32-x64-msvc": "1.2.13" + } + }, + "node_modules/scheduler": { + "version": "0.28.0", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.28.0.tgz", + "integrity": "sha512-juorfCmIkIw8tT+p5BXSm6PJjQF/ycEYmKyzURCIt/RaZIhL+PulbQ9Yu2z1HdOJDdqDTlxA1+xKBmHXJsczAw==", + "license": "MIT" + }, + "node_modules/source-map-js": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.2.tgz", + "integrity": "sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/tailwind-merge": { + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/tailwind-merge/-/tailwind-merge-3.7.0.tgz", + "integrity": "sha512-XPPUyAc+cvspz3lHTcR/QgPfW2A0lv/xQNIjX3HGhLR+Nq2lHaLq5MtTesHn8GUr3W3DguT2KT5x3NVgRtYwmA==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/dcastil" + } + }, + "node_modules/tailwindcss": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.3.3.tgz", + "integrity": "sha512-gOhV3P7ufE62QDGg1zVaTgCR+EtPv92k2nIhVcVKcLmxT1sUBsQGhnZj175j+MqRt4zLF7ic+sCYjfhxMxj7YQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/tapable": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.3.3.tgz", + "integrity": "sha512-uxc/zpqFg6x7C8vOE7lh6Lbda8eEL9zmVm/PLeTPBRhh1xCgdWaQ+J1CUieGpIfm2HdtsUpRv+HshiasBMcc6A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + } + }, + "node_modules/tinyglobby": { + "version": "0.2.17", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz", + "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.4" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "license": "0BSD" + }, + "node_modules/tw-animate-css": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/tw-animate-css/-/tw-animate-css-1.4.0.tgz", + "integrity": "sha512-7bziOlRqH0hJx80h/3mbicLW7o8qLsH5+RaLR2t+OHM3D0JlWGODQKQ4cxbK7WlvmUxpcj6Kgu6EKqjrGFe3QQ==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/Wombosvideo" + } + }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "8.9.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-8.9.0.tgz", + "integrity": "sha512-KTDyRTYX8sWmKXAikPHHSyc63CRPETMctyjKFupcC6OBLXT3xsN0e9aF7m+mIXutFWpUXuedtowG7iLOzp0kQg==", + "dev": true, + "license": "MIT" + }, + "node_modules/use-callback-ref": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/use-callback-ref/-/use-callback-ref-1.3.3.tgz", + "integrity": "sha512-jQL3lRnocaFtu3V00JToYz/4QkNWswxijDaCVNZRiRTO3HQDLsdu1ZtmIUvV4yPp+rvWm5j0y0TG/S61cuijTg==", + "license": "MIT", + "dependencies": { + "tslib": "^2.0.0" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/use-sidecar": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/use-sidecar/-/use-sidecar-1.1.3.tgz", + "integrity": "sha512-Fedw0aZvkhynoPYlA5WXrMCAMm+nSWdZt6lzJQ7Ok8S6Q+VsHmHpRWndVRJ8Be0ZbkfPc5LRYH+5XrzXcEeLRQ==", + "license": "MIT", + "dependencies": { + "detect-node-es": "^1.1.0", + "tslib": "^2.0.0" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/vite": { + "version": "8.3.4", + "resolved": "https://registry.npmjs.org/vite/-/vite-8.3.4.tgz", + "integrity": "sha512-IftLE8phJhdNRIGNEV4JCCvfNScoZQVfcXaN8TQropWGJtOHcu+iAB9pHcuGvmEb/kddw0LBe/jS8ztdC6xdiQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "lightningcss": "^1.33.0", + "picomatch": "^4.0.7", + "postcss": "^8.5.29", + "rolldown": "~1.2.12", + "tinyglobby": "^0.2.17" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^20.19.0 || >=22.12.0", + "@vitejs/devtools": "^0.7.1", + "esbuild": "^0.27.0 || ^0.28.0", + "jiti": ">=1.21.0", + "less": "^4.0.0", + "sass": "^1.70.0", + "sass-embedded": "^1.70.0", + "stylus": ">=0.54.8", + "sugarss": "^5.0.0", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "@vitejs/devtools": { + "optional": true + }, + "esbuild": { + "optional": true + }, + "jiti": { + "optional": true + }, + "less": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + }, + "node_modules/vite/node_modules/lightningcss": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.33.0.tgz", + "integrity": "sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==", + "dev": true, + "license": "MPL-2.0", + "dependencies": { + "detect-libc": "^2.0.3" + }, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + }, + "optionalDependencies": { + "lightningcss-android-arm64": "1.33.0", + "lightningcss-darwin-arm64": "1.33.0", + "lightningcss-darwin-x64": "1.33.0", + "lightningcss-freebsd-x64": "1.33.0", + "lightningcss-linux-arm-gnueabihf": "1.33.0", + "lightningcss-linux-arm64-gnu": "1.33.0", + "lightningcss-linux-arm64-musl": "1.33.0", + "lightningcss-linux-x64-gnu": "1.33.0", + "lightningcss-linux-x64-musl": "1.33.0", + "lightningcss-win32-arm64-msvc": "1.33.0", + "lightningcss-win32-x64-msvc": "1.33.0" + } + }, + "node_modules/vite/node_modules/lightningcss-android-arm64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-android-arm64/-/lightningcss-android-arm64-1.33.0.tgz", + "integrity": "sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/vite/node_modules/lightningcss-darwin-arm64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.33.0.tgz", + "integrity": "sha512-Sciaz8eenNTKn9b3t7+xr0ipTp9YxKQY4npwQ3mrRuL0BAVHBLyZxofhaKBAVtzmtRZ/zTyo0/to4B1uWG/Djg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/vite/node_modules/lightningcss-darwin-x64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.33.0.tgz", + "integrity": "sha512-Z5UPAxzrjlWNNyGy6i65cJzzvgJ5D3T6wMvs+gWpY9d7qRhANrxqAp6LhxIgZhWEw18RfJTGcRxjuLIBr+m8XQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/vite/node_modules/lightningcss-freebsd-x64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.33.0.tgz", + "integrity": "sha512-QQM/Ti/hQajJwCY+RiWuCZ9sdtI/XQk7nDK5vC8kkdwixezOlDgvDx7+RT+QjK6FcFT4MpsuoBnHIo/O3StRRg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/vite/node_modules/lightningcss-linux-arm-gnueabihf": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.33.0.tgz", + "integrity": "sha512-N7FVBe6iS24MlM6R/4RBTxGhQheZGs7tiQ9U32UtF75NzP5Q7xWPRqLBCKxlRQRk3rY1jCIPLzx7WzOhuUIRLQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/vite/node_modules/lightningcss-linux-arm64-gnu": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.33.0.tgz", + "integrity": "sha512-j2v/itmy4HlNxlc6voKXYgBqNi0Ng2LShg4z7GufpEgs05P+2suBVyi9I6YHq5uoVFx9ETin3eCEhLVyXGQnKg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/vite/node_modules/lightningcss-linux-arm64-musl": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.33.0.tgz", + "integrity": "sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/vite/node_modules/lightningcss-linux-x64-gnu": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.33.0.tgz", + "integrity": "sha512-ar+Ju7LmcN0Jo4FpL4hpFybwNG9/3A/Br5KW2n2jyODg3MEZXaDYADdemoNS+BDNfMgKvylJLj4S5tyRActuAg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/vite/node_modules/lightningcss-linux-x64-musl": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.33.0.tgz", + "integrity": "sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/vite/node_modules/lightningcss-win32-arm64-msvc": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.33.0.tgz", + "integrity": "sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/vite/node_modules/lightningcss-win32-x64-msvc": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.33.0.tgz", + "integrity": "sha512-OlEICDx/Xl0FqSp4bry8zFnCvGpig3Gl4gCquvYwHuqJKEC1+n9NgDniFvqHGmMv1ZkqDJrDqKKSykTDX+ehuA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/ws": { + "version": "8.22.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.22.0.tgz", + "integrity": "sha512-Ydggc987+RO0AnWtZ/7Wq9FtNvcrL1b/RO0ud9mWjUPgDrsAAwQSF51sm2hm1XofbU/4jkpGEsLFsZZxU+1DOg==", + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..72e5626 --- /dev/null +++ b/package.json @@ -0,0 +1,49 @@ +{ + "name": "cheatspecter", + "version": "0.3.0", + "private": true, + "description": "Browser-based real-time modding tool for jailbroken PS5 consoles running a ps5debug payload.", + "license": "GPL-3.0-only", + "type": "module", + "engines": { + "node": ">=20.19" + }, + "scripts": { + "build": "vite build", + "prestart": "vite build", + "start": "node bridge/server.mjs", + "predemo": "vite build", + "demo": "node bridge/server.mjs --demo", + "dev": "node scripts/dev.mjs", + "typecheck": "tsc --noEmit", + "test": "node --test \"test/*.test.mjs\"", + "payload:host": "vite build && node scripts/build-payload.mjs host", + "payload": "vite build && node scripts/build-payload.mjs ps5", + "payload:send": "node scripts/send-payload.mjs", + "mcp": "node scripts/build-mcp.mjs" + }, + "dependencies": { + "@radix-ui/react-use-controllable-state": "^1.2.6", + "class-variance-authority": "^0.7.1", + "clsx": "^2.1.1", + "iced-x86": "^1.21.0", + "lucide-react": "^1.54.0", + "radix-ui": "^1.7.0", + "react": "^19.3.0", + "react-dom": "^19.3.0", + "react-dropzone": "^20.1.2", + "tailwind-merge": "^3.7.0", + "tw-animate-css": "^1.4.0", + "ws": "^8.18.0" + }, + "devDependencies": { + "@tailwindcss/vite": "^4.3.3", + "@types/node": "^26.6.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.1.2", + "tailwindcss": "^4.3.3", + "typescript": "^5.6.0", + "vite": "^8.3.4" + } +} diff --git a/payload/README.md b/payload/README.md new file mode 100644 index 0000000..6092d9e --- /dev/null +++ b/payload/README.md @@ -0,0 +1,74 @@ +# On-console payload + +`cheatspecter.elf` runs on the PS5 and removes the computer from the picture. +It serves the web app and bridges it to the debugger, so any phone or laptop +on the network just opens `http://:8744`. + +**Status: builds and passes its tests on a computer; not yet run on a real +PS5.** The same source is compiled natively and exercised against the mock +console (`test/payload.test.mjs`): serving the app, the WebSocket handshake, +large transfers both ways, several connections at once, a missing debugger, +and cross-site rejection. What that cannot show is how it behaves under the +console's own loader and network stack. + +## Use it + +Send `cheatspecter-v.elf` if you use a payload manager: it reads the +version from the file name and shows it next to the payload. `cheatspecter.elf` +is the same build under a fixed name, for scripts. + +1. Load **ps5debug-NG** on the console as usual. +2. Send `payload/cheatspecter.elf` to your ELF loader, the same way you load + any other payload. From this folder: + + ```sh + npm run payload:send -- 192.168.1.20 # loader port 9021 by default + ``` + +3. A notification on the TV shows the address to open. + +It has to be sent again after each reboot, like any payload. Sending it twice +is harmless: the second copy sees the port is taken, says so, and exits. + +## What it does + +| Request | Behaviour | +| --- | --- | +| `GET /`, `/assets/*`, `/ghost.svg` | The web app, embedded in the ELF and served gzip-compressed. | +| `GET /api/info` | `{"mode":"console","version":"..."}`. The app sees this and skips the "find your PS5" screen. | +| `WS /ws` | Opens a TCP connection to `127.0.0.1:744` and relays binary frames both ways, unchanged. One WebSocket is one TCP connection. | +| `GET /api/library` | Installed titles: `{"titles":[{"id","meta":"json"\|"sfo","size","path"}]}`. `meta` is which metadata file the title has (`param.json` = PS5, `param.sfo` = PS4). | +| `GET /api/appmeta//<param.json\|param.sfo\|icon0.png>` | The system's own metadata file for a title, untouched. The web app reads the name from it. | +| `POST /api/launch/<title id>` | Closes the running game, if any, and starts this one. | +| `GET /api/tables/<title id>` | Which game versions have a saved cheat file. | +| `GET`, `PUT /api/tables/<title id>/<version>` | The user's cheats for that game version, stored as `/data/cheatspecter/cheats/<title id>-<version>.cspecter`. | +| `WS /events` | Debugger stop reports. The payload listens on `127.0.0.1:755`, where the debugger connects when something attaches, and forwards what arrives. | + +It is deliberately thin. All protocol knowledge and file parsing stay in the +web app, and ps5debug-NG keeps doing the kernel work. + +WebSocket upgrades, launches and file saves are refused when the `Origin` host +differs from `Host`, so another web page cannot drive the console through a +visitor's browser. Title IDs and versions are checked against a strict pattern +before they are used in a path. + +The library is built from the system's metadata folders +(`/system_data/priv/appmeta`, `/user/appmeta`). Sizes are the files found under +`/user/app`, `/user/patch`, the same folders on `/mnt/ext0` and `/mnt/ext1`, and +`/system_ex/app`, where game folders kept elsewhere are mounted. A title with +none of those is listed without a size; one with more than 200,000 files is +marked `partial`. + +## Build it + +```sh +npm run payload:host # for this computer; then: CS_PORT=8745 CS_DEBUGGER_PORT=7440 payload/build/cheatspecter-host +PS5_PAYLOAD_SDK=/opt/ps5-payload-sdk npm run payload # cheatspecter.elf +``` + +Both embed whatever `npm run build` produced, so the ELF needs rebuilding +after any change to the web app. The PS5 build needs +[ps5-payload-sdk](https://github.com/ps5-payload-dev/sdk) with clang and lld. + +`src/main.c` is the whole thing: an HTTP server, a WebSocket relay with one +thread per direction, and SHA-1 and Base64 for the handshake. diff --git a/payload/src/assets.h b/payload/src/assets.h new file mode 100644 index 0000000..b2ea549 --- /dev/null +++ b/payload/src/assets.h @@ -0,0 +1,19 @@ +/* Web app files embedded in the payload. Generated by scripts/embed-assets.mjs. */ +#ifndef CS_ASSETS_H +#define CS_ASSETS_H + +#include <stddef.h> + +struct asset { + const char *path; /* "/index.html" */ + const char *mime; + const unsigned char *data; /* gzip-compressed */ + size_t size; + int immutable; /* content-hashed name: cache forever */ +}; + +extern const struct asset CS_ASSETS[]; +extern const int CS_ASSET_COUNT; +extern const char CS_VERSION[]; + +#endif diff --git a/payload/src/main.c b/payload/src/main.c new file mode 100644 index 0000000..ddf1747 --- /dev/null +++ b/payload/src/main.c @@ -0,0 +1,1426 @@ +/* SPDX-License-Identifier: GPL-3.0-only + * + * CheatSpecter on-console payload. + * + * A small HTTP server that runs on the PS5 and does two things: + * - serves the CheatSpecter web app (embedded, gzip-compressed); + * - bridges a WebSocket at /ws to the debugger's TCP port on this console, + * byte for byte, because browsers cannot open raw TCP sockets; + * - listens on TCP 755, where the debugger reports breakpoint and watchpoint + * stops to whoever attached, and forwards those reports to WebSockets + * opened at /events; + * - keeps the user's own cheat files (/api/tables/<title id>/<version>, + * stored as /data/cheatspecter/cheats/<title id>-<version>.cspecter); + * - answers three questions the debugger cannot: which games are installed + * (/api/library), what they are called (/api/appmeta/...), and "start this + * one" (POST /api/launch/<title id>). + * + * It is deliberately thin. All protocol knowledge and all file parsing live in + * the web app; ps5debug-NG keeps doing the kernel work. + * + * The same file builds as a normal program for testing on a computer + * (`npm run payload:host`), where CS_PORT and CS_DEBUGGER_PORT can point it at the mock + * and CS_ROOT at a folder standing in for the console's file system. + */ + +#include <arpa/inet.h> +#include <dirent.h> +#include <errno.h> +#include <netinet/in.h> +#include <netinet/tcp.h> +#include <pthread.h> +#include <signal.h> +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <strings.h> +#include <sys/socket.h> +#include <sys/stat.h> +#include <sys/time.h> +#include <sys/types.h> +#include <time.h> +#include <unistd.h> + +#include "assets.h" + +#define DEFAULT_PORT 8744 +#define DEFAULT_DEBUGGER_PORT 744 +#define DEFAULT_EVENT_PORT 755 +#define MAX_EVENT_SUBSCRIBERS 16 +#define HEADER_MAX 8192 +#define RELAY_CHUNK 65536 + +#ifndef MSG_NOSIGNAL +#define MSG_NOSIGNAL 0 +#endif + +static int g_port = DEFAULT_PORT; +static int g_debugger_port = DEFAULT_DEBUGGER_PORT; +static int g_event_port = DEFAULT_EVENT_PORT; +static int g_events_ok = 0; +/* Prefix for every console path. Empty on the console; a test folder on a computer. */ +static const char *g_root = ""; + +/* ---- platform ------------------------------------------------------------ */ + +#ifdef __PROSPERO__ +typedef struct notify_request { + char useless1[45]; + char message[3075]; +} notify_request_t; + +int sceKernelSendNotificationRequest(int, notify_request_t *, size_t, int); + +static void notify(const char *text) { + notify_request_t req; + memset(&req, 0, sizeof req); + snprintf(req.message, sizeof req.message, "%s", text); + sceKernelSendNotificationRequest(0, &req, sizeof req, 0); +} +#else +static void notify(const char *text) { + fprintf(stderr, "[cheatspecter] %s\n", text); +} +#endif + +/* ---- socket helpers ------------------------------------------------------ */ + +static int write_all(int fd, const void *buf, size_t len) { + const unsigned char *p = buf; + while (len > 0) { + ssize_t n = send(fd, p, len, MSG_NOSIGNAL); + if (n < 0) { + if (errno == EINTR) continue; + return -1; + } + if (n == 0) return -1; + p += n; + len -= (size_t)n; + } + return 0; +} + +static int read_full(int fd, void *buf, size_t len) { + unsigned char *p = buf; + while (len > 0) { + ssize_t n = recv(fd, p, len, 0); + if (n < 0) { + if (errno == EINTR) continue; + return -1; + } + if (n == 0) return -1; + p += n; + len -= (size_t)n; + } + return 0; +} + +static void set_nodelay(int fd) { + int one = 1; + setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &one, sizeof one); +#ifdef SO_NOSIGPIPE + setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, &one, sizeof one); +#endif +} + +/* ---- SHA-1 and Base64, for the WebSocket handshake only --------------------- */ + +static uint32_t rol32(uint32_t x, int n) { + return (x << n) | (x >> (32 - n)); +} + +static void sha1(const unsigned char *data, size_t len, unsigned char out[20]) { + uint32_t h0 = 0x67452301u, h1 = 0xEFCDAB89u, h2 = 0x98BADCFEu, h3 = 0x10325476u, h4 = 0xC3D2E1F0u; + size_t total = ((len + 8) / 64 + 1) * 64; + unsigned char *msg = calloc(1, total); + if (!msg) { + memset(out, 0, 20); + return; + } + memcpy(msg, data, len); + msg[len] = 0x80; + uint64_t bits = (uint64_t)len * 8; + for (int i = 0; i < 8; i++) msg[total - 1 - i] = (unsigned char)(bits >> (8 * i)); + + for (size_t off = 0; off < total; off += 64) { + uint32_t w[80]; + for (int i = 0; i < 16; i++) { + w[i] = ((uint32_t)msg[off + 4 * i] << 24) | ((uint32_t)msg[off + 4 * i + 1] << 16) | + ((uint32_t)msg[off + 4 * i + 2] << 8) | (uint32_t)msg[off + 4 * i + 3]; + } + for (int i = 16; i < 80; i++) w[i] = rol32(w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16], 1); + uint32_t a = h0, b = h1, c = h2, d = h3, e = h4; + for (int i = 0; i < 80; i++) { + uint32_t f, k; + if (i < 20) { + f = (b & c) | (~b & d); + k = 0x5A827999u; + } else if (i < 40) { + f = b ^ c ^ d; + k = 0x6ED9EBA1u; + } else if (i < 60) { + f = (b & c) | (b & d) | (c & d); + k = 0x8F1BBCDCu; + } else { + f = b ^ c ^ d; + k = 0xCA62C1D6u; + } + uint32_t t = rol32(a, 5) + f + e + k + w[i]; + e = d; + d = c; + c = rol32(b, 30); + b = a; + a = t; + } + h0 += a; + h1 += b; + h2 += c; + h3 += d; + h4 += e; + } + free(msg); + uint32_t h[5] = {h0, h1, h2, h3, h4}; + for (int i = 0; i < 5; i++) { + out[4 * i] = (unsigned char)(h[i] >> 24); + out[4 * i + 1] = (unsigned char)(h[i] >> 16); + out[4 * i + 2] = (unsigned char)(h[i] >> 8); + out[4 * i + 3] = (unsigned char)h[i]; + } +} + +/* `out` needs room for 4 * ceil(len / 3) + 1 bytes. */ +static void base64(const unsigned char *in, size_t len, char *out) { + static const char tbl[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + size_t o = 0; + for (size_t i = 0; i < len; i += 3) { + uint32_t v = (uint32_t)in[i] << 16; + if (i + 1 < len) v |= (uint32_t)in[i + 1] << 8; + if (i + 2 < len) v |= in[i + 2]; + out[o++] = tbl[(v >> 18) & 63]; + out[o++] = tbl[(v >> 12) & 63]; + out[o++] = i + 1 < len ? tbl[(v >> 6) & 63] : '='; + out[o++] = i + 2 < len ? tbl[v & 63] : '='; + } + out[o] = 0; +} + +/* ---- HTTP ------------------------------------------------------------------ */ + +/* + * Reads the request head into buf (NUL-terminated). Returns 0 on success and + * sets *got to how much was read, which can run past the head into the body. + */ +static int read_head(int fd, char *buf, size_t cap, size_t *got) { + size_t len = 0; + while (len + 1 < cap) { + ssize_t n = recv(fd, buf + len, cap - 1 - len, 0); + if (n < 0 && errno == EINTR) continue; + if (n <= 0) return -1; + len += (size_t)n; + buf[len] = 0; + if (strstr(buf, "\r\n\r\n")) { + *got = len; + return 0; + } + } + return -1; +} + +/* Copies the value of a header (case-insensitive name) into out. Returns 1 if found. */ +static int header_value(const char *head, const char *name, char *out, size_t cap) { + size_t nlen = strlen(name); + const char *p = head; + while ((p = strstr(p, "\r\n")) != NULL) { + p += 2; + if (strncasecmp(p, name, nlen) == 0 && p[nlen] == ':') { + p += nlen + 1; + while (*p == ' ' || *p == '\t') p++; + size_t i = 0; + while (p[i] && p[i] != '\r' && p[i] != '\n' && i + 1 < cap) { + out[i] = p[i]; + i++; + } + while (i > 0 && (out[i - 1] == ' ' || out[i - 1] == '\t')) i--; + out[i] = 0; + return 1; + } + } + out[0] = 0; + return 0; +} + +static void send_simple(int fd, const char *status, const char *type, const char *body) { + char head[512]; + size_t blen = strlen(body); + int n = snprintf(head, sizeof head, + "HTTP/1.1 %s\r\nContent-Type: %s\r\nContent-Length: %zu\r\nCache-Control: no-store\r\nConnection: close\r\n\r\n", + status, type, blen); + if (n > 0 && write_all(fd, head, (size_t)n) == 0) write_all(fd, body, blen); +} + +static void send_asset(int fd, const struct asset *a, int head_only) { + char head[512]; + int n = snprintf(head, sizeof head, + "HTTP/1.1 200 OK\r\nContent-Type: %s\r\nContent-Encoding: gzip\r\nContent-Length: %zu\r\n" + "Cache-Control: %s\r\nConnection: close\r\n\r\n", + a->mime, a->size, a->immutable ? "public, max-age=31536000, immutable" : "no-cache"); + if (n > 0 && write_all(fd, head, (size_t)n) == 0 && !head_only) write_all(fd, a->data, a->size); +} + +/* + * A page from another site must not be able to drive the debugger through a + * visitor's browser, so the WebSocket is only accepted from the app this + * server itself served: the Origin's host has to equal the Host header. + * Requests without an Origin are not from a browser page and are allowed. + */ +static int same_origin(const char *head) { + char origin[256], host[256]; + if (!header_value(head, "Origin", origin, sizeof origin)) return 1; + if (!header_value(head, "Host", host, sizeof host)) return 0; + const char *o = strstr(origin, "://"); + if (!o) return 0; + return strcasecmp(o + 3, host) == 0; +} + +/* ---- WebSocket relay --------------------------------------------------------- */ + +struct relay { + int ws; + int tcp; + pthread_mutex_t wlock; +}; + +static int ws_send(struct relay *r, int opcode, const unsigned char *data, size_t len) { + unsigned char hdr[10]; + size_t hlen; + hdr[0] = (unsigned char)(0x80 | opcode); + if (len < 126) { + hdr[1] = (unsigned char)len; + hlen = 2; + } else if (len < 65536) { + hdr[1] = 126; + hdr[2] = (unsigned char)(len >> 8); + hdr[3] = (unsigned char)len; + hlen = 4; + } else { + hdr[1] = 127; + for (int i = 0; i < 8; i++) hdr[2 + i] = (unsigned char)((uint64_t)len >> (8 * (7 - i))); + hlen = 10; + } + pthread_mutex_lock(&r->wlock); + int rc = write_all(r->ws, hdr, hlen); + if (rc == 0 && len) rc = write_all(r->ws, data, len); + pthread_mutex_unlock(&r->wlock); + return rc; +} + +static void ws_close(struct relay *r, int code, const char *reason) { + unsigned char payload[125]; + size_t rlen = strlen(reason); + if (rlen > sizeof payload - 2) rlen = sizeof payload - 2; + payload[0] = (unsigned char)(code >> 8); + payload[1] = (unsigned char)code; + memcpy(payload + 2, reason, rlen); + ws_send(r, 0x8, payload, rlen + 2); +} + +/* Debugger -> browser. Each chunk read from TCP becomes one binary frame. */ +static void *tcp_to_ws(void *arg) { + struct relay *r = arg; + unsigned char *buf = malloc(RELAY_CHUNK); + if (buf) { + for (;;) { + ssize_t n = recv(r->tcp, buf, RELAY_CHUNK, 0); + if (n < 0 && errno == EINTR) continue; + if (n <= 0) break; + if (ws_send(r, 0x2, buf, (size_t)n) != 0) break; + } + free(buf); + } + ws_close(r, 4002, "The console closed the connection"); + /* Wakes the other direction, which is blocked reading the WebSocket. */ + shutdown(r->ws, SHUT_RDWR); + return NULL; +} + +/* Browser -> debugger. Frame boundaries carry no meaning; payloads are forwarded as a stream. */ +static void ws_to_tcp(struct relay *r) { + unsigned char *buf = malloc(RELAY_CHUNK); + if (!buf) return; + for (;;) { + unsigned char h[2]; + if (read_full(r->ws, h, 2) != 0) break; + int opcode = h[0] & 0x0f; + int masked = h[1] & 0x80; + uint64_t len = h[1] & 0x7f; + if (len == 126) { + unsigned char e[2]; + if (read_full(r->ws, e, 2) != 0) break; + len = ((uint64_t)e[0] << 8) | e[1]; + } else if (len == 127) { + unsigned char e[8]; + if (read_full(r->ws, e, 8) != 0) break; + len = 0; + for (int i = 0; i < 8; i++) len = (len << 8) | e[i]; + } + /* Browsers always mask; an unmasked client frame is a protocol error. */ + if (!masked) break; + unsigned char mask[4]; + if (read_full(r->ws, mask, 4) != 0) break; + + int forward = (opcode == 0x2 || opcode == 0x0); + int failed = 0; + uint64_t done = 0; + unsigned char first[125]; + size_t first_len = 0; + while (done < len) { + size_t take = (len - done > RELAY_CHUNK) ? RELAY_CHUNK : (size_t)(len - done); + if (read_full(r->ws, buf, take) != 0) { + failed = 1; + break; + } + for (size_t i = 0; i < take; i++) buf[i] ^= mask[(done + i) & 3]; + if (forward) { + /* An /events socket has no TCP side; anything the browser sends is dropped. */ + if (r->tcp >= 0 && write_all(r->tcp, buf, take) != 0) { + failed = 1; + break; + } + } else if (done == 0) { + first_len = take < sizeof first ? take : sizeof first; + memcpy(first, buf, first_len); + } + done += take; + } + if (failed) break; + + if (opcode == 0x8) { /* close: echo it and stop */ + ws_send(r, 0x8, first, first_len >= 2 ? 2 : 0); + break; + } + if (opcode == 0x9) ws_send(r, 0xA, first, first_len); /* ping -> pong */ + /* text frames and pongs are ignored */ + } + free(buf); +} + +/* Answers the WebSocket upgrade. Returns 0 once the socket is a WebSocket. */ +static int ws_handshake(int fd, const char *head) { + char key[128]; + if (!header_value(head, "Sec-WebSocket-Key", key, sizeof key) || strlen(key) > 64) { + send_simple(fd, "400 Bad Request", "text/plain", "Missing WebSocket key"); + return -1; + } + if (!same_origin(head)) { + send_simple(fd, "403 Forbidden", "text/plain", "Forbidden"); + return -1; + } + + char joined[128 + 40]; + snprintf(joined, sizeof joined, "%s258EAFA5-E914-47DA-95CA-C5AB0DC85B11", key); + unsigned char digest[20]; + char accept[32]; + sha1((const unsigned char *)joined, strlen(joined), digest); + base64(digest, 20, accept); + + char resp[256]; + int n = snprintf(resp, sizeof resp, + "HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\nConnection: Upgrade\r\n" + "Sec-WebSocket-Accept: %s\r\n\r\n", + accept); + if (n <= 0 || write_all(fd, resp, (size_t)n) != 0) return -1; + return 0; +} + +/* ---- debugger events ------------------------------------------------------------ */ + +static struct relay *g_subs[MAX_EVENT_SUBSCRIBERS]; +static pthread_mutex_t g_subs_lock = PTHREAD_MUTEX_INITIALIZER; + +/* The debugger's connection: pass everything it sends to every /events socket. */ +static void *event_source_thread(void *arg) { + int fd = (int)(intptr_t)arg; + unsigned char *buf = malloc(RELAY_CHUNK); + if (buf) { + for (;;) { + ssize_t n = recv(fd, buf, RELAY_CHUNK, 0); + if (n < 0 && errno == EINTR) continue; + if (n <= 0) break; + pthread_mutex_lock(&g_subs_lock); + for (int i = 0; i < MAX_EVENT_SUBSCRIBERS; i++) { + if (g_subs[i]) ws_send(g_subs[i], 0x2, buf, (size_t)n); + } + pthread_mutex_unlock(&g_subs_lock); + } + free(buf); + } + /* The debugger closes this when the session ends; pass that on, or a browser would wait forever. */ + pthread_mutex_lock(&g_subs_lock); + for (int i = 0; i < MAX_EVENT_SUBSCRIBERS; i++) { + if (g_subs[i]) { + ws_close(g_subs[i], 4005, "The console ended the debugging session"); + shutdown(g_subs[i]->ws, SHUT_RDWR); + } + } + pthread_mutex_unlock(&g_subs_lock); + close(fd); + return NULL; +} + +static int open_listener_on(int port, uint32_t bind_addr); + +static void *event_listener_thread(void *arg) { + (void)arg; + /* Loopback only: the debugger dials the address its attacher came from, which + is this console, and nothing else on the network should be able to feed in + fake stop reports. */ + int listener = open_listener_on(g_event_port, INADDR_LOOPBACK); + if (listener < 0) return NULL; + g_events_ok = 1; + for (;;) { + int fd = accept(listener, NULL, NULL); + if (fd < 0) { + if (errno == EINTR || errno == ECONNABORTED) continue; + close(listener); + g_events_ok = 0; + do { + sleep(1); + listener = open_listener_on(g_event_port, INADDR_LOOPBACK); + } while (listener < 0); + g_events_ok = 1; + continue; + } + pthread_t t; + pthread_attr_t attr; + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + if (pthread_create(&t, &attr, event_source_thread, (void *)(intptr_t)fd) != 0) close(fd); + pthread_attr_destroy(&attr); + } +} + +static void serve_events(int fd, const char *head) { + if (ws_handshake(fd, head) != 0) return; + struct relay r; + r.ws = fd; + r.tcp = -1; + pthread_mutex_init(&r.wlock, NULL); + + int slot = -1; + if (g_events_ok) { + pthread_mutex_lock(&g_subs_lock); + for (int i = 0; i < MAX_EVENT_SUBSCRIBERS; i++) { + if (!g_subs[i]) { + g_subs[i] = &r; + slot = i; + break; + } + } + pthread_mutex_unlock(&g_subs_lock); + } + if (slot < 0) { + ws_close(&r, 4004, g_events_ok ? "Too many debugger sessions are open" : "The bridge could not listen for debugger events (port 755 is in use)"); + } else { + ws_to_tcp(&r); /* returns when the browser closes the socket */ + pthread_mutex_lock(&g_subs_lock); + g_subs[slot] = NULL; + pthread_mutex_unlock(&g_subs_lock); + } + pthread_mutex_destroy(&r.wlock); +} + +static void serve_websocket(int fd, const char *head) { + if (ws_handshake(fd, head) != 0) return; + + struct relay r; + r.ws = fd; + r.tcp = -1; + pthread_mutex_init(&r.wlock, NULL); + + /* The debugger runs on this same console. */ + int tcp = socket(AF_INET, SOCK_STREAM, 0); + struct sockaddr_in addr; + memset(&addr, 0, sizeof addr); + addr.sin_family = AF_INET; + addr.sin_port = htons((uint16_t)g_debugger_port); + addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); + if (tcp < 0 || connect(tcp, (struct sockaddr *)&addr, sizeof addr) != 0) { + if (tcp >= 0) close(tcp); + ws_close(&r, 4001, "The console refused the connection. Is the ps5debug payload loaded?"); + pthread_mutex_destroy(&r.wlock); + return; + } + set_nodelay(tcp); + r.tcp = tcp; + + pthread_t reader; + if (pthread_create(&reader, NULL, tcp_to_ws, &r) != 0) { + ws_close(&r, 4001, "The bridge could not start"); + close(tcp); + pthread_mutex_destroy(&r.wlock); + return; + } + ws_to_tcp(&r); + /* Wakes the debugger->browser thread, which is blocked reading TCP. */ + shutdown(tcp, SHUT_RDWR); + pthread_join(reader, NULL); + close(tcp); + pthread_mutex_destroy(&r.wlock); +} + +/* ---- game library ---------------------------------------------------------------- */ + +/* Title IDs go into file paths, so nothing but the exact shape gets through. */ +static int valid_title_id(const char *s) { + for (int i = 0; i < 4; i++) + if (s[i] < 'A' || s[i] > 'Z') return 0; + for (int i = 4; i < 9; i++) + if (s[i] < '0' || s[i] > '9') return 0; + return s[9] == 0; +} + +static int file_exists(const char *path, struct stat *st) { + struct stat local; + if (!st) st = &local; + return stat(path, st) == 0 && S_ISREG(st->st_mode); +} + +/* Where the system keeps a title's metadata, most authoritative first. */ +static const char *const META_DIRS[] = { + "/system_data/priv/appmeta/%s/%s", + "/system_data/priv/appmeta/external/%s/%s", + "/user/appmeta/%s/%s", + "/user/appmeta/external/%s/%s", + "/user/app/%s/sce_sys/%s", + "/system_ex/app/%s/sce_sys/%s", +}; +#define META_DIR_COUNT ((int)(sizeof META_DIRS / sizeof META_DIRS[0])) + +static int find_meta(const char *tid, const char *file, char *out, size_t cap) { + char fmt[128]; + for (int i = 0; i < META_DIR_COUNT; i++) { + snprintf(fmt, sizeof fmt, "%%s%s", META_DIRS[i]); + snprintf(out, cap, fmt, g_root, tid, file); + if (file_exists(out, NULL)) return 1; + } + return 0; +} + +/* + * Where a game's files can be: internal storage, the extended storage drives, + * and /system_ex/app, which is where game folders kept elsewhere (a USB drive, + * a homebrew folder) are mounted so the console can run them. + */ +static const char *const INSTALL_DIRS[] = { + "/user/app/%s", "/user/patch/%s", "/system_ex/app/%s", + "/mnt/ext0/user/app/%s", "/mnt/ext0/user/patch/%s", "/mnt/ext1/user/app/%s", + "/mnt/ext1/user/patch/%s", +}; +#define INSTALL_DIR_COUNT ((int)(sizeof INSTALL_DIRS / sizeof INSTALL_DIRS[0])) + +/* Adds up the files under a folder. Bounded, so an odd folder cannot stall the server. */ +static uint64_t dir_size(const char *path, int depth, int *budget) { + uint64_t total = 0; + DIR *d = opendir(path); + if (!d) return 0; + struct dirent *e; + while ((e = readdir(d)) != NULL && *budget > 0) { + if (strcmp(e->d_name, ".") == 0 || strcmp(e->d_name, "..") == 0) continue; + char child[1024]; + if (snprintf(child, sizeof child, "%s/%s", path, e->d_name) >= (int)sizeof child) continue; + struct stat st; + if (lstat(child, &st) != 0) continue; + (*budget)--; + if (S_ISREG(st.st_mode)) total += (uint64_t)st.st_size; + else if (S_ISDIR(st.st_mode) && depth < 16) total += dir_size(child, depth + 1, budget); + } + closedir(d); + return total; +} + +struct strbuf { + char *data; + size_t len, cap; + int failed; +}; + +static void sb_add(struct strbuf *b, const char *text) { + size_t n = strlen(text); + if (b->failed) return; + if (b->len + n + 1 > b->cap) { + size_t cap = b->cap ? b->cap * 2 : 4096; + while (cap < b->len + n + 1) cap *= 2; + char *grown = realloc(b->data, cap); + if (!grown) { + b->failed = 1; + return; + } + b->data = grown; + b->cap = cap; + } + memcpy(b->data + b->len, text, n + 1); + b->len += n; +} + +#define MAX_TITLES 2048 + +struct title_set { + char ids[MAX_TITLES][10]; + int count; +}; + +static void collect_titles(struct title_set *set, const char *dir_fmt) { + char path[512]; + snprintf(path, sizeof path, dir_fmt, g_root); + DIR *d = opendir(path); + if (!d) return; + struct dirent *e; + while ((e = readdir(d)) != NULL && set->count < MAX_TITLES) { + /* NPXS titles are the console's own apps (settings, store, ...), not games. */ + if (!valid_title_id(e->d_name) || strncmp(e->d_name, "NPXS", 4) == 0) continue; + int seen = 0; + for (int i = 0; i < set->count && !seen; i++) seen = strcmp(set->ids[i], e->d_name) == 0; + if (!seen) memcpy(set->ids[set->count++], e->d_name, 10); + } + closedir(d); +} + +static int compare_ids(const void *a, const void *b) { + return strcmp(a, b); +} + +/* How big a title is on disk, and where most of it sits. */ +struct title_size { + char tid[10]; + uint64_t size; + char where[256]; /* the folder or image file holding most of it; empty when nothing was found */ + int partial; /* the file count limit was reached, so the real size is larger */ + time_t at; +}; + +/* + * ShadowMount is the homebrew that runs games kept as folders or disk images + * outside the normal install location, mounting an image only while its game + * is played. It knows where each one really is and says so on a local port. + * When it is running, that is the only reliable way to size a game whose + * image is not mounted right now. + */ +#define SHADOWMOUNT_DEFAULT_PORT 10101 +static int g_shadowmount_port = SHADOWMOUNT_DEFAULT_PORT; + +struct game_source { + char tid[10]; + char path[256]; +}; +#define MAX_SOURCES 512 + +/* Copies the string value of "key" found at or after `from` and before `end`. Returns 1 if found. */ +static int json_string_after(const char *from, const char *end, const char *key, char *out, size_t cap) { + char needle[40]; + snprintf(needle, sizeof needle, "\"%s\"", key); + const char *p = strstr(from, needle); + if (!p || p >= end) return 0; + p += strlen(needle); + while (p < end && (*p == ' ' || *p == ':' || *p == '\t')) p++; + if (p >= end || *p != '"') return 0; + p++; + size_t n = 0; + while (p < end && *p != '"') { + if (*p == '\\' && p + 1 < end) p++; /* \/ and \" and \\ all mean the character after the backslash */ + if (n + 1 < cap) out[n++] = *p; + p++; + } + out[n] = 0; + return 1; +} + +/* Asks ShadowMount which game is stored where. Returns how many it listed; 0 when it is not running. */ +static int shadowmount_sources(struct game_source *out, int max) { + int fd = socket(AF_INET, SOCK_STREAM, 0); + if (fd < 0) return 0; + struct sockaddr_in addr; + memset(&addr, 0, sizeof addr); + addr.sin_family = AF_INET; + addr.sin_port = htons((uint16_t)g_shadowmount_port); + addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); + struct timeval tv = {3, 0}; + setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof tv); + setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof tv); + static const char req[] = "POST /api/v1/games HTTP/1.1\r\nHost: 127.0.0.1\r\nContent-Type: application/json\r\n" + "Content-Length: 2\r\nConnection: close\r\n\r\n{}"; + int count = 0; + char *buf = NULL; + size_t len = 0, cap = 0; + if (connect(fd, (struct sockaddr *)&addr, sizeof addr) == 0 && write_all(fd, req, sizeof req - 1) == 0) { + for (;;) { + if (len + 4097 > cap) { + size_t grown = cap ? cap * 2 : 16384; + if (grown > (4u << 20)) break; + char *next = realloc(buf, grown); + if (!next) break; + buf = next; + cap = grown; + } + ssize_t n = recv(fd, buf + len, 4096, 0); + if (n < 0 && errno == EINTR) continue; + if (n <= 0) break; + len += (size_t)n; + } + } + close(fd); + if (buf && len > 0) { + buf[len] = 0; + /* Each game is one object holding both "path" and "title_id"; walk them in order. */ + const char *end = buf + len; + const char *p = strstr(buf, "\"games\""); + while (p && count < max) { + const char *open = strchr(p, '{'); + if (!open) break; + const char *close_ = strchr(open, '}'); + if (!close_) break; + char tid[32]; + if (json_string_after(open, close_, "title_id", tid, sizeof tid) && valid_title_id(tid) && + json_string_after(open, close_, "path", out[count].path, sizeof out[count].path) && out[count].path[0] == '/') { + memcpy(out[count].tid, tid, 10); + count++; + } + p = close_ + 1; + if (p >= end) break; + } + } + free(buf); + return count; +} + +/* Walking a large game takes a moment, so results are kept for a couple of minutes. */ +#define SIZE_CACHE_SLOTS 256 +#define SIZE_CACHE_SECONDS 120 +#define SIZE_FILE_LIMIT 200000 +static struct title_size g_sizes[SIZE_CACHE_SLOTS]; +static pthread_mutex_t g_sizes_lock = PTHREAD_MUTEX_INITIALIZER; + +static void measure_title(const char *tid, const char *source, struct title_size *out) { + time_t now = time(NULL); + int slot = -1; + pthread_mutex_lock(&g_sizes_lock); + for (int i = 0; i < SIZE_CACHE_SLOTS; i++) { + if (strcmp(g_sizes[i].tid, tid) == 0) { + slot = i; + break; + } + if (slot < 0 && g_sizes[i].tid[0] == 0) slot = i; + } + if (slot >= 0 && g_sizes[slot].tid[0] && now - g_sizes[slot].at < SIZE_CACHE_SECONDS) { + *out = g_sizes[slot]; + pthread_mutex_unlock(&g_sizes_lock); + return; + } + pthread_mutex_unlock(&g_sizes_lock); + + memset(out, 0, sizeof *out); + snprintf(out->tid, sizeof out->tid, "%.9s", tid); + out->at = now; + uint64_t largest = 0; + uint64_t mounted = 0; + int budget = SIZE_FILE_LIMIT; + + /* A game kept as a folder or image elsewhere: measure it where it really is. */ + int have_source = 0; + if (source && *source) { + char path[512]; + struct stat st; + snprintf(path, sizeof path, "%s%s", g_root, source); + if (stat(path, &st) == 0) { + uint64_t here = S_ISDIR(st.st_mode) ? dir_size(path, 0, &budget) : (uint64_t)st.st_size; + out->size += here; + largest = here; + snprintf(out->where, sizeof out->where, "%s", source); + have_source = 1; + } + } + + for (int k = 0; k < INSTALL_DIR_COUNT; k++) { + char path[512], fmt[128]; + struct stat st; + /* The mount point shows the same files as the source just counted. */ + if (have_source && strncmp(INSTALL_DIRS[k], "/system_ex/", 11) == 0) continue; + snprintf(fmt, sizeof fmt, "%%s%s", INSTALL_DIRS[k]); + snprintf(path, sizeof path, fmt, g_root, tid); + if (stat(path, &st) != 0 || !S_ISDIR(st.st_mode)) continue; + if (have_source) { + /* An ordinary installed game is reported with its install folder as the source; do not count that twice. */ + char plain[256]; + snprintf(plain, sizeof plain, INSTALL_DIRS[k], tid); + size_t n = strlen(plain); + if (strncmp(source, plain, n) == 0 && (source[n] == 0 || source[n] == '/')) continue; + } + uint64_t here = dir_size(path, 0, &budget); + if (strncmp(INSTALL_DIRS[k], "/system_ex/", 11) == 0) { + /* A mount point: another view of files that may already be counted where they are installed. */ + mounted = here; + continue; + } + out->size += here; + if (!out->where[0] || here > largest) { + largest = here; + snprintf(out->where, sizeof out->where, INSTALL_DIRS[k], tid); + } + } + /* So it only counts when it shows more than was found elsewhere: a game whose real files were not found any other way. */ + if (mounted > out->size) { + out->size = mounted; + snprintf(out->where, sizeof out->where, "/system_ex/app/%s", tid); + } + out->partial = budget <= 0; + + pthread_mutex_lock(&g_sizes_lock); + if (slot >= 0) g_sizes[slot] = *out; + pthread_mutex_unlock(&g_sizes_lock); +} + +/* + * Every title the console has metadata for, with what kind of metadata it is + * (param.json is a PS5 title, param.sfo a PS4 one), where it is installed and + * how much space that takes. `size` is 0 when no install folder was found. + */ +static void serve_library(int fd) { + struct title_set *set = calloc(1, sizeof *set); + struct strbuf b = {0}; + if (!set) { + send_simple(fd, "500 Internal Server Error", "text/plain", "Out of memory"); + return; + } + collect_titles(set, "%s/system_data/priv/appmeta"); + collect_titles(set, "%s/system_data/priv/appmeta/external"); + collect_titles(set, "%s/user/appmeta"); + collect_titles(set, "%s/user/appmeta/external"); + qsort(set->ids, (size_t)set->count, sizeof set->ids[0], compare_ids); + + struct game_source *sources = calloc(MAX_SOURCES, sizeof *sources); + int source_count = sources ? shadowmount_sources(sources, MAX_SOURCES) : 0; + + sb_add(&b, "{\"titles\":["); + int written = 0; + for (int i = 0; i < set->count; i++) { + const char *tid = set->ids[i]; + char path[512], item[1024 + 520]; + const char *meta = find_meta(tid, "param.json", path, sizeof path) ? "json" + : find_meta(tid, "param.sfo", path, sizeof path) ? "sfo" : NULL; + if (!meta) continue; + + const char *source = NULL; + for (int k = 0; k < source_count && !source; k++) + if (strcmp(sources[k].tid, tid) == 0) source = sources[k].path; + struct title_size ts; + measure_title(tid, source, &ts); + /* The path goes into JSON: quotes and backslashes are escaped, anything odder is dropped. */ + char location[520]; + size_t ln = 0; + for (const char *c = ts.where; *c && ln + 3 < sizeof location; c++) { + if ((unsigned char)*c < 0x20) continue; + if (*c == '"' || *c == '\\') location[ln++] = '\\'; + location[ln++] = *c; + } + location[ln] = 0; + snprintf(item, sizeof item, "%s{\"id\":\"%s\",\"meta\":\"%s\",\"size\":%llu,\"partial\":%s,\"path\":\"%s\"}", written ? "," : "", + tid, meta, (unsigned long long)ts.size, ts.partial ? "true" : "false", location); + sb_add(&b, item); + written++; + } + sb_add(&b, "]}"); + free(sources); + free(set); + if (b.failed) send_simple(fd, "500 Internal Server Error", "text/plain", "Out of memory"); + else send_simple(fd, "200 OK", "application/json; charset=utf-8", b.data); + free(b.data); +} + +#define META_FILE_MAX (8u << 20) + +/* GET /api/appmeta/<title id>/<param.json|param.sfo|icon0.png> */ +static void serve_appmeta(int fd, const char *rest, int head_only) { + char tid[10]; + const char *slash = strchr(rest, '/'); + if (!slash || slash - rest != 9) { + send_simple(fd, "404 Not Found", "text/plain", "Not found"); + return; + } + memcpy(tid, rest, 9); + tid[9] = 0; + const char *file = slash + 1; + const char *mime = strcmp(file, "param.json") == 0 ? "application/json; charset=utf-8" + : strcmp(file, "param.sfo") == 0 ? "application/octet-stream" + : strcmp(file, "icon0.png") == 0 ? "image/png" + : NULL; + char path[512]; + struct stat st; + if (!mime || !valid_title_id(tid) || !find_meta(tid, file, path, sizeof path) || stat(path, &st) != 0 || + (uint64_t)st.st_size > META_FILE_MAX) { + send_simple(fd, "404 Not Found", "text/plain", "Not found"); + return; + } + FILE *f = fopen(path, "rb"); + size_t size = (size_t)st.st_size; + unsigned char *data = f ? malloc(size ? size : 1) : NULL; + if (!data || fread(data, 1, size, f) != size) { + if (f) fclose(f); + free(data); + send_simple(fd, "404 Not Found", "text/plain", "Not found"); + return; + } + fclose(f); + char head[512]; + int n = snprintf(head, sizeof head, + "HTTP/1.1 200 OK\r\nContent-Type: %s\r\nContent-Length: %zu\r\nCache-Control: %s\r\n" + "X-Content-Type-Options: nosniff\r\nConnection: close\r\n\r\n", + mime, size, strcmp(file, "icon0.png") == 0 ? "private, max-age=86400" : "no-store"); + if (n > 0 && write_all(fd, head, (size_t)n) == 0 && !head_only) write_all(fd, data, size); + free(data); +} + +/* ---- starting a game ---------------------------------------------------------------- */ + +static pthread_mutex_t g_launch_lock = PTHREAD_MUTEX_INITIALIZER; + +#ifdef __PROSPERO__ +#include <ps5/kernel.h> +#include <sys/syscall.h> + +typedef struct app_launch_ctx { + uint32_t structsize; + uint32_t user_id; + uint32_t app_opt; + uint64_t crash_report; + uint32_t check_flag; +} app_launch_ctx_t; + +int sceUserServiceInitialize(void *); +int sceUserServiceGetForegroundUser(uint32_t *user_id); +int sceSystemServiceGetAppIdOfRunningBigApp(void); +int sceSystemServiceKillApp(int app_id, int how, int reason, int core_dump); +int sceSystemServiceLaunchApp(const char *title_id, char **argv, app_launch_ctx_t *ctx); + +/* The identity the system's own shell uses; the launch call refuses anyone else. */ +#define LAUNCHER_AUTHID 0x4801000000000013L + +/* Closes whatever game is running and starts `tid`, as picking it on the home screen would. */ +static int launch_title(const char *tid, const char **step) { + app_launch_ctx_t ctx; + char *argv[] = {NULL}; + memset(&ctx, 0, sizeof ctx); + + pid_t me = getpid(); + uint64_t before = kernel_get_ucred_authid(me); + kernel_set_ucred_authid(me, LAUNCHER_AUTHID); + + int err; + *step = "finding the signed-in user"; + if ((err = sceUserServiceGetForegroundUser(&ctx.user_id)) == 0) { + int app = sceSystemServiceGetAppIdOfRunningBigApp(); + *step = "closing the running game"; + if (app > 0) err = sceSystemServiceKillApp(app, -1, 0, 0); + if (err == 0) { + *step = "starting the game"; + err = sceSystemServiceLaunchApp(tid, argv, &ctx); + if (err > 0) err = 0; /* a positive result is the new app's id */ + } + } + if (before) kernel_set_ucred_authid(me, before); + return err; +} +#else +/* On a computer there is nothing to start; tests read back what was asked for. */ +static int launch_title(const char *tid, const char **step) { + const char *log = getenv("CS_LAUNCH_LOG"); + *step = "starting the game"; + if (!log) return -1; + FILE *f = fopen(log, "a"); + if (!f) return -1; + fprintf(f, "%s\n", tid); + fclose(f); + return 0; +} +#endif + +/* POST /api/launch/<title id> */ +static void serve_launch(int fd, const char *head, const char *tid) { + char path[512], body[256]; + /* This changes what the console is doing, so only the app this server served may ask. */ + if (!same_origin(head)) { + send_simple(fd, "403 Forbidden", "text/plain", "Forbidden"); + return; + } + if (!valid_title_id(tid) || strncmp(tid, "NPXS", 4) == 0 || + (!find_meta(tid, "param.json", path, sizeof path) && !find_meta(tid, "param.sfo", path, sizeof path))) { + send_simple(fd, "404 Not Found", "application/json; charset=utf-8", "{\"ok\":false,\"error\":\"That game is not on this console\"}"); + return; + } + const char *step = ""; + pthread_mutex_lock(&g_launch_lock); + int err = launch_title(tid, &step); + pthread_mutex_unlock(&g_launch_lock); + if (err == 0) { + send_simple(fd, "200 OK", "application/json; charset=utf-8", "{\"ok\":true}"); + } else { + snprintf(body, sizeof body, "{\"ok\":false,\"error\":\"The console refused while %s\",\"code\":\"0x%08x\"}", step, (unsigned)err); + send_simple(fd, "500 Internal Server Error", "application/json; charset=utf-8", body); + } +} + +/* ---- the user's own cheat files ---------------------------------------------------- */ + +/* One file per game and game version: <title id>-<version>.cspecter */ +#define TABLES_DIR "/data/cheatspecter/cheats" +#define TABLE_MAX (4u << 20) + +/* A game version as it appears in a file name: digits, letters and dots only. */ +static int valid_version(const char *s) { + size_t n = 0; + for (; s[n]; n++) { + char c = s[n]; + if (!((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c == '.' && n > 0))) return 0; + } + return n >= 1 && n <= 16; +} + +/* Splits "<title id>/<version>" into its halves. Returns 1 when both are well-formed. */ +static int split_table_ref(const char *rest, char tid[10], char version[17]) { + if (strlen(rest) < 11 || strlen(rest) > 9 + 1 + 16 || rest[9] != '/') return 0; + memcpy(tid, rest, 9); + tid[9] = 0; + snprintf(version, 17, "%s", rest + 10); + return valid_title_id(tid) && valid_version(version); +} + +static void table_path(const char *tid, const char *version, const char *suffix, char *out, size_t cap) { + snprintf(out, cap, "%s%s/%.9s-%.16s.cspecter%s", g_root, TABLES_DIR, tid, version, suffix); +} + +/* GET /api/tables/<title id>: which versions of this game have a saved file. */ +static void list_tables(int fd, const char *tid) { + char path[512], item[64]; + struct strbuf b = {0}; + if (!valid_title_id(tid)) { + send_simple(fd, "404 Not Found", "text/plain", "Not found"); + return; + } + sb_add(&b, "{\"folder\":\"" TABLES_DIR "\",\"versions\":["); + snprintf(path, sizeof path, "%s%s", g_root, TABLES_DIR); + DIR *d = opendir(path); + int written = 0; + if (d) { + struct dirent *e; + while ((e = readdir(d)) != NULL) { + size_t len = strlen(e->d_name); + char version[17]; + if (len < 9 + 1 + 1 + 9 || len > 9 + 1 + 16 + 9) continue; + if (strncmp(e->d_name, tid, 9) != 0 || e->d_name[9] != '-' || strcmp(e->d_name + len - 9, ".cspecter") != 0) continue; + snprintf(version, sizeof version, "%.*s", (int)(len - 19), e->d_name + 10); + if (!valid_version(version)) continue; + snprintf(item, sizeof item, "%s\"%s\"", written++ ? "," : "", version); + sb_add(&b, item); + } + closedir(d); + } + sb_add(&b, "]}"); + if (b.failed) send_simple(fd, "500 Internal Server Error", "text/plain", "Out of memory"); + else send_simple(fd, "200 OK", "application/json; charset=utf-8", b.data); + free(b.data); +} + +/* GET /api/tables/<title id>/<version> */ +static void serve_table(int fd, const char *rest, int head_only) { + char tid[10], version[17], path[512]; + struct stat st; + FILE *f = NULL; + if (split_table_ref(rest, tid, version)) { + table_path(tid, version, "", path, sizeof path); + if (file_exists(path, &st) && (uint64_t)st.st_size <= TABLE_MAX) f = fopen(path, "rb"); + } + if (!f) { + send_simple(fd, "404 Not Found", "text/plain", "Not found"); + return; + } + size_t size = (size_t)st.st_size; + char *data = malloc(size + 1); + if (data && fread(data, 1, size, f) == size) { + char head[256]; + int n = snprintf(head, sizeof head, + "HTTP/1.1 200 OK\r\nContent-Type: application/json; charset=utf-8\r\nContent-Length: %zu\r\n" + "Cache-Control: no-store\r\nConnection: close\r\n\r\n", + size); + if (n > 0 && write_all(fd, head, (size_t)n) == 0 && !head_only) write_all(fd, data, size); + } else { + send_simple(fd, "500 Internal Server Error", "text/plain", "Could not read the file"); + } + free(data); + fclose(f); +} + +/* PUT /api/tables/<title id>/<version>. `early` is the part of the body that arrived with the head. */ +static void store_table(int fd, const char *head, const char *rest, const char *early, size_t early_len) { + char tid[10], version[17], value[32], path[512], tmp[512]; + if (!same_origin(head)) { + send_simple(fd, "403 Forbidden", "text/plain", "Forbidden"); + return; + } + if (!split_table_ref(rest, tid, version) || !header_value(head, "Content-Length", value, sizeof value)) { + send_simple(fd, "400 Bad Request", "text/plain", "Bad request"); + return; + } + unsigned long long length = strtoull(value, NULL, 10); + if (length > TABLE_MAX || early_len > length) { + send_simple(fd, "413 Content Too Large", "text/plain", "That table is too large"); + return; + } + char *body = malloc((size_t)length + 1); + if (!body) { + send_simple(fd, "500 Internal Server Error", "text/plain", "Out of memory"); + return; + } + memcpy(body, early, early_len); + if (read_full(fd, body + early_len, (size_t)length - early_len) != 0) { + free(body); + return; + } + + snprintf(path, sizeof path, "%s/data", g_root); + mkdir(path, 0777); + snprintf(path, sizeof path, "%s/data/cheatspecter", g_root); + mkdir(path, 0777); + snprintf(path, sizeof path, "%s%s", g_root, TABLES_DIR); + mkdir(path, 0777); + /* Written beside the real file and moved into place, so a crash cannot leave half a table. */ + table_path(tid, version, "", path, sizeof path); + table_path(tid, version, ".saving", tmp, sizeof tmp); + FILE *f = fopen(tmp, "wb"); + int ok = f != NULL && fwrite(body, 1, (size_t)length, f) == (size_t)length; + if (f && fclose(f) != 0) ok = 0; + if (ok) ok = rename(tmp, path) == 0; + if (!ok) unlink(tmp); + free(body); + if (ok) { + static const char done[] = "HTTP/1.1 204 No Content\r\nCache-Control: no-store\r\nConnection: close\r\n\r\n"; + write_all(fd, done, sizeof done - 1); + } else { + send_simple(fd, "500 Internal Server Error", "text/plain", "Could not save the file"); + } +} + +/* ---- request dispatch ---------------------------------------------------------- */ + +static void handle_connection(int fd) { + char *head = malloc(HEADER_MAX); + if (!head) return; + size_t got = 0; + if (read_head(fd, head, HEADER_MAX, &got) != 0) { + free(head); + return; + } + + char method[8] = {0}, target[1024] = {0}; + if (sscanf(head, "%7s %1023s", method, target) != 2) { + send_simple(fd, "400 Bad Request", "text/plain", "Bad request"); + free(head); + return; + } + char *q = strchr(target, '?'); + if (q) *q = 0; + const char *body = strstr(head, "\r\n\r\n") + 4; + + int is_head = strcmp(method, "HEAD") == 0; + if (strcmp(method, "POST") == 0 && strcmp(target, "/api/shutdown") == 0) { + /* A newer copy of this payload asking the running one to make way. Only + something on the console itself may ask. */ + struct sockaddr_in peer; + socklen_t plen = sizeof peer; + if (getpeername(fd, (struct sockaddr *)&peer, &plen) == 0 && peer.sin_family == AF_INET && + peer.sin_addr.s_addr == htonl(INADDR_LOOPBACK)) { + send_simple(fd, "200 OK", "text/plain", "bye"); + shutdown(fd, SHUT_RDWR); + close(fd); + _exit(0); + } + send_simple(fd, "403 Forbidden", "text/plain", "Forbidden"); + free(head); + return; + } + if (strcmp(method, "POST") == 0 && strncmp(target, "/api/launch/", 12) == 0) { + serve_launch(fd, head, target + 12); + } else if (strcmp(method, "PUT") == 0 && strncmp(target, "/api/tables/", 12) == 0) { + store_table(fd, head, target + 12, body, got - (size_t)(body - head)); + } else if (strcmp(method, "GET") != 0 && !is_head) { + send_simple(fd, "405 Method Not Allowed", "text/plain", "Method not allowed"); + } else if (strcmp(target, "/ws") == 0) { + serve_websocket(fd, head); + } else if (strcmp(target, "/events") == 0) { + serve_events(fd, head); + } else if (strcmp(target, "/api/info") == 0) { + char info[192]; + snprintf(info, sizeof info, "{\"mode\":\"console\",\"version\":\"%s\",\"events\":%s,\"library\":true}", CS_VERSION, + g_events_ok ? "true" : "false"); + send_simple(fd, "200 OK", "application/json; charset=utf-8", info); + } else if (strncmp(target, "/api/tables/", 12) == 0) { + if (strchr(target + 12, '/')) serve_table(fd, target + 12, is_head); + else list_tables(fd, target + 12); + } else if (strcmp(target, "/api/library") == 0) { + serve_library(fd); + } else if (strncmp(target, "/api/appmeta/", 13) == 0) { + serve_appmeta(fd, target + 13, is_head); + } else { + const char *path = strcmp(target, "/") == 0 ? "/index.html" : target; + const struct asset *found = NULL; + for (int i = 0; i < CS_ASSET_COUNT; i++) { + if (strcmp(CS_ASSETS[i].path, path) == 0) { + found = &CS_ASSETS[i]; + break; + } + } + if (found) send_asset(fd, found, is_head); + else send_simple(fd, "404 Not Found", "text/plain", "Not found"); + } + free(head); +} + +static void *connection_thread(void *arg) { + int fd = (int)(intptr_t)arg; + set_nodelay(fd); + /* A browser that vanished without closing must not block a writer forever. */ + struct timeval tv = {15, 0}; + setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof tv); + handle_connection(fd); + shutdown(fd, SHUT_RDWR); + close(fd); + return NULL; +} + +/* ---- startup ----------------------------------------------------------------- */ + +static int open_listener_on(int port, uint32_t bind_addr) { + int fd = socket(AF_INET, SOCK_STREAM, 0); + if (fd < 0) return -1; + int one = 1; + setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof one); + struct sockaddr_in addr; + memset(&addr, 0, sizeof addr); + addr.sin_family = AF_INET; + addr.sin_port = htons((uint16_t)port); + addr.sin_addr.s_addr = htonl(bind_addr); + if (bind(fd, (struct sockaddr *)&addr, sizeof addr) != 0 || listen(fd, 16) != 0) { + int saved = errno; + close(fd); + errno = saved; + return -1; + } + return fd; +} + +static int open_listener(void) { + return open_listener_on(g_port, INADDR_ANY); +} + +/* + * The console's LAN address, for the "open this on your phone" notification. + * Connecting a UDP socket sends nothing; it only makes the kernel pick the + * outgoing interface, whose address is then read back. + */ +static int lan_address(char *out, size_t cap) { + int fd = socket(AF_INET, SOCK_DGRAM, 0); + if (fd < 0) return -1; + struct sockaddr_in peer; + memset(&peer, 0, sizeof peer); + peer.sin_family = AF_INET; + peer.sin_port = htons(9); + inet_pton(AF_INET, "192.0.2.1", &peer.sin_addr); + struct sockaddr_in self; + socklen_t slen = sizeof self; + int ok = connect(fd, (struct sockaddr *)&peer, sizeof peer) == 0 && + getsockname(fd, (struct sockaddr *)&self, &slen) == 0 && self.sin_addr.s_addr != 0 && + inet_ntop(AF_INET, &self.sin_addr, out, (socklen_t)cap) != NULL; + close(fd); + return ok ? 0 : -1; +} + +static void replace_running_copy(void) { + int fd = socket(AF_INET, SOCK_STREAM, 0); + if (fd < 0) return; + struct sockaddr_in addr; + memset(&addr, 0, sizeof addr); + addr.sin_family = AF_INET; + addr.sin_port = htons((uint16_t)g_port); + addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); + struct timeval tv = {3, 0}; + setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof tv); + setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof tv); + if (connect(fd, (struct sockaddr *)&addr, sizeof addr) == 0) { + static const char req[] = "POST /api/shutdown HTTP/1.1\r\nHost: 127.0.0.1\r\nContent-Length: 0\r\nConnection: close\r\n\r\n"; + char buf[128]; + if (write_all(fd, req, sizeof req - 1) == 0) (void)recv(fd, buf, sizeof buf, 0); + } + close(fd); +} + +int main(void) { + signal(SIGPIPE, SIG_IGN); + +#ifndef __PROSPERO__ + /* Test hooks for the computer build only. */ + if (getenv("CS_PORT")) g_port = atoi(getenv("CS_PORT")); + if (getenv("CS_DEBUGGER_PORT")) g_debugger_port = atoi(getenv("CS_DEBUGGER_PORT")); + if (getenv("CS_EVENT_PORT")) g_event_port = atoi(getenv("CS_EVENT_PORT")); + if (getenv("CS_ROOT")) g_root = getenv("CS_ROOT"); + if (getenv("CS_SHADOWMOUNT_PORT")) g_shadowmount_port = atoi(getenv("CS_SHADOWMOUNT_PORT")); +#else + /* The name process lists and payload managers show for this payload. */ + syscall(SYS_thr_set_name, -1, "cheatspecter.elf"); + /* Needed once before asking who is signed in, which starting a game does. */ + sceUserServiceInitialize(0); +#endif + + int listener = open_listener(); + if (listener < 0 && errno == EADDRINUSE) { + /* An older copy is still running: ask it to stop, then take its place. */ + replace_running_copy(); + for (int i = 0; i < 50 && listener < 0; i++) { + usleep(100 * 1000); + listener = open_listener(); + } + if (listener < 0) errno = EADDRINUSE; + } + if (listener < 0) { + notify(errno == EADDRINUSE ? "An older CheatSpecter is running and would not stop. Restart the PS5, then send this again." : "CheatSpecter could not start its web server"); + return 1; + } + + pthread_t events; + if (pthread_create(&events, NULL, event_listener_thread, NULL) == 0) pthread_detach(events); + + char ip[64], msg[256]; + if (lan_address(ip, sizeof ip) == 0) { + snprintf(msg, sizeof msg, "CheatSpecter %s is ready\nOpen http://%s:%d in a browser", CS_VERSION, ip, g_port); + } else { + snprintf(msg, sizeof msg, "CheatSpecter %s is ready on port %d", CS_VERSION, g_port); + } + notify(msg); + + for (;;) { + int fd = accept(listener, NULL, NULL); + if (fd < 0) { + if (errno == EINTR || errno == ECONNABORTED) continue; + /* After rest mode the listening socket can be dead; start a new one. */ + close(listener); + do { + sleep(1); + listener = open_listener(); + } while (listener < 0); + continue; + } + pthread_t t; + pthread_attr_t attr; + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + if (pthread_create(&t, &attr, connection_thread, (void *)(intptr_t)fd) != 0) close(fd); + pthread_attr_destroy(&attr); + } +} diff --git a/public/ghost.svg b/public/ghost.svg new file mode 100644 index 0000000..c7cea35 --- /dev/null +++ b/public/ghost.svg @@ -0,0 +1,8 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" xmlns:c2pa="http://c2pa.org/manifest"><metadata><c2pa:manifest>AAAWgmp1bWIAAAAeanVtZGMycGEAEQAQgAAAqgA4m3EDYzJwYQAAABZcanVtYgAAAEdqdW1kYzJtYQARABCAAACqADibcQN1cm46YzJwYToyZmQwOTkwYi01ZjU3LTQ2YzktYTE2Zi04YmJlYmJlMTM0NzcAAAADl2p1bWIAAAApanVtZGMyYXMAEQAQgAAAqgA4m3EDYzJwYS5hc3NlcnRpb25zAAAAALxqdW1iAAAARGp1bWRjYm9yABEAEIAAAKoAOJtxE2MycGEuaW5ncmVkaWVudC52MwAAAAAYYzJzaGPOotfX2vlH/nUnNK+REAMAAABwY2JvcqNpZGM6Zm9ybWF0bWltYWdlL3N2Zyt4bWxqaW5zdGFuY2VJRHgseG1wOmlpZDo0NDZkYjcwMC0yNjgwLTQyYjUtOGZkMC0zMGM1MjZhMzlmOWNscmVsYXRpb25zaGlwaHBhcmVudE9mAAAB4mp1bWIAAABBanVtZGNib3IAEQAQgAAAqgA4m3ETYzJwYS5hY3Rpb25zLnYyAAAAABhjMnNoIIoEgWfbNw+17N2s2fSnbAAAAZljYm9yomdhY3Rpb25zgqJmYWN0aW9ua2MycGEub3BlbmVkanBhcmFtZXRlcnOha2luZ3JlZGllbnRzgaJjdXJseC1zZWxmI2p1bWJmPWMycGEuYXNzZXJ0aW9ucy9jMnBhLmluZ3JlZGllbnQudjNkaGFzaFggX7hS0m+3DmO1r9z9E/c9M1fIntZO42L1pXuIT5B7kOekZmFjdGlvbngdY29tLmFudGhyb3BpYy5jbGF1ZGUucHJvdmlkZWRqcGFyYW1ldGVyc6F4H2NvbS5hbnRocm9waWMub3JpZ2luLWNvbmZpZGVuY2VndW5rbm93bmtkZXNjcmlwdGlvbnhmQ2xhdWRlIHByb3ZpZGVkIHRoaXMgZmlsZSBhdCB0aGUgcmVxdWVzdCBvZiBhIHVzZXIgYW5kIG1heSBoYXZlIGNyZWF0ZWQgb3IgbW9kaWZpZWQgdGhlIGZpbGUgY29udGVudHMubXNvZnR3YXJlQWdlbnShZG5hbWVmQ2xhdWRlcmFsbEFjdGlvbnNJbmNsdWRlZPUAAADIanVtYgAAAEBqdW1kY2JvcgARABCAAACqADibcRNjMnBhLmhhc2guZGF0YQAAAAAYYzJzaD/CZH3twzjXh1+Y7+ILwtwAAACAY2JvcqVjYWxnZnNoYTI1NmNwYWRNAAAAAAAAAAAAAAAAAGRoYXNoWCBSAIF//tQPqpyqSM0NKyINo/HxArL/hqve95S5Yq5YAWRuYW1lbmp1bWJmIG1hbmlmZXN0amV4Y2x1c2lvbnOBomVzdGFydBh7Zmxlbmd0aBkeBAAAAj5qdW1iAAAAJ2p1bWRjMmNsABEAEIAAAKoAOJtxA2MycGEuY2xhaW0udjIAAAACD2Nib3KlY2FsZ2ZzaGEyNTZpc2lnbmF0dXJleE1zZWxmI2p1bWJmPS9jMnBhL3VybjpjMnBhOjJmZDA5OTBiLTVmNTctNDZjOS1hMTZmLThiYmViYmUxMzQ3Ny9jMnBhLnNpZ25hdHVyZWppbnN0YW5jZUlEeCx4bXA6aWlkOjgxYmMwMjRlLTcxOGYtNDEyMi04MjE3LThmNzM4NzAyYzkzMXJjcmVhdGVkX2Fzc2VydGlvbnODomN1cmx4LXNlbGYjanVtYmY9YzJwYS5hc3NlcnRpb25zL2MycGEuaW5ncmVkaWVudC52M2RoYXNoWCBfuFLSb7cOY7Wv3P0T9z0zV8ie1k7jYvWle4hPkHuQ56JjdXJseCpzZWxmI2p1bWJmPWMycGEuYXNzZXJ0aW9ucy9jMnBhLmFjdGlvbnMudjJkaGFzaFggyXVp/CMt70i5LlUePfBP82HSdbKl58WTbn+Sv/nMVmWiY3VybHgpc2VsZiNqdW1iZj1jMnBhLmFzc2VydGlvbnMvYzJwYS5oYXNoLmRhdGFkaGFzaFggnO8/tbYzNjnJaA8MyBu3ixlswMgij0R8IPz73UpX9vh0Y2xhaW1fZ2VuZXJhdG9yX2luZm+jZG5hbWVvQW50aHJvcGljIEZpbGVzZ3ZlcnNpb25lMS4wLjBrc3BlY1ZlcnNpb25lMi40LjAAABA4anVtYgAAAChqdW1kYzJjcwARABCAAACqADibcQNjMnBhLnNpZ25hdHVyZQAAABAIY2JvctKEWQISogEmGCFZAgowggIGMIIBjaADAgECAhRA5aAK7sI50L64g/oGQgU9Z1UTADAKBggqhkjOPQQDAzBJMRcwFQYDVQQKEw5BbnRocm9waWMsIFBCQzEuMCwGA1UEAxMlQW50aHJvcGljIENvbnRlbnQgQ3JlZGVudGlhbHMgUm9vdCBDQTAeFw0yNjA4MDcxODQzNTZaFw0yODA4MDYxOTQzNTZaMEQxFzAVBgNVBAoTDkFudGhyb3BpYywgUEJDMSkwJwYDVQQDEyBBbnRocm9waWMgQ2xhdWRlIENvbnRlbnQgU2lnbmluZzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABJh6CmvLUBgFFNU0vUKlOVtE6djd17L5SuwX0LemFisBM3dkd/3cyjxFA3Qo5S46fX0/ihY0VZ7mfb9KF703t5OjWDBWMA4GA1UdDwEB/wQEAwIHgDAVBgNVHSUEDjAMBgorBgEEAYPoXgIBMAwGA1UdEwEB/wQCMAAwHwYDVR0jBBgwFoAUzlHiBIFOZFsj+OPEz5o+nMHXXMIwCgYIKoZIzj0EAwMDZwAwZAIwMXMdFJ4BetLLVY7ORuE9noqbbAZOZn/aArXyTwFAZfKrPzxF2vPoJNf1+UCdg1XGAjBwX1zd9WGqYkqmL5SFqw1QySjr1zJfpJM9+1rdDwSPLMOPOjKuiXjoU/pUUeG9RwmhY3BhZFkNngAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPZYQACv8TqOhFMeuLQbkwE1UOcYNEQkwWS+kRKr5QjAY5Avg5v8FfIAoI6/A8PVx+zPIuRxA9cOEsYo0a0+IhbSnyc=</c2pa:manifest></metadata> + <rect width="64" height="64" rx="14" fill="#070707"/> + <path d="M10 34C10 19 19.5 8 32 8s22 11 22 26v22l-7.3-6.5L39.3 56 32 49.5 24.7 56l-7.4-6.5L10 56Z" fill="#ffd400"/> + <ellipse cx="24" cy="30" rx="5.5" ry="6.5" fill="#fff"/> + <ellipse cx="40" cy="30" rx="5.5" ry="6.5" fill="#fff"/> + <circle cx="26.5" cy="31" r="3" fill="#0a0a0a"/> + <circle cx="42.5" cy="31" r="3" fill="#0a0a0a"/> +</svg> diff --git a/scripts/build-mcp.mjs b/scripts/build-mcp.mjs new file mode 100644 index 0000000..795788c --- /dev/null +++ b/scripts/build-mcp.mjs @@ -0,0 +1,134 @@ +// Builds the MCP server as a desktop extension: mcp/cheatspecter-<version>.mcpb +// +// An .mcpb file is a zip with a manifest and the server inside. Opening it in +// the Claude desktop app installs it; nothing has to be typed or configured +// beyond the PS5's address. + +import fs from 'node:fs'; +import path from 'node:path'; +import zlib from 'node:zlib'; +import { fileURLToPath } from 'node:url'; +import { rolldown } from 'rolldown'; + +const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..'); +const { version } = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8')); +const out = path.join(root, 'mcp/build'); +fs.rmSync(out, { recursive: true, force: true }); +fs.mkdirSync(path.join(out, 'server'), { recursive: true }); + +// One file with everything in it except the disassembler, which loads a +// WebAssembly file from beside itself and so is shipped as it is. +const bundle = await rolldown({ + input: path.join(root, 'mcp/server.ts'), + platform: 'node', + external: ['iced-x86'], + transform: { define: { __VERSION__: JSON.stringify(version) } }, + logLevel: 'warn', +}); +await bundle.write({ file: path.join(out, 'server/index.mjs'), format: 'esm', codeSplitting: false }); +await bundle.close(); + +const iced = path.join(root, 'node_modules/iced-x86'); +const icedOut = path.join(out, 'server/node_modules/iced-x86'); +fs.mkdirSync(icedOut, { recursive: true }); +for (const f of ['package.json', 'iced_x86.js', 'iced_x86_bg.wasm', 'LICENSE.txt']) fs.copyFileSync(path.join(iced, f), path.join(icedOut, f)); + +const manifest = { + manifest_version: '0.3', + name: 'cheatspecter', + display_name: 'CheatSpecter', + version, + description: 'Find and make cheats for single-player games on a jailbroken PS5 running the CheatSpecter payload.', + long_description: + 'Lets Claude work with a PS5 that has ps5debug-NG and the CheatSpecter payload loaded: see what game is running, search its memory for values, find the code that changes them, and save the result as a switch in the CheatSpecter app. For single-player games you own.', + author: { name: 'CheatSpecter' }, + license: 'GPL-3.0-only', + server: { + type: 'node', + entry_point: 'server/index.mjs', + mcp_config: { + command: 'node', + args: ['${__dirname}/server/index.mjs'], + env: { CHEATSPECTER_HOST: '${user_config.host}' }, + }, + }, + user_config: { + host: { + type: 'string', + title: 'PS5 address', + description: "Your PS5's IP address, as shown in the notification when the CheatSpecter payload starts (for example 192.168.1.50). Can be left empty and set later by asking Claude.", + required: false, + default: '', + }, + }, + tools: [], + compatibility: { runtimes: { node: '>=18.0.0' } }, +}; + +// The tool list in the manifest is what the app shows before the server runs; take it from the source so the two cannot drift. +const source = fs.readFileSync(path.join(root, 'mcp/server.ts'), 'utf8'); +for (const m of source.matchAll(/\n \{\n\s+name: '([a-z_]+)',\n\s+description:\s*\n?\s*(['"`])((?:\\.|(?!\2).)*)\2/g)) { + manifest.tools.push({ name: m[1], description: m[3].replace(/\\(['"`n])/g, (_, c) => (c === 'n' ? ' ' : c)).split('\n')[0].slice(0, 300) }); +} +fs.writeFileSync(path.join(out, 'manifest.json'), JSON.stringify(manifest, null, 2) + '\n'); + +// ---- a zip, written by hand (deflate; no dependencies) ---- +const crcTable = new Uint32Array(256).map((_, n) => { + let c = n; + for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1; + return c >>> 0; +}); +const crc32 = (buf) => { + let c = 0xffffffff; + for (const b of buf) c = crcTable[(c ^ b) & 0xff] ^ (c >>> 8); + return (c ^ 0xffffffff) >>> 0; +}; +const files = []; +const walk = (dir, rel = '') => { + for (const name of fs.readdirSync(dir).sort()) { + const full = path.join(dir, name); + const r = rel ? `${rel}/${name}` : name; + if (fs.statSync(full).isDirectory()) walk(full, r); + else files.push({ name: r, data: fs.readFileSync(full) }); + } +}; +walk(out); +const parts = []; +const central = []; +let offset = 0; +for (const f of files) { + const name = Buffer.from(f.name, 'utf8'); + const packed = zlib.deflateRawSync(f.data, { level: 9 }); + const head = Buffer.alloc(30); + head.writeUInt32LE(0x04034b50, 0); + head.writeUInt16LE(20, 4); + head.writeUInt16LE(0x0800, 6); // names are UTF-8 + head.writeUInt16LE(8, 8); // deflate + head.writeUInt16LE(0, 10); + head.writeUInt16LE(0x21, 12); // 1980-01-01, so the same input always gives the same file + head.writeUInt32LE(crc32(f.data), 14); + head.writeUInt32LE(packed.length, 18); + head.writeUInt32LE(f.data.length, 22); + head.writeUInt16LE(name.length, 26); + parts.push(head, name, packed); + const cd = Buffer.alloc(46); + cd.writeUInt32LE(0x02014b50, 0); + cd.writeUInt16LE(20, 4); + cd.writeUInt16LE(20, 6); + head.copy(cd, 8, 6, 30); // flags .. name length + cd.writeUInt32LE(offset, 42); + central.push(cd, name); + offset += head.length + name.length + packed.length; +} +const cdBuf = Buffer.concat(central); +const end = Buffer.alloc(22); +end.writeUInt32LE(0x06054b50, 0); +end.writeUInt16LE(files.length, 8); +end.writeUInt16LE(files.length, 10); +end.writeUInt32LE(cdBuf.length, 12); +end.writeUInt32LE(offset, 16); + +for (const f of fs.readdirSync(path.join(root, 'mcp'))) if (/^cheatspecter-.*\.mcpb$/.test(f)) fs.rmSync(path.join(root, 'mcp', f)); +const target = path.join(root, `mcp/cheatspecter-${version}.mcpb`); +fs.writeFileSync(target, Buffer.concat([...parts, cdBuf, end])); +console.log(`Built ${path.relative(root, target)} (${files.length} files, ${(fs.statSync(target).size / 1024).toFixed(0)} KB, ${manifest.tools.length} tools)`); diff --git a/scripts/build-payload.mjs b/scripts/build-payload.mjs new file mode 100644 index 0000000..f6346f8 --- /dev/null +++ b/scripts/build-payload.mjs @@ -0,0 +1,53 @@ +// Builds the on-console payload. +// +// node scripts/build-payload.mjs host for this computer (testing against the mock) +// node scripts/build-payload.mjs ps5 payload/cheatspecter.elf (needs PS5_PAYLOAD_SDK) +// +// Both embed the built web app from dist/, so run `npm run build` first; the +// npm scripts `payload:host` and `payload` do that for you. + +import fs from 'node:fs'; +import path from 'node:path'; +import { execFileSync } from 'node:child_process'; +import { fileURLToPath } from 'node:url'; + +const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..'); +const target = process.argv[2] ?? 'ps5'; +const payload = path.join(root, 'payload'); +const assets = path.join(payload, 'build/assets.c'); +const sources = [path.join(payload, 'src/main.c'), assets]; +const flags = ['-O2', '-Wall', '-Wextra', `-I${path.join(payload, 'src')}`]; + +const run = (cmd, args) => execFileSync(cmd, args, { stdio: 'inherit' }); + +if (!fs.existsSync(path.join(root, 'dist/index.html'))) { + console.error('The web app is not built yet. Run: npm run build'); + process.exit(1); +} +run(process.execPath, [path.join(root, 'scripts/embed-assets.mjs'), path.join(root, 'dist'), assets]); + +if (target === 'host') { + const out = path.join(payload, 'build/cheatspecter-host'); + run(process.env.CC ?? 'cc', [...flags, '-o', out, ...sources, '-lpthread']); + console.log(`Built ${path.relative(root, out)}`); +} else if (target === 'ps5') { + const sdk = process.env.PS5_PAYLOAD_SDK; + if (!sdk) { + console.error('Set PS5_PAYLOAD_SDK to your ps5-payload-sdk install, e.g. /opt/ps5-payload-sdk'); + process.exit(1); + } + const out = path.join(payload, 'cheatspecter.elf'); + run(path.join(sdk, 'bin/prospero-clang'), [...flags, '-o', out, ...sources, '-lkernel_sys', '-lSceSystemService', '-lSceUserService']); + // Payload managers read the version from the file name ("name-v1.2.3.elf"), + // so the build is also written under one. Older versioned copies are removed. + const { version } = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8')); + const versioned = path.join(payload, `cheatspecter-v${version}.elf`); + for (const f of fs.readdirSync(payload)) { + if (/^cheatspecter-v[\d.]+\.elf$/.test(f)) fs.rmSync(path.join(payload, f)); + } + fs.copyFileSync(out, versioned); + console.log(`Built ${path.relative(root, out)} and ${path.relative(root, versioned)}`); +} else { + console.error('Usage: build-payload.mjs host|ps5'); + process.exit(1); +} diff --git a/scripts/dev.mjs b/scripts/dev.mjs new file mode 100644 index 0000000..8f7c271 --- /dev/null +++ b/scripts/dev.mjs @@ -0,0 +1,11 @@ +// Runs the bridge (with the demo console) and the Vite dev server together. +import { spawn } from 'node:child_process'; + +const children = [ + spawn(process.execPath, ['bridge/server.mjs', '--demo'], { stdio: 'inherit' }), + spawn(process.platform === 'win32' ? 'npx.cmd' : 'npx', ['vite'], { stdio: 'inherit' }), +]; +const stop = () => children.forEach((c) => c.kill()); +process.on('SIGINT', stop); +process.on('SIGTERM', stop); +children.forEach((c) => c.on('exit', stop)); diff --git a/scripts/embed-assets.mjs b/scripts/embed-assets.mjs new file mode 100644 index 0000000..c6e9df1 --- /dev/null +++ b/scripts/embed-assets.mjs @@ -0,0 +1,64 @@ +// Turns the built web app (dist/) into a C file the payload compiles in. +// Every file is stored gzip-compressed and served that way. +// +// node scripts/embed-assets.mjs <dist dir> <output .c> + +import fs from 'node:fs'; +import path from 'node:path'; +import zlib from 'node:zlib'; +import { fileURLToPath } from 'node:url'; + +const [distDir, outFile] = process.argv.slice(2); +if (!distDir || !outFile) { + console.error('usage: embed-assets.mjs <dist dir> <output .c>'); + process.exit(1); +} + +const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..'); +const version = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8')).version; + +const MIME = { + '.html': 'text/html; charset=utf-8', + '.js': 'text/javascript; charset=utf-8', + '.css': 'text/css; charset=utf-8', + '.svg': 'image/svg+xml', + '.json': 'application/json; charset=utf-8', + '.png': 'image/png', + '.ico': 'image/x-icon', + '.wasm': 'application/wasm', +}; + +function walk(dir, prefix = '') { + const out = []; + for (const entry of fs.readdirSync(dir, { withFileTypes: true })) { + const rel = `${prefix}/${entry.name}`; + if (entry.isDirectory()) out.push(...walk(path.join(dir, entry.name), rel)); + else out.push(rel); + } + return out.sort(); +} + +const files = walk(distDir); +if (!files.includes('/index.html')) { + console.error(`${distDir} has no index.html; run "npm run build" first`); + process.exit(1); +} + +let c = '/* Generated by scripts/embed-assets.mjs. Do not edit. */\n#include "assets.h"\n\n'; +c += `const char CS_VERSION[] = ${JSON.stringify(version)};\n\n`; +const rows = []; +let total = 0; +files.forEach((rel, i) => { + const gz = zlib.gzipSync(fs.readFileSync(path.join(distDir, rel)), { level: 9 }); + total += gz.length; + const bytes = []; + for (let o = 0; o < gz.length; o += 20) bytes.push(' ' + [...gz.subarray(o, o + 20)].join(',')); + c += `static const unsigned char asset_${i}[] = {\n${bytes.join(',\n')}\n};\n\n`; + const mime = MIME[path.extname(rel).toLowerCase()] ?? 'application/octet-stream'; + rows.push(` {${JSON.stringify(rel)}, ${JSON.stringify(mime)}, asset_${i}, sizeof asset_${i}, ${rel.startsWith('/assets/') ? 1 : 0}}`); +}); +c += `const struct asset CS_ASSETS[] = {\n${rows.join(',\n')}\n};\n\nconst int CS_ASSET_COUNT = ${files.length};\n`; + +fs.mkdirSync(path.dirname(outFile), { recursive: true }); +fs.writeFileSync(outFile, c); +console.log(`Embedded ${files.length} files, ${(total / 1024).toFixed(0)} KB compressed -> ${outFile}`); diff --git a/scripts/send-payload.mjs b/scripts/send-payload.mjs new file mode 100644 index 0000000..05fdc1a --- /dev/null +++ b/scripts/send-payload.mjs @@ -0,0 +1,48 @@ +// Sends the built payload to an ELF loader on the console. +// +// npm run payload:send -- 192.168.1.20 (loader on port 9021) +// npm run payload:send -- 192.168.1.20 9020 + +import fs from 'node:fs'; +import net from 'node:net'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; + +const [host, portArg] = process.argv.slice(2); +if (!host) { + console.error('Usage: npm run payload:send -- <PS5 IP address> [loader port, default 9021]'); + process.exit(1); +} +const port = Number(portArg ?? 9021); +const elf = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../payload/cheatspecter.elf'); +if (!fs.existsSync(elf)) { + console.error('payload/cheatspecter.elf does not exist yet. Build it with: npm run payload'); + process.exit(1); +} + +const data = fs.readFileSync(elf); +const sock = net.connect({ host, port, timeout: 5000 }); +// Some loaders keep the connection open after taking the file, so once every +// byte has gone out, a quiet connection is success, not a failure. +let sent = false; +let reported = false; +const done = () => { + if (reported) return; + reported = true; + console.log(`Sent ${(data.length / 1024).toFixed(0)} KB to ${host}:${port}. Watch the TV for the "CheatSpecter is ready" notification.`); +}; +sock.on('timeout', () => { + if (sent) { + done(); + sock.destroy(); + } else sock.destroy(new Error('timed out')); +}); +sock.on('connect', () => sock.end(data, () => (sent = true))); +sock.on('close', (hadError) => { + if (!hadError && sent) done(); +}); +sock.on('error', (err) => { + if (reported) return; + console.error(`Could not send to ${host}:${port} (${err.message}). Is an ELF loader running on the console?`); + process.exitCode = 1; +}); diff --git a/src/components/kibo-ui/banner/index.tsx b/src/components/kibo-ui/banner/index.tsx new file mode 100644 index 0000000..bc1b916 --- /dev/null +++ b/src/components/kibo-ui/banner/index.tsx @@ -0,0 +1,142 @@ +"use client"; + +import { useControllableState } from "@radix-ui/react-use-controllable-state"; +import { type LucideIcon, XIcon } from "lucide-react"; +import { + type ComponentProps, + createContext, + type HTMLAttributes, + type MouseEventHandler, + useContext, +} from "react"; +import { Button } from "@/components/ui/button"; +import { cn } from "@/lib/utils"; + +type BannerContextProps = { + show: boolean; + setShow: (show: boolean) => void; +}; + +export const BannerContext = createContext<BannerContextProps>({ + show: true, + setShow: () => {}, +}); + +export type BannerProps = HTMLAttributes<HTMLDivElement> & { + visible?: boolean; + defaultVisible?: boolean; + onClose?: () => void; + inset?: boolean; +}; + +export const Banner = ({ + children, + visible, + defaultVisible = true, + onClose, + className, + inset = false, + ...props +}: BannerProps) => { + const [show, setShow] = useControllableState({ + defaultProp: defaultVisible, + prop: visible, + onChange: onClose, + }); + + if (!show) { + return null; + } + + return ( + <BannerContext.Provider value={{ show, setShow }}> + <div + className={cn( + "flex w-full items-center justify-between gap-2 bg-primary px-4 py-2 text-primary-foreground", + inset && "rounded-lg", + className + )} + {...props} + > + {children} + </div> + </BannerContext.Provider> + ); +}; + +export type BannerIconProps = HTMLAttributes<HTMLDivElement> & { + icon: LucideIcon; +}; + +export const BannerIcon = ({ + icon: Icon, + className, + ...props +}: BannerIconProps) => ( + <div + className={cn( + "rounded-full border border-background/20 bg-background/10 p-1 shadow-sm", + className + )} + {...props} + > + <Icon size={16} /> + </div> +); + +export type BannerTitleProps = HTMLAttributes<HTMLParagraphElement>; + +export const BannerTitle = ({ className, ...props }: BannerTitleProps) => ( + <p className={cn("flex-1 text-sm", className)} {...props} /> +); + +export type BannerActionProps = ComponentProps<typeof Button>; + +export const BannerAction = ({ + variant = "outline", + size = "sm", + className, + ...props +}: BannerActionProps) => ( + <Button + className={cn( + "shrink-0 bg-transparent hover:bg-background/10 hover:text-background", + className + )} + size={size} + variant={variant} + {...props} + /> +); + +export type BannerCloseProps = ComponentProps<typeof Button>; + +export const BannerClose = ({ + variant = "ghost", + size = "icon", + onClick, + className, + ...props +}: BannerCloseProps) => { + const { setShow } = useContext(BannerContext); + + const handleClick: MouseEventHandler<HTMLButtonElement> = (e) => { + setShow(false); + onClick?.(e); + }; + + return ( + <Button + className={cn( + "shrink-0 bg-transparent hover:bg-background/10 hover:text-background", + className + )} + onClick={handleClick} + size={size} + variant={variant} + {...props} + > + <XIcon size={18} /> + </Button> + ); +}; diff --git a/src/components/kibo-ui/dropzone/index.tsx b/src/components/kibo-ui/dropzone/index.tsx new file mode 100644 index 0000000..4633adc --- /dev/null +++ b/src/components/kibo-ui/dropzone/index.tsx @@ -0,0 +1,202 @@ +"use client"; + +import { UploadIcon } from "lucide-react"; +import type { ReactNode } from "react"; +import { createContext, useContext } from "react"; +import type { DropEvent, DropzoneOptions, FileRejection } from "react-dropzone"; +import { useDropzone } from "react-dropzone"; +import { Button } from "@/components/ui/button"; +import { cn } from "@/lib/utils"; + +type DropzoneContextType = { + src?: File[]; + accept?: DropzoneOptions["accept"]; + maxSize?: DropzoneOptions["maxSize"]; + minSize?: DropzoneOptions["minSize"]; + maxFiles?: DropzoneOptions["maxFiles"]; +}; + +const renderBytes = (bytes: number) => { + const units = ["B", "KB", "MB", "GB", "TB", "PB"]; + let size = bytes; + let unitIndex = 0; + + while (size >= 1024 && unitIndex < units.length - 1) { + size /= 1024; + unitIndex++; + } + + return `${size.toFixed(2)}${units[unitIndex]}`; +}; + +const DropzoneContext = createContext<DropzoneContextType | undefined>( + undefined +); + +export type DropzoneProps = Omit<DropzoneOptions, "onDrop"> & { + src?: File[]; + className?: string; + onDrop?: ( + acceptedFiles: File[], + fileRejections: FileRejection[], + event: DropEvent + ) => void; + children?: ReactNode; +}; + +export const Dropzone = ({ + accept, + maxFiles = 1, + maxSize, + minSize, + onDrop, + onError, + disabled, + src, + className, + children, + ...props +}: DropzoneProps) => { + const { getRootProps, getInputProps, isDragActive } = useDropzone({ + accept, + maxFiles, + maxSize, + minSize, + onError, + disabled, + onDrop: (acceptedFiles, fileRejections, event) => { + if (fileRejections.length > 0) { + const message = fileRejections.at(0)?.errors.at(0)?.message; + onError?.(new Error(message)); + return; + } + + onDrop?.(acceptedFiles, fileRejections, event); + }, + ...props, + }); + + return ( + <DropzoneContext.Provider + key={JSON.stringify(src)} + value={{ src, accept, maxSize, minSize, maxFiles }} + > + <Button + className={cn( + "relative h-auto w-full flex-col overflow-hidden p-8", + isDragActive && "outline-none ring-1 ring-ring", + className + )} + disabled={disabled} + type="button" + variant="outline" + {...getRootProps()} + > + <input {...getInputProps()} disabled={disabled} /> + {children} + </Button> + </DropzoneContext.Provider> + ); +}; + +const useDropzoneContext = () => { + const context = useContext(DropzoneContext); + + if (!context) { + throw new Error("useDropzoneContext must be used within a Dropzone"); + } + + return context; +}; + +export type DropzoneContentProps = { + children?: ReactNode; + className?: string; +}; + +const maxLabelItems = 3; + +export const DropzoneContent = ({ + children, + className, +}: DropzoneContentProps) => { + const { src } = useDropzoneContext(); + + if (!src) { + return null; + } + + if (children) { + return children; + } + + return ( + <div className={cn("flex flex-col items-center justify-center", className)}> + <div className="flex size-8 items-center justify-center rounded-md bg-muted text-muted-foreground"> + <UploadIcon size={16} /> + </div> + <p className="my-2 w-full truncate font-medium text-sm"> + {src.length > maxLabelItems + ? `${new Intl.ListFormat("en").format( + src.slice(0, maxLabelItems).map((file) => file.name) + )} and ${src.length - maxLabelItems} more` + : new Intl.ListFormat("en").format(src.map((file) => file.name))} + </p> + <p className="w-full text-wrap text-muted-foreground text-xs"> + Drag and drop or click to replace + </p> + </div> + ); +}; + +export type DropzoneEmptyStateProps = { + children?: ReactNode; + className?: string; +}; + +export const DropzoneEmptyState = ({ + children, + className, +}: DropzoneEmptyStateProps) => { + const { src, accept, maxSize, minSize, maxFiles } = useDropzoneContext(); + + if (src) { + return null; + } + + if (children) { + return children; + } + + let caption = ""; + + if (accept) { + caption += "Accepts "; + caption += new Intl.ListFormat("en").format(Object.keys(accept)); + } + + if (minSize && maxSize) { + caption += ` between ${renderBytes(minSize)} and ${renderBytes(maxSize)}`; + } else if (minSize) { + caption += ` at least ${renderBytes(minSize)}`; + } else if (maxSize) { + caption += ` less than ${renderBytes(maxSize)}`; + } + + return ( + <div className={cn("flex flex-col items-center justify-center", className)}> + <div className="flex size-8 items-center justify-center rounded-md bg-muted text-muted-foreground"> + <UploadIcon size={16} /> + </div> + <p className="my-2 w-full truncate text-wrap font-medium text-sm"> + Upload {maxFiles === 1 ? "a file" : "files"} + </p> + <p className="w-full truncate text-wrap text-muted-foreground text-xs"> + Drag and drop or click to upload + </p> + {caption && ( + <p className="text-wrap text-muted-foreground text-xs">{caption}.</p> + )} + </div> + ); +}; diff --git a/src/components/kibo-ui/pill/index.tsx b/src/components/kibo-ui/pill/index.tsx new file mode 100644 index 0000000..afcfd43 --- /dev/null +++ b/src/components/kibo-ui/pill/index.tsx @@ -0,0 +1,166 @@ +import { ChevronDownIcon, ChevronUpIcon, MinusIcon } from "lucide-react"; +import type { ComponentProps, ReactNode } from "react"; +import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; +import { Badge } from "@/components/ui/badge"; +import { Button } from "@/components/ui/button"; +import { cn } from "@/lib/utils"; + +export type PillProps = ComponentProps<typeof Badge> & { + themed?: boolean; +}; + +export const Pill = ({ + variant = "secondary", + themed = false, + className, + ...props +}: PillProps) => ( + <Badge + className={cn("gap-2 rounded-full px-3 py-1.5 font-normal", className)} + variant={variant} + {...props} + /> +); + +export type PillAvatarProps = ComponentProps<typeof AvatarImage> & { + fallback?: string; +}; + +export const PillAvatar = ({ + fallback, + className, + ...props +}: PillAvatarProps) => ( + <Avatar className={cn("-ml-1 h-4 w-4", className)}> + <AvatarImage {...props} /> + <AvatarFallback>{fallback}</AvatarFallback> + </Avatar> +); + +export type PillButtonProps = ComponentProps<typeof Button>; + +export const PillButton = ({ className, ...props }: PillButtonProps) => ( + <Button + className={cn( + "-my-2 -mr-2 size-6 rounded-full p-0.5 hover:bg-foreground/5", + className + )} + size="icon" + variant="ghost" + {...props} + /> +); + +export type PillStatusProps = { + children: ReactNode; + className?: string; +}; + +export const PillStatus = ({ + children, + className, + ...props +}: PillStatusProps) => ( + <div + className={cn( + "flex items-center gap-2 border-r pr-2 font-medium", + className + )} + {...props} + > + {children} + </div> +); + +export type PillIndicatorProps = { + variant?: "success" | "error" | "warning" | "info"; + pulse?: boolean; +}; + +export const PillIndicator = ({ + variant = "success", + pulse = false, +}: PillIndicatorProps) => ( + <span className="relative flex size-2"> + {pulse && ( + <span + className={cn( + "absolute inline-flex h-full w-full animate-ping rounded-full opacity-75", + variant === "success" && "bg-emerald-400", + variant === "error" && "bg-rose-400", + variant === "warning" && "bg-amber-400", + variant === "info" && "bg-sky-400" + )} + /> + )} + <span + className={cn( + "relative inline-flex size-2 rounded-full", + variant === "success" && "bg-emerald-500", + variant === "error" && "bg-rose-500", + variant === "warning" && "bg-amber-500", + variant === "info" && "bg-sky-500" + )} + /> + </span> +); + +export type PillDeltaProps = { + className?: string; + delta: number; +}; + +export const PillDelta = ({ className, delta }: PillDeltaProps) => { + if (!delta) { + return ( + <MinusIcon className={cn("size-3 text-muted-foreground", className)} /> + ); + } + + if (delta > 0) { + return ( + <ChevronUpIcon className={cn("size-3 text-emerald-500", className)} /> + ); + } + + return <ChevronDownIcon className={cn("size-3 text-rose-500", className)} />; +}; + +export type PillIconProps = { + icon: typeof ChevronUpIcon; + className?: string; +}; + +export const PillIcon = ({ + icon: Icon, + className, + ...props +}: PillIconProps) => ( + <Icon + className={cn("size-3 text-muted-foreground", className)} + size={12} + {...props} + /> +); + +export type PillAvatarGroupProps = { + children: ReactNode; + className?: string; +}; + +export const PillAvatarGroup = ({ + children, + className, + ...props +}: PillAvatarGroupProps) => ( + <div + className={cn( + "-space-x-1 flex items-center", + "[&>*:not(:first-of-type)]:[mask-image:radial-gradient(circle_9px_at_-4px_50%,transparent_99%,white_100%)]", + className + )} + {...props} + > + {children} + </div> +); diff --git a/src/components/kibo-ui/spinner/index.tsx b/src/components/kibo-ui/spinner/index.tsx new file mode 100644 index 0000000..80dc816 --- /dev/null +++ b/src/components/kibo-ui/spinner/index.tsx @@ -0,0 +1,271 @@ +import { Spinner as ShadcnSpinner } from "@/components/ui/spinner"; +import { + LoaderCircleIcon, + LoaderIcon, + LoaderPinwheelIcon, + type LucideProps, +} from "lucide-react"; +import { cn } from "@/lib/utils"; + +type SpinnerVariantProps = Omit<SpinnerProps, "variant">; + +const Throbber = ({ className, ...props }: SpinnerVariantProps) => ( + <LoaderIcon className={cn("animate-spin", className)} {...props} /> +); + +const Pinwheel = ({ className, ...props }: SpinnerVariantProps) => ( + <LoaderPinwheelIcon className={cn("animate-spin", className)} {...props} /> +); + +const CircleFilled = ({ + className, + size = 24, + ...props +}: SpinnerVariantProps) => ( + <div className="relative" style={{ width: size, height: size }}> + <div className="absolute inset-0 rotate-180"> + <LoaderCircleIcon + className={cn("animate-spin", className, "text-foreground opacity-20")} + size={size} + {...props} + /> + </div> + <LoaderCircleIcon + className={cn("relative animate-spin", className)} + size={size} + {...props} + /> + </div> +); + +const Ellipsis = ({ size = 24, ...props }: SpinnerVariantProps) => { + return ( + <svg + height={size} + viewBox="0 0 24 24" + width={size} + xmlns="http://www.w3.org/2000/svg" + {...props} + > + <title>Loading... + + + + + + + + + + + ); +}; + +const Ring = ({ size = 24, ...props }: SpinnerVariantProps) => ( + + Loading... + + + + + + + + + + + +); + +const Bars = ({ size = 24, ...props }: SpinnerVariantProps) => ( + + Loading... + + + + + +); + +const Infinite = ({ size = 24, ...props }: SpinnerVariantProps) => ( + + Loading... + + + + +); + +export type SpinnerProps = LucideProps & { + variant?: + | "default" + | "throbber" + | "pinwheel" + | "circle-filled" + | "ellipsis" + | "ring" + | "bars" + | "infinite"; +}; + +export const Spinner = ({ variant, ...props }: SpinnerProps) => { + switch (variant) { + case "throbber": + return ; + case "pinwheel": + return ; + case "circle-filled": + return ; + case "ellipsis": + return ; + case "ring": + return ; + case "bars": + return ; + case "infinite": + return ; + default: + return ( + + ); + } +}; diff --git a/src/components/kibo-ui/status/index.tsx b/src/components/kibo-ui/status/index.tsx new file mode 100644 index 0000000..982f844 --- /dev/null +++ b/src/components/kibo-ui/status/index.tsx @@ -0,0 +1,62 @@ +import type { ComponentProps, HTMLAttributes } from "react"; +import { Badge } from "@/components/ui/badge"; +import { cn } from "@/lib/utils"; + +export type StatusProps = ComponentProps & { + status: "online" | "offline" | "maintenance" | "degraded"; +}; + +export const Status = ({ className, status, ...props }: StatusProps) => ( + +); + +export type StatusIndicatorProps = HTMLAttributes; + +export const StatusIndicator = ({ + className, + ...props +}: StatusIndicatorProps) => ( + + + + +); + +export type StatusLabelProps = HTMLAttributes; + +export const StatusLabel = ({ + className, + children, + ...props +}: StatusLabelProps) => ( + + {children ?? ( + <> + Online + Offline + Maintenance + Degraded + + )} + +); diff --git a/src/components/ui/alert.tsx b/src/components/ui/alert.tsx new file mode 100644 index 0000000..11ffb6b --- /dev/null +++ b/src/components/ui/alert.tsx @@ -0,0 +1,65 @@ +import * as React from "react" +import { cva, type VariantProps } from "class-variance-authority" +import { cn } from "@/lib/utils" + +const alertVariants = cva( + "relative grid w-full grid-cols-[0_1fr] items-start gap-y-0.5 rounded-lg border px-4 py-3 text-sm has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] has-[>svg]:gap-x-3 [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current", + { + variants: { + variant: { + default: "bg-card text-card-foreground", + destructive: + "bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 [&>svg]:text-current", + }, + }, + defaultVariants: { + variant: "default", + }, + } +) + +function Alert({ + className, + variant, + ...props +}: React.ComponentProps<"div"> & VariantProps) { + return ( +
+ ) +} + +function AlertTitle({ className, ...props }: React.ComponentProps<"div">) { + return ( +
+ ) +} + +function AlertDescription({ + className, + ...props +}: React.ComponentProps<"div">) { + return ( +
+ ) +} + +export { Alert, AlertTitle, AlertDescription } diff --git a/src/components/ui/avatar.tsx b/src/components/ui/avatar.tsx new file mode 100644 index 0000000..cec62fa --- /dev/null +++ b/src/components/ui/avatar.tsx @@ -0,0 +1,106 @@ +import * as React from "react" +import { cn } from "@/lib/utils" +import { Avatar as AvatarPrimitive } from "radix-ui" + +function Avatar({ + className, + size = "default", + ...props +}: React.ComponentProps & { + size?: "default" | "sm" | "lg" +}) { + return ( + + ) +} + +function AvatarImage({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function AvatarFallback({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function AvatarBadge({ className, ...props }: React.ComponentProps<"span">) { + return ( + svg]:hidden", + "group-data-[size=default]/avatar:size-2.5 group-data-[size=default]/avatar:[&>svg]:size-2", + "group-data-[size=lg]/avatar:size-3 group-data-[size=lg]/avatar:[&>svg]:size-2", + className + )} + {...props} + /> + ) +} + +function AvatarGroup({ className, ...props }: React.ComponentProps<"div">) { + return ( +
+ ) +} + +function AvatarGroupCount({ + className, + ...props +}: React.ComponentProps<"div">) { + return ( +
svg]:size-4 group-has-data-[size=lg]/avatar-group:[&>svg]:size-5 group-has-data-[size=sm]/avatar-group:[&>svg]:size-3", + className + )} + {...props} + /> + ) +} + +export { + Avatar, + AvatarImage, + AvatarFallback, + AvatarBadge, + AvatarGroup, + AvatarGroupCount, +} diff --git a/src/components/ui/badge.tsx b/src/components/ui/badge.tsx new file mode 100644 index 0000000..2b41c16 --- /dev/null +++ b/src/components/ui/badge.tsx @@ -0,0 +1,47 @@ +import * as React from "react" +import { cva, type VariantProps } from "class-variance-authority" +import { cn } from "@/lib/utils" +import { Slot } from "radix-ui" + +const badgeVariants = cva( + "inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3", + { + variants: { + variant: { + default: "bg-primary text-primary-foreground [a&]:hover:bg-primary/90", + secondary: + "bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90", + destructive: + "bg-destructive text-white focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40 [a&]:hover:bg-destructive/90", + outline: + "border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground", + ghost: "[a&]:hover:bg-accent [a&]:hover:text-accent-foreground", + link: "text-primary underline-offset-4 [a&]:hover:underline", + }, + }, + defaultVariants: { + variant: "default", + }, + } +) + +function Badge({ + className, + variant = "default", + asChild = false, + ...props +}: React.ComponentProps<"span"> & + VariantProps & { asChild?: boolean }) { + const Comp = asChild ? Slot.Root : "span" + + return ( + + ) +} + +export { Badge, badgeVariants } diff --git a/src/components/ui/button.tsx b/src/components/ui/button.tsx new file mode 100644 index 0000000..0d202d6 --- /dev/null +++ b/src/components/ui/button.tsx @@ -0,0 +1,63 @@ +import * as React from "react" +import { cva, type VariantProps } from "class-variance-authority" +import { cn } from "@/lib/utils" +import { Slot } from "radix-ui" + +const buttonVariants = cva( + "inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", + { + variants: { + variant: { + default: "bg-primary text-primary-foreground hover:bg-primary/90", + destructive: + "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40", + outline: + "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50", + secondary: + "bg-secondary text-secondary-foreground hover:bg-secondary/80", + ghost: + "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50", + link: "text-primary underline-offset-4 hover:underline", + }, + size: { + default: "h-9 px-4 py-2 has-[>svg]:px-3", + xs: "h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3", + sm: "h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5", + lg: "h-10 rounded-md px-6 has-[>svg]:px-4", + icon: "size-9", + "icon-xs": "size-6 rounded-md [&_svg:not([class*='size-'])]:size-3", + "icon-sm": "size-8", + "icon-lg": "size-10", + }, + }, + defaultVariants: { + variant: "default", + size: "default", + }, + } +) + +function Button({ + className, + variant = "default", + size = "default", + asChild = false, + ...props +}: React.ComponentProps<"button"> & + VariantProps & { + asChild?: boolean + }) { + const Comp = asChild ? Slot.Root : "button" + + return ( + + ) +} + +export { Button, buttonVariants } diff --git a/src/components/ui/card.tsx b/src/components/ui/card.tsx new file mode 100644 index 0000000..6c922ec --- /dev/null +++ b/src/components/ui/card.tsx @@ -0,0 +1,91 @@ +import * as React from "react" +import { cn } from "@/lib/utils" + +function Card({ className, ...props }: React.ComponentProps<"div">) { + return ( +
+ ) +} + +function CardHeader({ className, ...props }: React.ComponentProps<"div">) { + return ( +
+ ) +} + +function CardTitle({ className, ...props }: React.ComponentProps<"div">) { + return ( +
+ ) +} + +function CardDescription({ className, ...props }: React.ComponentProps<"div">) { + return ( +
+ ) +} + +function CardAction({ className, ...props }: React.ComponentProps<"div">) { + return ( +
+ ) +} + +function CardContent({ className, ...props }: React.ComponentProps<"div">) { + return ( +
+ ) +} + +function CardFooter({ className, ...props }: React.ComponentProps<"div">) { + return ( +
+ ) +} + +export { + Card, + CardHeader, + CardFooter, + CardTitle, + CardAction, + CardDescription, + CardContent, +} diff --git a/src/components/ui/dialog.tsx b/src/components/ui/dialog.tsx new file mode 100644 index 0000000..0a46fe3 --- /dev/null +++ b/src/components/ui/dialog.tsx @@ -0,0 +1,156 @@ +import * as React from "react" +import { cn } from "@/lib/utils" +import { XIcon } from "lucide-react" +import { Dialog as DialogPrimitive } from "radix-ui" + +import { Button } from "@/components/ui/button" + +function Dialog({ + ...props +}: React.ComponentProps) { + return +} + +function DialogTrigger({ + ...props +}: React.ComponentProps) { + return +} + +function DialogPortal({ + ...props +}: React.ComponentProps) { + return +} + +function DialogClose({ + ...props +}: React.ComponentProps) { + return +} + +function DialogOverlay({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function DialogContent({ + className, + children, + showCloseButton = true, + ...props +}: React.ComponentProps & { + showCloseButton?: boolean +}) { + return ( + + + + {children} + {showCloseButton && ( + + + Close + + )} + + + ) +} + +function DialogHeader({ className, ...props }: React.ComponentProps<"div">) { + return ( +
+ ) +} + +function DialogFooter({ + className, + showCloseButton = false, + children, + ...props +}: React.ComponentProps<"div"> & { + showCloseButton?: boolean +}) { + return ( +
+ {children} + {showCloseButton && ( + + + + )} +
+ ) +} + +function DialogTitle({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function DialogDescription({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +export { + Dialog, + DialogClose, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogOverlay, + DialogPortal, + DialogTitle, + DialogTrigger, +} diff --git a/src/components/ui/dropdown-menu.tsx b/src/components/ui/dropdown-menu.tsx new file mode 100644 index 0000000..3faa9f7 --- /dev/null +++ b/src/components/ui/dropdown-menu.tsx @@ -0,0 +1,256 @@ +"use client" + +import * as React from "react" +import { cn } from "@/lib/utils" +import { CheckIcon, ChevronRightIcon, CircleIcon } from "lucide-react" +import { DropdownMenu as DropdownMenuPrimitive } from "radix-ui" + +function DropdownMenu({ + ...props +}: React.ComponentProps) { + return +} + +function DropdownMenuPortal({ + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function DropdownMenuTrigger({ + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function DropdownMenuContent({ + className, + sideOffset = 4, + ...props +}: React.ComponentProps) { + return ( + + + + ) +} + +function DropdownMenuGroup({ + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function DropdownMenuItem({ + className, + inset, + variant = "default", + ...props +}: React.ComponentProps & { + inset?: boolean + variant?: "default" | "destructive" +}) { + return ( + + ) +} + +function DropdownMenuCheckboxItem({ + className, + children, + checked, + ...props +}: React.ComponentProps) { + return ( + + + + + + + {children} + + ) +} + +function DropdownMenuRadioGroup({ + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function DropdownMenuRadioItem({ + className, + children, + ...props +}: React.ComponentProps) { + return ( + + + + + + + {children} + + ) +} + +function DropdownMenuLabel({ + className, + inset, + ...props +}: React.ComponentProps & { + inset?: boolean +}) { + return ( + + ) +} + +function DropdownMenuSeparator({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function DropdownMenuShortcut({ + className, + ...props +}: React.ComponentProps<"span">) { + return ( + + ) +} + +function DropdownMenuSub({ + ...props +}: React.ComponentProps) { + return +} + +function DropdownMenuSubTrigger({ + className, + inset, + children, + ...props +}: React.ComponentProps & { + inset?: boolean +}) { + return ( + + {children} + + + ) +} + +function DropdownMenuSubContent({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +export { + DropdownMenu, + DropdownMenuPortal, + DropdownMenuTrigger, + DropdownMenuContent, + DropdownMenuGroup, + DropdownMenuLabel, + DropdownMenuItem, + DropdownMenuCheckboxItem, + DropdownMenuRadioGroup, + DropdownMenuRadioItem, + DropdownMenuSeparator, + DropdownMenuShortcut, + DropdownMenuSub, + DropdownMenuSubTrigger, + DropdownMenuSubContent, +} diff --git a/src/components/ui/input.tsx b/src/components/ui/input.tsx new file mode 100644 index 0000000..1e3b932 --- /dev/null +++ b/src/components/ui/input.tsx @@ -0,0 +1,20 @@ +import * as React from "react" +import { cn } from "@/lib/utils" + +function Input({ className, type, ...props }: React.ComponentProps<"input">) { + return ( + + ) +} + +export { Input } diff --git a/src/components/ui/label.tsx b/src/components/ui/label.tsx new file mode 100644 index 0000000..44b8f3b --- /dev/null +++ b/src/components/ui/label.tsx @@ -0,0 +1,21 @@ +import * as React from "react" +import { cn } from "@/lib/utils" +import { Label as LabelPrimitive } from "radix-ui" + +function Label({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +export { Label } diff --git a/src/components/ui/select.tsx b/src/components/ui/select.tsx new file mode 100644 index 0000000..6125634 --- /dev/null +++ b/src/components/ui/select.tsx @@ -0,0 +1,187 @@ +import * as React from "react" +import { cn } from "@/lib/utils" +import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from "lucide-react" +import { Select as SelectPrimitive } from "radix-ui" + +function Select({ + ...props +}: React.ComponentProps) { + return +} + +function SelectGroup({ + ...props +}: React.ComponentProps) { + return +} + +function SelectValue({ + ...props +}: React.ComponentProps) { + return +} + +function SelectTrigger({ + className, + size = "default", + children, + ...props +}: React.ComponentProps & { + size?: "sm" | "default" +}) { + return ( + + {children} + + + + + ) +} + +function SelectContent({ + className, + children, + position = "item-aligned", + align = "center", + ...props +}: React.ComponentProps) { + return ( + + + + + {children} + + + + + ) +} + +function SelectLabel({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function SelectItem({ + className, + children, + ...props +}: React.ComponentProps) { + return ( + + + + + + + {children} + + ) +} + +function SelectSeparator({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function SelectScrollUpButton({ + className, + ...props +}: React.ComponentProps) { + return ( + + + + ) +} + +function SelectScrollDownButton({ + className, + ...props +}: React.ComponentProps) { + return ( + + + + ) +} + +export { + Select, + SelectContent, + SelectGroup, + SelectItem, + SelectLabel, + SelectScrollDownButton, + SelectScrollUpButton, + SelectSeparator, + SelectTrigger, + SelectValue, +} diff --git a/src/components/ui/spinner.tsx b/src/components/ui/spinner.tsx new file mode 100644 index 0000000..9b2c982 --- /dev/null +++ b/src/components/ui/spinner.tsx @@ -0,0 +1,15 @@ +import { cn } from "@/lib/utils" +import { Loader2Icon } from "lucide-react" + +function Spinner({ className, ...props }: React.ComponentProps<"svg">) { + return ( + + ) +} + +export { Spinner } diff --git a/src/components/ui/switch.tsx b/src/components/ui/switch.tsx new file mode 100644 index 0000000..29cad0f --- /dev/null +++ b/src/components/ui/switch.tsx @@ -0,0 +1,32 @@ +import * as React from "react" +import { cn } from "@/lib/utils" +import { Switch as SwitchPrimitive } from "radix-ui" + +function Switch({ + className, + size = "default", + ...props +}: React.ComponentProps & { + size?: "sm" | "default" +}) { + return ( + + + + ) +} + +export { Switch } diff --git a/src/components/ui/table.tsx b/src/components/ui/table.tsx new file mode 100644 index 0000000..c707725 --- /dev/null +++ b/src/components/ui/table.tsx @@ -0,0 +1,115 @@ +"use client" + +import * as React from "react" +import { cn } from "@/lib/utils" + +function Table({ className, ...props }: React.ComponentProps<"table">) { + return ( +
+ + + ) +} + +function TableHeader({ className, ...props }: React.ComponentProps<"thead">) { + return ( + + ) +} + +function TableBody({ className, ...props }: React.ComponentProps<"tbody">) { + return ( + + ) +} + +function TableFooter({ className, ...props }: React.ComponentProps<"tfoot">) { + return ( + tr]:last:border-b-0", + className + )} + {...props} + /> + ) +} + +function TableRow({ className, ...props }: React.ComponentProps<"tr">) { + return ( + + ) +} + +function TableHead({ className, ...props }: React.ComponentProps<"th">) { + return ( +
[role=checkbox]]:translate-y-[2px]", + className + )} + {...props} + /> + ) +} + +function TableCell({ className, ...props }: React.ComponentProps<"td">) { + return ( + [role=checkbox]]:translate-y-[2px]", + className + )} + {...props} + /> + ) +} + +function TableCaption({ + className, + ...props +}: React.ComponentProps<"caption">) { + return ( +
+ ) +} + +export { + Table, + TableHeader, + TableBody, + TableFooter, + TableHead, + TableRow, + TableCell, + TableCaption, +} diff --git a/src/components/ui/tabs.tsx b/src/components/ui/tabs.tsx new file mode 100644 index 0000000..27365d8 --- /dev/null +++ b/src/components/ui/tabs.tsx @@ -0,0 +1,90 @@ +"use client" + +import * as React from "react" +import { cva, type VariantProps } from "class-variance-authority" +import { cn } from "@/lib/utils" +import { Tabs as TabsPrimitive } from "radix-ui" + +function Tabs({ + className, + orientation = "horizontal", + ...props +}: React.ComponentProps) { + return ( + + ) +} + +const tabsListVariants = cva( + "group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-[orientation=horizontal]/tabs:h-9 group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col data-[variant=line]:rounded-none", + { + variants: { + variant: { + default: "bg-muted", + line: "gap-1 bg-transparent", + }, + }, + defaultVariants: { + variant: "default", + }, + } +) + +function TabsList({ + className, + variant = "default", + ...props +}: React.ComponentProps & + VariantProps) { + return ( + + ) +} + +function TabsTrigger({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function TabsContent({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +export { Tabs, TabsList, TabsTrigger, TabsContent, tabsListVariants } diff --git a/src/components/ui/textarea.tsx b/src/components/ui/textarea.tsx new file mode 100644 index 0000000..8d02e03 --- /dev/null +++ b/src/components/ui/textarea.tsx @@ -0,0 +1,17 @@ +import * as React from "react" +import { cn } from "@/lib/utils" + +function Textarea({ className, ...props }: React.ComponentProps<"textarea">) { + return ( +