From f96c30e52f7c8b02f12927ff8654c44bcac0ba3e Mon Sep 17 00:00:00 2001 From: Sawyer Date: Thu, 17 Sep 2026 17:53:07 -0700 Subject: [PATCH 1/2] refactor(credentials)!: split credential-providers into corbits-credential-header and corbits-credential-mcp (CL-8339) --- apps/hub/package.json | 1 - packages/credential-providers/LICENSE | 176 ---- packages/credential-providers/README.md | 68 -- packages/credential-providers/package.json | 23 - .../http-raw-authorization-provider.test.ts | 90 -- .../src/http-raw-authorization-provider.ts | 115 --- .../src/http-x-api-key-provider.test.ts | 111 --- .../src/http-x-api-key-provider.ts | 113 --- .../src/http-x-manus-api-key-provider.test.ts | 118 --- .../src/http-x-manus-api-key-provider.ts | 110 --- packages/credential-providers/src/index.ts | 36 - .../src/mcp-origin-pinned-fetch.ts | 90 -- .../src/mcp-streamable-http-provider.test.ts | 194 ----- .../src/mcp-streamable-http-provider.ts | 76 -- .../src/resolved-bindings.ts | 45 - packages/credential-providers/tsconfig.json | 23 - .../credential-providers/tsconfig.src.json | 20 - .../tool-registry-publish/src/registry.ts | 1 - tools/granola/package.json | 1 - .../credential-wiring-e2e.drizzle.test.ts | 202 ----- tools/linear/README.md | 2 +- tools/linear/package.json | 1 - tools/linear/src/tool.test.ts | 4 +- .../credential-wiring-e2e.drizzle.test.ts | 215 ----- ...inear-raw-authorization-regression.test.ts | 74 -- tools/manus/LICENSE | 176 ---- tools/manus/README.md | 40 - tools/manus/package.json | 45 - tools/manus/src/client.test.ts | 685 --------------- tools/manus/src/client.ts | 548 ------------ tools/manus/src/index.ts | 40 - tools/manus/src/manifest.test.ts | 21 - tools/manus/src/tool.test.ts | 482 ----------- tools/manus/src/tool.ts | 809 ------------------ tools/manus/tsconfig.json | 15 - tools/manus/tsconfig.src.json | 12 - tsconfig.build.json | 6 - 37 files changed, 3 insertions(+), 4785 deletions(-) delete mode 100644 packages/credential-providers/LICENSE delete mode 100644 packages/credential-providers/README.md delete mode 100644 packages/credential-providers/package.json delete mode 100644 packages/credential-providers/src/http-raw-authorization-provider.test.ts delete mode 100644 packages/credential-providers/src/http-raw-authorization-provider.ts delete mode 100644 packages/credential-providers/src/http-x-api-key-provider.test.ts delete mode 100644 packages/credential-providers/src/http-x-api-key-provider.ts delete mode 100644 packages/credential-providers/src/http-x-manus-api-key-provider.test.ts delete mode 100644 packages/credential-providers/src/http-x-manus-api-key-provider.ts delete mode 100644 packages/credential-providers/src/index.ts delete mode 100644 packages/credential-providers/src/mcp-origin-pinned-fetch.ts delete mode 100644 packages/credential-providers/src/mcp-streamable-http-provider.test.ts delete mode 100644 packages/credential-providers/src/mcp-streamable-http-provider.ts delete mode 100644 packages/credential-providers/src/resolved-bindings.ts delete mode 100644 packages/credential-providers/tsconfig.json delete mode 100644 packages/credential-providers/tsconfig.src.json delete mode 100644 tools/granola/test/credential-wiring-e2e.drizzle.test.ts delete mode 100644 tools/linear/test/credential-wiring-e2e.drizzle.test.ts delete mode 100644 tools/linear/test/linear-raw-authorization-regression.test.ts delete mode 100644 tools/manus/LICENSE delete mode 100644 tools/manus/README.md delete mode 100644 tools/manus/package.json delete mode 100644 tools/manus/src/client.test.ts delete mode 100644 tools/manus/src/client.ts delete mode 100644 tools/manus/src/index.ts delete mode 100644 tools/manus/src/manifest.test.ts delete mode 100644 tools/manus/src/tool.test.ts delete mode 100644 tools/manus/src/tool.ts delete mode 100644 tools/manus/tsconfig.json delete mode 100644 tools/manus/tsconfig.src.json diff --git a/apps/hub/package.json b/apps/hub/package.json index a545a6b78c..bf4765fc66 100644 --- a/apps/hub/package.json +++ b/apps/hub/package.json @@ -18,7 +18,6 @@ "@corbits/artifact-ui": "workspace:*", "@corbits/artifacts": "github:corbitsdev/corbits-artifacts#5309a15d4aa504f132c54b4da08bb672b4903873", "@corbits/codex-provider": "github:corbitsdev/corbits-codex-provider#a1f475f341261c05fa8dade0c82f1246c175b5b3", - "@corbits/credential-providers": "workspace:*", "@corbits/cron": "workspace:*", "@corbits/error-sink": "workspace:*", "@corbits/hub-api-client": "workspace:*", diff --git a/packages/credential-providers/LICENSE b/packages/credential-providers/LICENSE deleted file mode 100644 index 173c3a21d0..0000000000 --- a/packages/credential-providers/LICENSE +++ /dev/null @@ -1,176 +0,0 @@ -GNU LESSER GENERAL PUBLIC LICENSE - -Version 2.1, February 1999 - -Copyright (C) 1991, 1999 Free Software Foundation, Inc. -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] - -Preamble - -The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. - -This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. - -When we speak of free software, we are referring to freedom of use, 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 this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. - -To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. - -For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. - -We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. - -To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. - -Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. - -Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. - -When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. - -We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. - -For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. - -In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. - -Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. - -The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. - -GNU LESSER GENERAL PUBLIC LICENSE -TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - -0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". - -A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. - -The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) - -"Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. - -Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. - -1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. - -You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. - -2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. - -(For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. - -3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. - -Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. - -This option is useful when you wish to copy part of the code of the Library into a program that is not a library. - -4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. - -If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. - -5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. - -However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. - -When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. - -If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) - -Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. - -6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. - -You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: - - a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. - - e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. - -For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. - -It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. - -7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. - - b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. - -8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. - -9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. - -10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. - -11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), 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 distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. - -This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. - -12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. - -13. The Free Software Foundation may publish revised and/or new versions of the Lesser 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 Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. - -14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. - -NO WARRANTY - -15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "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 LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - -16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY 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 LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - -END OF TERMS AND CONDITIONS - -How to Apply These Terms to Your New Libraries - -If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). - -To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. - - one line to give the library's name and an idea of what it does. - Copyright (C) year name of author - - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; version 2.1 of the License. - - This library 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 Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: - -Yoyodyne, Inc., hereby disclaims all copyright interest in -the library `Frob' (a library for tweaking knobs) written -by James Random Hacker. - -signature of Ty Coon, 1 April 1990 -Ty Coon, President of Vice -That's all there is to it! diff --git a/packages/credential-providers/README.md b/packages/credential-providers/README.md deleted file mode 100644 index 33e10658f7..0000000000 --- a/packages/credential-providers/README.md +++ /dev/null @@ -1,68 +0,0 @@ -# @corbits/credential-providers - -Workbench-owned `CredentialProvider` plugins for auth schemes the vendored -`@intx/harness` `http` provider doesn't cover. - -## `http-raw-authorization` - -`@intx/harness`'s built-in `createHttpCredentialProvider` (key `http`) -always sends `authorization: Bearer ` — correct for a -bearer-token API, wrong for Linear's, which expects the raw key with no -`Bearer ` prefix in `authorization`. `createHttpRawAuthorizationCredentialProvider` -(key `http-raw-authorization`) mirrors the vendored provider's -origin-pinning and `redirect: "manual"` protections exactly; only the -injected header value differs. - -Register it alongside the vendored built-ins in the sidecar's -`CredentialProviderRegistry`: - -```ts -import { builtinCredentialProviders, createCredentialProviderRegistry } from "@intx/harness"; -import { createHttpRawAuthorizationCredentialProvider } from "@corbits/credential-providers"; - -const providers = createCredentialProviderRegistry([ - ...builtinCredentialProviders(), - createHttpRawAuthorizationCredentialProvider(), -]); -``` - -A tenant's Linear credential's `provider` row must set `plugin: -"http-raw-authorization"` (not `"http"`) for its bindings to send the -header Linear's API actually expects. Every other provider row that -authenticates with a bearer token keeps `plugin: "http"`. - -## `http-x-api-key` - -Neither vendored plugin fits Exa or ScrapeCreators: both authenticate via -an `x-api-key` header, not `authorization` in any shape. -`createHttpXApiKeyCredentialProvider` (key `http-x-api-key`) mirrors the -same origin-pinning and `redirect: "manual"` protections; only the -injected header name differs. A tenant's Exa or ScrapeCreators provider -row must set `plugin: "http-x-api-key"`. - -## `http-x-manus-api-key` - -Manus authenticates via `x-manus-api-key`, not `x-api-key` and not -`authorization` in any shape. `createHttpXManusApiKeyCredentialProvider` -(key `http-x-manus-api-key`) mirrors the same origin-pinning and -`redirect: "manual"` protections; only the injected header name differs. -A tenant's Manus provider row must set `plugin: "http-x-manus-api-key"`. - -## `resolved-bindings` - -`deriveResolvedBindings` reshapes a launch-time `CredentialDelivery` -(`@intx/types/sidecar`) into the `ResolvedCredentialBinding` map -`@intx/harness`'s `createCredentialCapability` consumes for one consumer. -It is the package-side twin of the sidecar app's own -`consumerBindings` derivation (`apps/sidecar/src/step-agent-tools.ts`) — -apps stay generic, so any tool package or test that needs the same -delivery-to-bindings shape depends on this rather than hand-copying the -loop. - -## Running tests - -``` -cd packages/credential-providers && bun test -``` - -No live database or external credentials required. diff --git a/packages/credential-providers/package.json b/packages/credential-providers/package.json deleted file mode 100644 index d3405a2505..0000000000 --- a/packages/credential-providers/package.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "@corbits/credential-providers", - "version": "0.0.1", - "private": true, - "description": "Workbench-owned CredentialProvider plugins beyond @intx/harness's built-ins, for auth schemes the vendored http provider doesn't cover", - "license": "LGPL-2.1-only", - "type": "module", - "exports": { - ".": "./src/index.ts" - }, - "scripts": { - "typecheck": "tsc --noEmit", - "test": "bun test" - }, - "dependencies": { - "@intx/harness": "workspace:*", - "@intx/types": "workspace:*" - }, - "devDependencies": { - "@types/bun": "catalog:", - "typescript": "catalog:" - } -} diff --git a/packages/credential-providers/src/http-raw-authorization-provider.test.ts b/packages/credential-providers/src/http-raw-authorization-provider.test.ts deleted file mode 100644 index 99c985fe5a..0000000000 --- a/packages/credential-providers/src/http-raw-authorization-provider.test.ts +++ /dev/null @@ -1,90 +0,0 @@ -import { expect, test } from "bun:test"; - -import { - createHttpRawAuthorizationCredentialProvider, - HTTP_RAW_AUTHORIZATION_PROVIDER_KEY, -} from "./http-raw-authorization-provider"; - -const ORIGIN = "https://api.linear.app"; - -function materialSource(secret: string): { current: string } { - return { current: secret }; -} - -test("key is http-raw-authorization", () => { - expect(createHttpRawAuthorizationCredentialProvider().key).toBe( - HTTP_RAW_AUTHORIZATION_PROVIDER_KEY, - ); -}); - -test("sends the raw secret in authorization, with no Bearer prefix", async () => { - const captured: { auth: string | null } = { auth: null }; - const provider = createHttpRawAuthorizationCredentialProvider({ - fetch: async (_input, init) => { - captured.auth = (init?.headers as Headers | undefined)?.get("authorization") ?? null; - return new Response("{}", { status: 200 }); - }, - }); - const mediated = provider.shape({ - origin: ORIGIN, - readCurrentMaterial: () => ({ secret: "lin_api_key_real" }), - }); - - await mediated.fetch(`${ORIGIN}/graphql`); - - expect(captured.auth).toBe("lin_api_key_real"); - expect(captured.auth).not.toBe("Bearer lin_api_key_real"); -}); - -test("re-reads the material source per call, reflecting a rotation", async () => { - const auths: string[] = []; - const material = materialSource("original-key"); - const provider = createHttpRawAuthorizationCredentialProvider({ - fetch: async (_input, init) => { - auths.push((init?.headers as Headers | undefined)?.get("authorization") ?? ""); - return new Response("{}", { status: 200 }); - }, - }); - const mediated = provider.shape({ - origin: ORIGIN, - readCurrentMaterial: () => ({ secret: material.current }), - }); - - await mediated.fetch(`${ORIGIN}/graphql`); - material.current = "rotated-key"; - await mediated.fetch(`${ORIGIN}/graphql`); - - expect(auths).toEqual(["original-key", "rotated-key"]); -}); - -test("refuses a cross-origin request rather than leaking the secret off the pinned origin", async () => { - const provider = createHttpRawAuthorizationCredentialProvider({ - fetch: async () => new Response("{}", { status: 200 }), - }); - const mediated = provider.shape({ - origin: ORIGIN, - readCurrentMaterial: () => ({ secret: "lin_api_key_real" }), - }); - - await expect(mediated.fetch("https://evil.example.com/graphql")).rejects.toThrow( - /refusing cross-origin request/, - ); -}); - -test("forces redirect: manual so a same-origin 3xx never auto-follows off the handle", async () => { - const captured: { redirect: string | undefined } = { redirect: undefined }; - const provider = createHttpRawAuthorizationCredentialProvider({ - fetch: async (_input, init) => { - captured.redirect = init?.redirect; - return new Response("{}", { status: 200 }); - }, - }); - const mediated = provider.shape({ - origin: ORIGIN, - readCurrentMaterial: () => ({ secret: "lin_api_key_real" }), - }); - - await mediated.fetch(`${ORIGIN}/graphql`); - - expect(captured.redirect).toBe("manual"); -}); diff --git a/packages/credential-providers/src/http-raw-authorization-provider.ts b/packages/credential-providers/src/http-raw-authorization-provider.ts deleted file mode 100644 index b437d0406c..0000000000 --- a/packages/credential-providers/src/http-raw-authorization-provider.ts +++ /dev/null @@ -1,115 +0,0 @@ -// A workbench-owned `CredentialProvider`, sibling to `@intx/harness`'s -// vendored `createHttpCredentialProvider` (`@intx/harness/src/ -// credential-providers.ts`, read-only per AGENTS.md). That provider -// unconditionally sends `authorization: Bearer ` -- correct for a -// bearer-token API, but Linear's REST/GraphQL API expects the raw key with -// NO "Bearer " prefix in `authorization` (the same convention the -// pre-credential-wiring `linear-tools` client used directly). Registering -// this as a second provider plugin, keyed `http-raw-authorization`, lets a -// tenant's Linear provider row opt into the header shape its API actually -// wants without touching the vendored plugin or forking it. -// -// Every protection the vendored provider enforces is mirrored exactly: the -// handle is pinned to the credential's origin at shape time, every request -// is re-checked against that origin (a cross-origin target is refused), and -// every outbound request forces `redirect: "manual"` so a 3xx never lets a -// server redirect the raw key to a foreign host -- only the injected header -// VALUE differs. - -import type { - CredentialProvider, - CredentialShapeContext, - HttpMediatedCredential, -} from "@intx/types"; - -/** - * The minimal call signature the shaped handle needs from `fetch`. Mirrors - * `@intx/harness`'s `FetchLike` so a caller can inject a stub in tests - * without pulling the full `fetch` type's extra members. - */ -export type FetchLike = (input: string | URL | Request, init?: RequestInit) => Promise; - -export interface HttpRawAuthorizationCredentialProviderOptions { - /** - * The `fetch` the shaped handle delegates to once the request is - * origin-checked and the auth header is injected. Defaults to the global - * `fetch`; injectable so origin-pinning can be exercised without a - * network. - */ - fetch?: FetchLike; -} - -/** - * Provider plugin key a `credential` row's `plugin` column names to opt a - * binding into this raw-authorization header shape instead of the vendored - * `http` (Bearer) plugin. - */ -export const HTTP_RAW_AUTHORIZATION_PROVIDER_KEY = "http-raw-authorization"; - -/** - * Build the `http-raw-authorization` credential provider: an - * `HttpMediatedCredential` whose `fetch` sends the secret verbatim in - * `authorization`, no `Bearer ` prefix. Register it alongside - * `@intx/harness`'s `builtinCredentialProviders()` in a - * `CredentialProviderRegistry` and point a provider row's `plugin` column - * at `HTTP_RAW_AUTHORIZATION_PROVIDER_KEY` to opt that credential's - * bindings into this header shape. - */ -export function createHttpRawAuthorizationCredentialProvider( - opts?: HttpRawAuthorizationCredentialProviderOptions, -): CredentialProvider { - const fetchImpl: FetchLike = opts?.fetch ?? globalThis.fetch; - - return { - key: HTTP_RAW_AUTHORIZATION_PROVIDER_KEY, - shape(context: CredentialShapeContext): HttpMediatedCredential { - const pinnedOrigin = new URL(context.origin).origin; - - return { - kind: "http", - async fetch(input: string | URL | Request, init?: RequestInit): Promise { - const target = resolveTargetUrl(input, pinnedOrigin); - if (target.origin !== pinnedOrigin) { - throw new Error( - `http-raw-authorization credential is pinned to ${pinnedOrigin}; refusing cross-origin request to ${target.origin}`, - ); - } - - // Read the secret fresh on every call so a rotation of the - // underlying material cell reaches this handle without a rebuild. - const { secret } = context.readCurrentMaterial(); - - if (input instanceof Request) { - const headers = new Headers(input.headers); - headers.set("authorization", secret); - return fetchImpl(new Request(input, { headers, redirect: "manual" })); - } - - const headers = new Headers(init?.headers); - headers.set("authorization", secret); - return fetchImpl(target, { ...init, headers, redirect: "manual" }); - }, - dispose(): void { - // A raw-header http handle allocates no resources; nothing to - // release. - }, - }; - }, - }; -} - -/** - * Resolve the URL a request targets, matching `@intx/harness`'s own - * `resolveTargetUrl`: a relative string resolves against the pinned - * origin, an absolute string or URL keeps its own origin (refused above if - * it differs), and a `Request` already carries an absolute URL. - */ -function resolveTargetUrl(input: string | URL | Request, pinnedOrigin: string): URL { - if (typeof input === "string") { - return new URL(input, pinnedOrigin); - } - if (input instanceof URL) { - return input; - } - return new URL(input.url); -} diff --git a/packages/credential-providers/src/http-x-api-key-provider.test.ts b/packages/credential-providers/src/http-x-api-key-provider.test.ts deleted file mode 100644 index 1d2b85309f..0000000000 --- a/packages/credential-providers/src/http-x-api-key-provider.test.ts +++ /dev/null @@ -1,111 +0,0 @@ -import { expect, test } from "bun:test"; - -import { - createHttpXApiKeyCredentialProvider, - HTTP_X_API_KEY_PROVIDER_KEY, -} from "./http-x-api-key-provider"; - -const ORIGIN = "https://api.exa.ai"; - -function materialSource(secret: string): { current: string } { - return { current: secret }; -} - -test("key is http-x-api-key", () => { - expect(createHttpXApiKeyCredentialProvider().key).toBe(HTTP_X_API_KEY_PROVIDER_KEY); -}); - -test("sends the secret in x-api-key, not authorization", async () => { - const captured: { apiKey: string | null; auth: string | null } = { - apiKey: null, - auth: null, - }; - const provider = createHttpXApiKeyCredentialProvider({ - fetch: async (_input, init) => { - const headers = init?.headers as Headers | undefined; - captured.apiKey = headers?.get("x-api-key") ?? null; - captured.auth = headers?.get("authorization") ?? null; - return new Response("{}", { status: 200 }); - }, - }); - const mediated = provider.shape({ - origin: ORIGIN, - readCurrentMaterial: () => ({ secret: "exa_real_key" }), - }); - - await mediated.fetch(`${ORIGIN}/search`); - - expect(captured.apiKey).toBe("exa_real_key"); - expect(captured.auth).toBeNull(); -}); - -test("re-reads the material source per call, reflecting a rotation", async () => { - const apiKeys: string[] = []; - const material = materialSource("original-key"); - const provider = createHttpXApiKeyCredentialProvider({ - fetch: async (_input, init) => { - apiKeys.push((init?.headers as Headers | undefined)?.get("x-api-key") ?? ""); - return new Response("{}", { status: 200 }); - }, - }); - const mediated = provider.shape({ - origin: ORIGIN, - readCurrentMaterial: () => ({ secret: material.current }), - }); - - await mediated.fetch(`${ORIGIN}/search`); - material.current = "rotated-key"; - await mediated.fetch(`${ORIGIN}/search`); - - expect(apiKeys).toEqual(["original-key", "rotated-key"]); -}); - -test("refuses a cross-origin request rather than leaking the secret off the pinned origin", async () => { - const provider = createHttpXApiKeyCredentialProvider({ - fetch: async () => new Response("{}", { status: 200 }), - }); - const mediated = provider.shape({ - origin: ORIGIN, - readCurrentMaterial: () => ({ secret: "exa_real_key" }), - }); - - await expect(mediated.fetch("https://evil.example.com/search")).rejects.toThrow( - /refusing cross-origin request/, - ); -}); - -test("forces redirect: manual so a same-origin 3xx never auto-follows off the handle", async () => { - const captured: { redirect: string | undefined } = { redirect: undefined }; - const provider = createHttpXApiKeyCredentialProvider({ - fetch: async (_input, init) => { - captured.redirect = init?.redirect; - return new Response("{}", { status: 200 }); - }, - }); - const mediated = provider.shape({ - origin: ORIGIN, - readCurrentMaterial: () => ({ secret: "exa_real_key" }), - }); - - await mediated.fetch(`${ORIGIN}/search`); - - expect(captured.redirect).toBe("manual"); -}); - -test("also mediates a Request input, preserving its own headers", async () => { - const captured: { apiKey: string | null } = { apiKey: null }; - const provider = createHttpXApiKeyCredentialProvider({ - fetch: async (request) => { - captured.apiKey = (request as Request).headers.get("x-api-key"); - return new Response("{}", { status: 200 }); - }, - }); - const mediated = provider.shape({ - origin: ORIGIN, - readCurrentMaterial: () => ({ secret: "exa_real_key" }), - }); - - await mediated.fetch(new Request(`${ORIGIN}/search`, { method: "POST" })); - - expect(captured.apiKey).toBe("exa_real_key"); -}); diff --git a/packages/credential-providers/src/http-x-api-key-provider.ts b/packages/credential-providers/src/http-x-api-key-provider.ts deleted file mode 100644 index 5389969b58..0000000000 --- a/packages/credential-providers/src/http-x-api-key-provider.ts +++ /dev/null @@ -1,113 +0,0 @@ -// A workbench-owned `CredentialProvider`, sibling to -// `http-raw-authorization-provider.ts` and to `@intx/harness`'s vendored -// `createHttpCredentialProvider` (`@intx/harness/src/ -// credential-providers.ts`, read-only per AGENTS.md). Neither vendored -// plugin fits Exa or ScrapeCreators: both APIs authenticate via an -// `x-api-key` header, not `authorization` in any shape. Registering this -// as a third provider plugin, keyed `http-x-api-key`, lets a tenant's Exa -// or ScrapeCreators provider row opt into the header shape its API -// actually wants without touching or forking the vendored plugin. -// -// Every protection the sibling providers enforce is mirrored exactly: the -// handle is pinned to the credential's origin at shape time, every request -// is re-checked against that origin (a cross-origin target is refused), and -// every outbound request forces `redirect: "manual"` so a 3xx never lets a -// server redirect the key to a foreign host -- only the injected header -// NAME differs. - -import type { - CredentialProvider, - CredentialShapeContext, - HttpMediatedCredential, -} from "@intx/types"; - -/** - * The minimal call signature the shaped handle needs from `fetch`. Mirrors - * `@intx/harness`'s `FetchLike` so a caller can inject a stub in tests - * without pulling the full `fetch` type's extra members. - */ -export type FetchLike = (input: string | URL | Request, init?: RequestInit) => Promise; - -export interface HttpXApiKeyCredentialProviderOptions { - /** - * The `fetch` the shaped handle delegates to once the request is - * origin-checked and the header is injected. Defaults to the global - * `fetch`; injectable so origin-pinning can be exercised without a - * network. - */ - fetch?: FetchLike; -} - -/** - * Provider plugin key a `credential` row's `plugin` column names to opt a - * binding into an `x-api-key` header shape instead of the vendored `http` - * (Bearer) plugin or this package's own `http-raw-authorization` plugin. - */ -export const HTTP_X_API_KEY_PROVIDER_KEY = "http-x-api-key"; - -/** - * Build the `http-x-api-key` credential provider: an - * `HttpMediatedCredential` whose `fetch` sends the secret in the - * `x-api-key` header. Register it alongside `@intx/harness`'s - * `builtinCredentialProviders()` in a `CredentialProviderRegistry` and - * point a provider row's `plugin` column at `HTTP_X_API_KEY_PROVIDER_KEY` - * to opt that credential's bindings into this header shape. - */ -export function createHttpXApiKeyCredentialProvider( - opts?: HttpXApiKeyCredentialProviderOptions, -): CredentialProvider { - const fetchImpl: FetchLike = opts?.fetch ?? globalThis.fetch; - - return { - key: HTTP_X_API_KEY_PROVIDER_KEY, - shape(context: CredentialShapeContext): HttpMediatedCredential { - const pinnedOrigin = new URL(context.origin).origin; - - return { - kind: "http", - async fetch(input: string | URL | Request, init?: RequestInit): Promise { - const target = resolveTargetUrl(input, pinnedOrigin); - if (target.origin !== pinnedOrigin) { - throw new Error( - `http-x-api-key credential is pinned to ${pinnedOrigin}; refusing cross-origin request to ${target.origin}`, - ); - } - - // Read the secret fresh on every call so a rotation of the - // underlying material cell reaches this handle without a rebuild. - const { secret } = context.readCurrentMaterial(); - - if (input instanceof Request) { - const headers = new Headers(input.headers); - headers.set("x-api-key", secret); - return fetchImpl(new Request(input, { headers, redirect: "manual" })); - } - - const headers = new Headers(init?.headers); - headers.set("x-api-key", secret); - return fetchImpl(target, { ...init, headers, redirect: "manual" }); - }, - dispose(): void { - // An x-api-key http handle allocates no resources; nothing to - // release. - }, - }; - }, - }; -} - -/** - * Resolve the URL a request targets, matching `@intx/harness`'s own - * `resolveTargetUrl`: a relative string resolves against the pinned - * origin, an absolute string or URL keeps its own origin (refused above if - * it differs), and a `Request` already carries an absolute URL. - */ -function resolveTargetUrl(input: string | URL | Request, pinnedOrigin: string): URL { - if (typeof input === "string") { - return new URL(input, pinnedOrigin); - } - if (input instanceof URL) { - return input; - } - return new URL(input.url); -} diff --git a/packages/credential-providers/src/http-x-manus-api-key-provider.test.ts b/packages/credential-providers/src/http-x-manus-api-key-provider.test.ts deleted file mode 100644 index aaaf0629d8..0000000000 --- a/packages/credential-providers/src/http-x-manus-api-key-provider.test.ts +++ /dev/null @@ -1,118 +0,0 @@ -import { expect, test } from "bun:test"; - -import { - createHttpXManusApiKeyCredentialProvider, - HTTP_X_MANUS_API_KEY_PROVIDER_KEY, -} from "./http-x-manus-api-key-provider"; - -const ORIGIN = "https://api.manus.ai"; - -function materialSource(secret: string): { current: string } { - return { current: secret }; -} - -test("key is http-x-manus-api-key", () => { - expect(createHttpXManusApiKeyCredentialProvider().key).toBe(HTTP_X_MANUS_API_KEY_PROVIDER_KEY); -}); - -test("sends the secret in x-manus-api-key, not authorization or x-api-key", async () => { - const captured: { - manusKey: string | null; - apiKey: string | null; - auth: string | null; - } = { - manusKey: null, - apiKey: null, - auth: null, - }; - const provider = createHttpXManusApiKeyCredentialProvider({ - fetch: async (_input, init) => { - const headers = init?.headers as Headers | undefined; - captured.manusKey = headers?.get("x-manus-api-key") ?? null; - captured.apiKey = headers?.get("x-api-key") ?? null; - captured.auth = headers?.get("authorization") ?? null; - return new Response("{}", { status: 200 }); - }, - }); - const mediated = provider.shape({ - origin: ORIGIN, - readCurrentMaterial: () => ({ secret: "manus_real_key" }), - }); - - await mediated.fetch(`${ORIGIN}/v2/skill.list`); - - expect(captured.manusKey).toBe("manus_real_key"); - expect(captured.apiKey).toBeNull(); - expect(captured.auth).toBeNull(); -}); - -test("re-reads the material source per call, reflecting a rotation", async () => { - const manusKeys: string[] = []; - const material = materialSource("original-key"); - const provider = createHttpXManusApiKeyCredentialProvider({ - fetch: async (_input, init) => { - manusKeys.push((init?.headers as Headers | undefined)?.get("x-manus-api-key") ?? ""); - return new Response("{}", { status: 200 }); - }, - }); - const mediated = provider.shape({ - origin: ORIGIN, - readCurrentMaterial: () => ({ secret: material.current }), - }); - - await mediated.fetch(`${ORIGIN}/v2/skill.list`); - material.current = "rotated-key"; - await mediated.fetch(`${ORIGIN}/v2/skill.list`); - - expect(manusKeys).toEqual(["original-key", "rotated-key"]); -}); - -test("refuses a cross-origin request rather than leaking the secret off the pinned origin", async () => { - const provider = createHttpXManusApiKeyCredentialProvider({ - fetch: async () => new Response("{}", { status: 200 }), - }); - const mediated = provider.shape({ - origin: ORIGIN, - readCurrentMaterial: () => ({ secret: "manus_real_key" }), - }); - - await expect(mediated.fetch("https://evil.example.com/v2/skill.list")).rejects.toThrow( - /refusing cross-origin request/, - ); -}); - -test("forces redirect: manual so a same-origin 3xx never auto-follows off the handle", async () => { - const captured: { redirect: string | undefined } = { redirect: undefined }; - const provider = createHttpXManusApiKeyCredentialProvider({ - fetch: async (_input, init) => { - captured.redirect = init?.redirect; - return new Response("{}", { status: 200 }); - }, - }); - const mediated = provider.shape({ - origin: ORIGIN, - readCurrentMaterial: () => ({ secret: "manus_real_key" }), - }); - - await mediated.fetch(`${ORIGIN}/v2/skill.list`); - - expect(captured.redirect).toBe("manual"); -}); - -test("also mediates a Request input, preserving its own headers", async () => { - const captured: { manusKey: string | null } = { manusKey: null }; - const provider = createHttpXManusApiKeyCredentialProvider({ - fetch: async (request) => { - captured.manusKey = (request as Request).headers.get("x-manus-api-key"); - return new Response("{}", { status: 200 }); - }, - }); - const mediated = provider.shape({ - origin: ORIGIN, - readCurrentMaterial: () => ({ secret: "manus_real_key" }), - }); - - await mediated.fetch(new Request(`${ORIGIN}/v2/task.create`, { method: "POST" })); - - expect(captured.manusKey).toBe("manus_real_key"); -}); diff --git a/packages/credential-providers/src/http-x-manus-api-key-provider.ts b/packages/credential-providers/src/http-x-manus-api-key-provider.ts deleted file mode 100644 index 8c0223384d..0000000000 --- a/packages/credential-providers/src/http-x-manus-api-key-provider.ts +++ /dev/null @@ -1,110 +0,0 @@ -// A workbench-owned `CredentialProvider`, sibling to -// `http-x-api-key-provider.ts`. Manus authenticates via `x-manus-api-key`, -// not `x-api-key` (Exa/ScrapeCreators) and not `authorization` in any -// shape. Registering this as its own plugin, keyed `http-x-manus-api-key`, -// lets a tenant's Manus provider row opt into the header its API actually -// wants without changing the existing `http-x-api-key` plugin. -// -// Every protection the sibling providers enforce is mirrored exactly: the -// handle is pinned to the credential's origin at shape time, every request -// is re-checked against that origin (a cross-origin target is refused), and -// every outbound request forces `redirect: "manual"` so a 3xx never lets a -// server redirect the key to a foreign host -- only the injected header -// NAME differs. - -import type { - CredentialProvider, - CredentialShapeContext, - HttpMediatedCredential, -} from "@intx/types"; - -/** - * The minimal call signature the shaped handle needs from `fetch`. Mirrors - * `@intx/harness`'s `FetchLike` so a caller can inject a stub in tests - * without pulling the full `fetch` type's extra members. - */ -export type FetchLike = (input: string | URL | Request, init?: RequestInit) => Promise; - -export interface HttpXManusApiKeyCredentialProviderOptions { - /** - * The `fetch` the shaped handle delegates to once the request is - * origin-checked and the header is injected. Defaults to the global - * `fetch`; injectable so origin-pinning can be exercised without a - * network. - */ - fetch?: FetchLike; -} - -/** - * Provider plugin key a `credential` row's `plugin` column names to opt a - * binding into an `x-manus-api-key` header shape. - */ -export const HTTP_X_MANUS_API_KEY_PROVIDER_KEY = "http-x-manus-api-key"; - -/** - * Build the `http-x-manus-api-key` credential provider: an - * `HttpMediatedCredential` whose `fetch` sends the secret in the - * `x-manus-api-key` header. Register it alongside `@intx/harness`'s - * `builtinCredentialProviders()` in a `CredentialProviderRegistry` and - * point a provider row's `plugin` column at - * `HTTP_X_MANUS_API_KEY_PROVIDER_KEY` to opt that credential's bindings - * into this header shape. - */ -export function createHttpXManusApiKeyCredentialProvider( - opts?: HttpXManusApiKeyCredentialProviderOptions, -): CredentialProvider { - const fetchImpl: FetchLike = opts?.fetch ?? globalThis.fetch; - - return { - key: HTTP_X_MANUS_API_KEY_PROVIDER_KEY, - shape(context: CredentialShapeContext): HttpMediatedCredential { - const pinnedOrigin = new URL(context.origin).origin; - - return { - kind: "http", - async fetch(input: string | URL | Request, init?: RequestInit): Promise { - const target = resolveTargetUrl(input, pinnedOrigin); - if (target.origin !== pinnedOrigin) { - throw new Error( - `http-x-manus-api-key credential is pinned to ${pinnedOrigin}; refusing cross-origin request to ${target.origin}`, - ); - } - - // Read the secret fresh on every call so a rotation of the - // underlying material cell reaches this handle without a rebuild. - const { secret } = context.readCurrentMaterial(); - - if (input instanceof Request) { - const headers = new Headers(input.headers); - headers.set("x-manus-api-key", secret); - return fetchImpl(new Request(input, { headers, redirect: "manual" })); - } - - const headers = new Headers(init?.headers); - headers.set("x-manus-api-key", secret); - return fetchImpl(target, { ...init, headers, redirect: "manual" }); - }, - dispose(): void { - // An x-manus-api-key http handle allocates no resources; nothing - // to release. - }, - }; - }, - }; -} - -/** - * Resolve the URL a request targets, matching `@intx/harness`'s own - * `resolveTargetUrl`: a relative string resolves against the pinned - * origin, an absolute string or URL keeps its own origin (refused above if - * it differs), and a `Request` already carries an absolute URL. - */ -function resolveTargetUrl(input: string | URL | Request, pinnedOrigin: string): URL { - if (typeof input === "string") { - return new URL(input, pinnedOrigin); - } - if (input instanceof URL) { - return input; - } - return new URL(input.url); -} diff --git a/packages/credential-providers/src/index.ts b/packages/credential-providers/src/index.ts deleted file mode 100644 index 9be63ed939..0000000000 --- a/packages/credential-providers/src/index.ts +++ /dev/null @@ -1,36 +0,0 @@ -export { - createHttpRawAuthorizationCredentialProvider, - HTTP_RAW_AUTHORIZATION_PROVIDER_KEY, -} from "./http-raw-authorization-provider"; -export type { - FetchLike, - HttpRawAuthorizationCredentialProviderOptions, -} from "./http-raw-authorization-provider"; - -export { - createHttpXApiKeyCredentialProvider, - HTTP_X_API_KEY_PROVIDER_KEY, -} from "./http-x-api-key-provider"; -export type { HttpXApiKeyCredentialProviderOptions } from "./http-x-api-key-provider"; - -export { - createHttpXManusApiKeyCredentialProvider, - HTTP_X_MANUS_API_KEY_PROVIDER_KEY, -} from "./http-x-manus-api-key-provider"; -export type { HttpXManusApiKeyCredentialProviderOptions } from "./http-x-manus-api-key-provider"; - -export { deriveResolvedBindings } from "./resolved-bindings"; - -export { - createMcpStreamableHttpCredentialProvider, - MCP_NO_TOKEN_SENTINEL, - MCP_STREAMABLE_HTTP_PROVIDER_KEY, -} from "./mcp-streamable-http-provider"; -export type { McpStreamableHttpCredentialProviderOptions } from "./mcp-streamable-http-provider"; - -export { - assertMcpPinnedTarget, - mcpOriginPinnedFetch, - resolveMcpTargetUrl, -} from "./mcp-origin-pinned-fetch"; -export type { McpOriginPinnedFetchArgs } from "./mcp-origin-pinned-fetch"; diff --git a/packages/credential-providers/src/mcp-origin-pinned-fetch.ts b/packages/credential-providers/src/mcp-origin-pinned-fetch.ts deleted file mode 100644 index 64cd4a1381..0000000000 --- a/packages/credential-providers/src/mcp-origin-pinned-fetch.ts +++ /dev/null @@ -1,90 +0,0 @@ -// Shared origin pin for MCP Streamable HTTP: the credential provider and -// the connect-time probe must refuse the same cross-origin first hops and -// never follow a 3xx (even to an allowlisted origin). Extra origins are -// an explicit map keyed by the pinned origin — not a host suffix. - -import type { FetchLike } from "./http-x-api-key-provider"; - -/** - * Additional first-hop origins a pinned MCP credential may call. Only - * `https://mcp.canva.com` → `https://canva.ai`: Canva's MCP protocol - * origin is not the stored `apiBaseUrl` origin. - */ -const MCP_PINNED_ORIGIN_EXTRAS: Readonly> = { - "https://mcp.canva.com": ["https://canva.ai"], -}; - -export interface McpOriginPinnedFetchArgs { - /** Origin the handle is pinned to (`new URL(context.origin).origin`). */ - pinnedOrigin: string; - /** Injectable `fetch`; defaults to the global `fetch`. */ - fetch?: FetchLike; - /** - * Secret for this request. Called per fetch so a rotation reaches the - * handle without a rebuild. `undefined` or empty omits `authorization` - * (keyless / sentinel already translated by the caller). - */ - readToken: () => string | undefined; -} - -/** - * Resolve the URL a request targets: a relative string resolves against - * the pinned origin, an absolute string or URL keeps its own origin, and - * a `Request` already carries an absolute URL. - */ -export function resolveMcpTargetUrl(input: string | URL | Request, pinnedOrigin: string): URL { - if (typeof input === "string") { - return new URL(input, pinnedOrigin); - } - if (input instanceof URL) { - return input; - } - return new URL(input.url); -} - -/** - * Throw if `target` is neither the pinned origin nor an explicit extra - * origin for that pin. Error text matches the mcp-streamable-http - * provider's historical refusal. - */ -export function assertMcpPinnedTarget(target: URL, pinnedOrigin: string): void { - if (target.origin === pinnedOrigin) return; - const extras = MCP_PINNED_ORIGIN_EXTRAS[pinnedOrigin]; - if (extras !== undefined && extras.includes(target.origin)) return; - throw new Error( - `mcp-streamable-http credential is pinned to ${pinnedOrigin}; refusing cross-origin request to ${target.origin}`, - ); -} - -function applyAuthorization(headers: Headers, token: string | undefined): void { - if (token === undefined || token.length === 0) { - headers.delete("authorization"); - return; - } - headers.set("authorization", `Bearer ${token}`); -} - -/** - * Fetch that origin-checks every request, injects Bearer when a token is - * present, and forces `redirect: "manual"` so a 3xx never sends a token - * (or a keyless handshake) to a foreign host. - */ -export function mcpOriginPinnedFetch(args: McpOriginPinnedFetchArgs): FetchLike { - const fetchImpl: FetchLike = args.fetch ?? globalThis.fetch; - - return async (input: string | URL | Request, init?: RequestInit): Promise => { - const target = resolveMcpTargetUrl(input, args.pinnedOrigin); - assertMcpPinnedTarget(target, args.pinnedOrigin); - const token = args.readToken(); - - if (input instanceof Request) { - const headers = new Headers(input.headers); - applyAuthorization(headers, token); - return fetchImpl(new Request(input, { headers, redirect: "manual" })); - } - - const headers = new Headers(init?.headers); - applyAuthorization(headers, token); - return fetchImpl(target, { ...init, headers, redirect: "manual" }); - }; -} diff --git a/packages/credential-providers/src/mcp-streamable-http-provider.test.ts b/packages/credential-providers/src/mcp-streamable-http-provider.test.ts deleted file mode 100644 index b1f88d8732..0000000000 --- a/packages/credential-providers/src/mcp-streamable-http-provider.test.ts +++ /dev/null @@ -1,194 +0,0 @@ -// Tests for the `mcp-streamable-http` provider: Bearer for a real token, -// NO authorization header at all for the keyless sentinel (a public MCP -// server like Exa accepts an absent header but 401s a bogus bearer), and -// the same origin-pinning + manual-redirect protections its sibling -// providers enforce. Canva's MCP protocol origin `https://canva.ai` is an -// explicit extra first hop when the credential is pinned to -// `https://mcp.canva.com` — never a host-suffix, never followed via 3xx. -import { describe, expect, test } from "bun:test"; -import type { CredentialShapeContext } from "@intx/types"; - -import { - createMcpStreamableHttpCredentialProvider, - MCP_NO_TOKEN_SENTINEL, - MCP_STREAMABLE_HTTP_PROVIDER_KEY, -} from "./mcp-streamable-http-provider"; - -function contextWith( - secret: string, - origin = "https://mcp.example.test/mcp", -): CredentialShapeContext { - return { - origin, - readCurrentMaterial: () => ({ secret }), - } as CredentialShapeContext; -} - -function capturingFetch(respond?: (input: string | URL | Request, init?: RequestInit) => Response) { - const seen: { url: string; headers: Headers; redirect?: string }[] = []; - const fetchImpl = async ( - input: string | URL | Request, - init?: RequestInit, - ): Promise => { - if (input instanceof Request) { - seen.push({ - url: input.url, - headers: new Headers(input.headers), - ...(input.redirect !== undefined ? { redirect: input.redirect } : {}), - }); - } else { - seen.push({ - url: String(input), - headers: new Headers(init?.headers), - ...(init?.redirect !== undefined ? { redirect: init.redirect } : {}), - }); - } - return respond?.(input, init) ?? new Response("ok"); - }; - return { seen, fetchImpl }; -} - -describe(MCP_STREAMABLE_HTTP_PROVIDER_KEY, () => { - test("a real token is sent as a Bearer authorization header", async () => { - const { seen, fetchImpl } = capturingFetch(); - const provider = createMcpStreamableHttpCredentialProvider({ - fetch: fetchImpl, - }); - const shaped = provider.shape(contextWith("tok-123")); - if (shaped.kind !== "http") throw new Error("expected http"); - await shaped.fetch("https://mcp.example.test/mcp"); - expect(seen[0]?.headers.get("authorization")).toBe("Bearer tok-123"); - }); - - test("the keyless sentinel sends NO authorization header", async () => { - const { seen, fetchImpl } = capturingFetch(); - const provider = createMcpStreamableHttpCredentialProvider({ - fetch: fetchImpl, - }); - const shaped = provider.shape(contextWith(MCP_NO_TOKEN_SENTINEL)); - if (shaped.kind !== "http") throw new Error("expected http"); - await shaped.fetch("https://mcp.example.test/mcp"); - expect(seen[0]?.headers.has("authorization")).toBe(false); - expect(seen[0]?.redirect).toBe("manual"); - }); - - test("a cross-origin request is refused before any fetch", async () => { - const { seen, fetchImpl } = capturingFetch(); - const provider = createMcpStreamableHttpCredentialProvider({ - fetch: fetchImpl, - }); - const shaped = provider.shape(contextWith("tok-123")); - if (shaped.kind !== "http") throw new Error("expected http"); - await expect(shaped.fetch("https://evil.example/steal")).rejects.toThrow(/pinned to/); - expect(seen).toHaveLength(0); - }); - - test("a Request input keeps its headers and gains the bearer", async () => { - const { seen, fetchImpl } = capturingFetch(); - const provider = createMcpStreamableHttpCredentialProvider({ - fetch: fetchImpl, - }); - const shaped = provider.shape(contextWith("tok-9")); - if (shaped.kind !== "http") throw new Error("expected http"); - await shaped.fetch( - new Request("https://mcp.example.test/mcp", { - headers: { "content-type": "application/json" }, - }), - ); - expect(seen[0]?.headers.get("content-type")).toBe("application/json"); - expect(seen[0]?.headers.get("authorization")).toBe("Bearer tok-9"); - }); - - test("https://canva.ai is allowed as a first hop when pinned to https://mcp.canva.com", async () => { - const { seen, fetchImpl } = capturingFetch(); - const provider = createMcpStreamableHttpCredentialProvider({ - fetch: fetchImpl, - }); - const shaped = provider.shape(contextWith("tok-canva", "https://mcp.canva.com/mcp")); - if (shaped.kind !== "http") throw new Error("expected http"); - await shaped.fetch("https://canva.ai/mcp"); - expect(seen).toHaveLength(1); - expect(seen[0]?.url).toBe("https://canva.ai/mcp"); - expect(seen[0]?.headers.get("authorization")).toBe("Bearer tok-canva"); - expect(seen[0]?.redirect).toBe("manual"); - }); - - test("https://evil.example is refused when pinned to https://mcp.canva.com", async () => { - const { seen, fetchImpl } = capturingFetch(); - const provider = createMcpStreamableHttpCredentialProvider({ - fetch: fetchImpl, - }); - const shaped = provider.shape(contextWith("tok-canva", "https://mcp.canva.com/mcp")); - if (shaped.kind !== "http") throw new Error("expected http"); - await expect(shaped.fetch("https://evil.example/steal")).rejects.toThrow( - "mcp-streamable-http credential is pinned to https://mcp.canva.com; refusing cross-origin request to https://evil.example", - ); - expect(seen).toHaveLength(0); - }); - - test("https://notcanva.com is refused when pinned to https://mcp.canva.com", async () => { - const { seen, fetchImpl } = capturingFetch(); - const provider = createMcpStreamableHttpCredentialProvider({ - fetch: fetchImpl, - }); - const shaped = provider.shape(contextWith("tok-canva", "https://mcp.canva.com/mcp")); - if (shaped.kind !== "http") throw new Error("expected http"); - await expect(shaped.fetch("https://notcanva.com/mcp")).rejects.toThrow( - "mcp-streamable-http credential is pinned to https://mcp.canva.com; refusing cross-origin request to https://notcanva.com", - ); - expect(seen).toHaveLength(0); - }); - - test("unlisted Canva sibling https://media.canva.com is refused", async () => { - const { seen, fetchImpl } = capturingFetch(); - const provider = createMcpStreamableHttpCredentialProvider({ - fetch: fetchImpl, - }); - const shaped = provider.shape(contextWith("tok-canva", "https://mcp.canva.com/mcp")); - if (shaped.kind !== "http") throw new Error("expected http"); - await expect(shaped.fetch("https://media.canva.com/mcp")).rejects.toThrow( - "mcp-streamable-http credential is pinned to https://mcp.canva.com; refusing cross-origin request to https://media.canva.com", - ); - expect(seen).toHaveLength(0); - }); - - test("a 302 Location to https://canva.ai is not followed", async () => { - const { seen, fetchImpl } = capturingFetch( - () => - new Response(null, { - status: 302, - headers: { Location: "https://canva.ai/mcp" }, - }), - ); - const provider = createMcpStreamableHttpCredentialProvider({ - fetch: fetchImpl, - }); - const shaped = provider.shape(contextWith("tok-canva", "https://mcp.canva.com/mcp")); - if (shaped.kind !== "http") throw new Error("expected http"); - const response = await shaped.fetch("https://mcp.canva.com/mcp"); - expect(response.status).toBe(302); - expect(seen).toHaveLength(1); - expect(seen[0]?.url).toBe("https://mcp.canva.com/mcp"); - expect(seen[0]?.redirect).toBe("manual"); - }); - - test("a 302 Location off the allowlist is not followed", async () => { - const { seen, fetchImpl } = capturingFetch( - () => - new Response(null, { - status: 302, - headers: { Location: "https://evil.example/steal" }, - }), - ); - const provider = createMcpStreamableHttpCredentialProvider({ - fetch: fetchImpl, - }); - const shaped = provider.shape(contextWith("tok-canva", "https://mcp.canva.com/mcp")); - if (shaped.kind !== "http") throw new Error("expected http"); - const response = await shaped.fetch("https://mcp.canva.com/mcp"); - expect(response.status).toBe(302); - expect(seen).toHaveLength(1); - expect(seen[0]?.url).toBe("https://mcp.canva.com/mcp"); - expect(seen[0]?.redirect).toBe("manual"); - }); -}); diff --git a/packages/credential-providers/src/mcp-streamable-http-provider.ts b/packages/credential-providers/src/mcp-streamable-http-provider.ts deleted file mode 100644 index 8dcaa4ce7b..0000000000 --- a/packages/credential-providers/src/mcp-streamable-http-provider.ts +++ /dev/null @@ -1,76 +0,0 @@ -// The MCP-server credential provider, sibling to -// `http-x-api-key-provider.ts`: a tenant-connected MCP server -// (a stored `mcp:` credential) authenticates with -// `authorization: Bearer ` when the person supplied a token, and -// with NO authorization header at all when they connected keyless. The -// vendored `http` (Bearer) plugin cannot express the keyless case — it -// always injects the stored secret, and a public MCP server like Exa -// accepts an absent header but 401s a bogus bearer — so keyless -// connections store `MCP_NO_TOKEN_SENTINEL` and this provider omits the -// header when it reads that sentinel back. -// -// Every protection the sibling providers enforce is mirrored exactly: -// the handle is pinned to the credential's origin at shape time, every -// request is re-checked against that origin (plus an explicit extra-origin -// map), and every outbound request forces `redirect: "manual"` so a 3xx -// never sends a token to a foreign host. - -import type { - CredentialProvider, - CredentialShapeContext, - HttpMediatedCredential, -} from "@intx/types"; - -import type { FetchLike } from "./http-x-api-key-provider"; -import { mcpOriginPinnedFetch } from "./mcp-origin-pinned-fetch"; - -/** - * The stored-secret sentinel for a keyless MCP-server connection. - * Credential storage requires a non-empty secret, so a tokenless server - * stores this value; this provider reads it back as "send no - * authorization header". - */ -export const MCP_NO_TOKEN_SENTINEL = "unauthenticated-mcp-server"; - -export interface McpStreamableHttpCredentialProviderOptions { - /** Injectable `fetch` for tests; defaults to the global `fetch`. */ - fetch?: FetchLike; -} - -/** - * Provider plugin key an MCP-server provider row's `plugin` column - * names. Written on connect; the sidecar registers the provider - * alongside the other workbench-owned plugins. - */ -export const MCP_STREAMABLE_HTTP_PROVIDER_KEY = "mcp-streamable-http"; - -export function createMcpStreamableHttpCredentialProvider( - opts?: McpStreamableHttpCredentialProviderOptions, -): CredentialProvider { - const fetchImpl: FetchLike = opts?.fetch ?? globalThis.fetch; - - return { - key: MCP_STREAMABLE_HTTP_PROVIDER_KEY, - shape(context: CredentialShapeContext): HttpMediatedCredential { - const pinnedOrigin = new URL(context.origin).origin; - - return { - kind: "http", - fetch: mcpOriginPinnedFetch({ - pinnedOrigin, - fetch: fetchImpl, - readToken: () => { - // Read the secret fresh on every call so a rotation of the - // underlying material cell reaches this handle without a - // rebuild. - const { secret } = context.readCurrentMaterial(); - return secret === MCP_NO_TOKEN_SENTINEL ? undefined : secret; - }, - }), - dispose(): void { - // An http handle allocates no resources; nothing to release. - }, - }; - }, - }; -} diff --git a/packages/credential-providers/src/resolved-bindings.ts b/packages/credential-providers/src/resolved-bindings.ts deleted file mode 100644 index 77e6b11ef0..0000000000 --- a/packages/credential-providers/src/resolved-bindings.ts +++ /dev/null @@ -1,45 +0,0 @@ -// Reshape a launch-time `CredentialDelivery` into the -// `ResolvedCredentialBinding` map `@intx/harness`'s -// `createCredentialCapability` consumes for one consumer. -// -// This is the same derivation `apps/sidecar/src/step-agent-tools.ts`'s -// `consumerBindings` performs from a step's live `CredentialWiring` -- -// but that function lives in the sidecar APP, and "apps stay generic; -// packages own the domain" runs one direction only: a package (this one, -// or a tool package's own tests) must never import an app. This is the -// package-side twin any tool package or test that needs the same -// delivery -> bindings shape can depend on as a real dependency, rather -// than each hand-copying the loop. `apps/sidecar/test/ -// credential-bindings-parity.test.ts` is the drift guard proving the -// sidecar's live-ref version and this plain-delivery version agree. -import type { CredentialDelivery } from "@intx/types/sidecar"; -import type { ResolvedCredentialBinding } from "@intx/harness"; - -/** - * Derive one consumer's bound credential handles from a `CredentialDelivery`. - * A binding delivered for a different consumer is skipped; a binding whose - * `credentialId` has no matching `materials` entry is skipped rather than - * thrown -- `buildCredentialDelivery` always pairs the two, so a caller - * driving a REAL delivery never hits this, and a hand-built test fixture - * that omits a material simply yields no binding for that handle. - */ -export function deriveResolvedBindings( - delivery: CredentialDelivery, - consumer: string, -): ReadonlyMap { - const bindings = new Map(); - for (const binding of delivery.bindings) { - if (binding.consumer !== consumer) continue; - const material = delivery.materials.find( - (entry) => entry.credentialId === binding.credentialId, - ); - if (material === undefined) continue; - bindings.set(binding.handle, { - credentialId: binding.credentialId, - providerKey: material.providerKey, - origin: material.origin, - readCurrentMaterial: () => ({ secret: material.secret }), - }); - } - return bindings; -} diff --git a/packages/credential-providers/tsconfig.json b/packages/credential-providers/tsconfig.json deleted file mode 100644 index 41729a50da..0000000000 --- a/packages/credential-providers/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "extends": "./tsconfig.src.json", - "compilerOptions": { - "composite": false, - "noEmit": true, - "disableSourceOfProjectReferenceRedirect": true, - "declaration": false, - "declarationMap": false, - "emitDeclarationOnly": false, - "tsBuildInfoFile": "tsconfig.tsbuildinfo", - "rootDir": "../.." - }, - "include": ["src"], - "exclude": [], - "references": [ - { - "path": "../../vendor/intx/harness/tsconfig.src.json" - }, - { - "path": "../../vendor/intx/types/tsconfig.src.json" - } - ] -} diff --git a/packages/credential-providers/tsconfig.src.json b/packages/credential-providers/tsconfig.src.json deleted file mode 100644 index 1a4c19e48f..0000000000 --- a/packages/credential-providers/tsconfig.src.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "include": ["src", "package.json", "src/**/*.json"], - "exclude": ["src/**/*.test.ts", "src/**/*.test.tsx"], - "compilerOptions": { - "types": ["bun"], - "composite": true, - "emitDeclarationOnly": true, - "outDir": "dist", - "tsBuildInfoFile": "dist/tsconfig.tsbuildinfo" - }, - "references": [ - { - "path": "../../vendor/intx/harness/tsconfig.src.json" - }, - { - "path": "../../vendor/intx/types/tsconfig.src.json" - } - ] -} diff --git a/packages/tool-registry-publish/src/registry.ts b/packages/tool-registry-publish/src/registry.ts index 5967ac993d..1e6194309c 100644 --- a/packages/tool-registry-publish/src/registry.ts +++ b/packages/tool-registry-publish/src/registry.ts @@ -66,7 +66,6 @@ export const CORBITS_TOOL_PACKAGE_DIRS: readonly string[] = [ new URL("../../../tools/github", import.meta.url).pathname, new URL("../../../tools/web-search", import.meta.url).pathname, new URL("../../../tools/granola", import.meta.url).pathname, - new URL("../../../tools/manus", import.meta.url).pathname, new URL("../../../tools/linear", import.meta.url).pathname, new URL("../../../tools/workflow-authoring", import.meta.url).pathname, ]; diff --git a/tools/granola/package.json b/tools/granola/package.json index 603c5e8182..2ee059f323 100644 --- a/tools/granola/package.json +++ b/tools/granola/package.json @@ -28,7 +28,6 @@ "arktype": "catalog:" }, "devDependencies": { - "@corbits/credential-providers": "workspace:*", "@intx/authz": "0.3.0", "@intx/crypto": "0.3.0", "@intx/db": "workspace:*", diff --git a/tools/granola/test/credential-wiring-e2e.drizzle.test.ts b/tools/granola/test/credential-wiring-e2e.drizzle.test.ts deleted file mode 100644 index 3b8e63b50b..0000000000 --- a/tools/granola/test/credential-wiring-e2e.drizzle.test.ts +++ /dev/null @@ -1,202 +0,0 @@ -// DB-gated: skipped when no DATABASE_URL is reachable, mirroring -// `credential-delivery.drizzle.test.ts` (its own schema, never the -// developer's or the walking-skeleton suite's). -// -// Proves the FULL "connect once, workflows just work" chain end to end -// through the platform's own, already-built functions -- never a -// hand-rolled resolver or a fake credential: -// -// 1. seed a tenant-owned Granola credential in Postgres; -// 2. `buildCredentialDelivery` (`@intx/db`, launch-time resolution) -// resolves this package's declared "granola" handle to that -// credential's decrypted secret, plus the `credential:{id}` / `use` -// grant the launch stamps; -// 3. compose the consumer-scoped `credentials` capability exactly as -// `apps/sidecar/src/step-agent-tools.ts`'s `createToolBearingAgentFactory` -// does at a real step build -- `createCredentialCapability` + -// `createHttpCredentialProvider` (`@intx/harness`) over -// `deriveResolvedBindings` (`@corbits/credential-providers`, the -// package-side twin of the sidecar's own `consumerBindings`, proven -// to agree with it by `apps/sidecar/test/ -// credential-bindings-parity.test.ts`) -- never reimplemented here; -// 4. run this package's real `granolaTools` bundle against that -// capability and assert the tool call reaches the (stubbed) network -// carrying the seeded secret as a bearer token. -// -// What this does NOT cover: driving the call through a real `Agent` + -// LLM inference cycle (`agent.send()` deciding to call the tool). No -// scripted/deterministic tool-call inference adapter exists anywhere in -// this repo today (`@intx/agent` ships no test fixtures for one). This test instead drives the tool -// bundle directly with a `ToolCall`, exactly as `../src/tool.test.ts` -// does, so what's new here is steps 1-3: a REAL seeded credential -// reaching the tool through the REAL substrate composition. -import { afterAll, beforeAll, expect, test } from "bun:test"; -import { buildCredentialDelivery, createDB, runMigrations, dropSchema } from "@intx/db"; -import { schema } from "@intx/db"; -import { createEnvKeyCredentialCipher } from "@intx/crypto"; -import { credentialAad } from "@intx/types"; -import type { CredentialBinding } from "@intx/types"; -import { toolConsumer } from "@intx/authz"; -import type { GrantRule } from "@intx/authz"; -import { - createCredentialCapability, - createCredentialProviderRegistry, - createHttpCredentialProvider, -} from "@intx/harness"; -import { deriveResolvedBindings } from "@corbits/credential-providers"; -import type { ToolCall } from "@intx/types/runtime"; - -import { dbTargetFromUrl } from "../../../scripts/db-setup"; -import { e2eDatabaseUrl } from "../../../test/database-url"; -import { GRANOLA_LIST_RECENT_NOTES_TOOL, granolaTools } from "../src/tool"; -import type { GranolaEnv } from "../src/tool"; -import { dbGate } from "../../../test/db-gate"; - -const databaseUrl = e2eDatabaseUrl(); -const describeIfDb = dbGate(databaseUrl, import.meta.path); - -const SCHEMA = "granola_tools_credential_wiring_e2e_test"; -const KEY = new Uint8Array(32).fill(11); -const CIPHER = createEnvKeyCredentialCipher(KEY); -const CONSUMER = toolConsumer("@corbits/granola-tools"); - -const GRANOLA_BINDING: CredentialBinding = { - package: "@corbits/granola-tools", - handle: "granola", - provider: "granola", - locator: "tenant", -}; - -/** A delivered binding descriptor, reshaped into the launch-time `GrantRule`. */ -function toGrantRule(descriptor: { credentialId: string; consumer: string }): GrantRule { - return { - id: "grant_launch_1", - resource: `credential:${descriptor.credentialId}`, - action: "use", - effect: "allow", - origin: "system", - conditions: { tool: descriptor.consumer }, - expiresAt: null, - roleId: null, - principalId: null, - }; -} - -describeIfDb("credential wiring end to end: seed -> delivery -> capability -> tool", () => { - const target = dbTargetFromUrl(databaseUrl ?? "postgres://localhost:5432/unused"); - - beforeAll(async () => { - await runMigrations(target, { schema: SCHEMA }); - }); - - afterAll(async () => { - await dropSchema(target, { schema: SCHEMA }); - }); - - test("a tenant-seeded credential reaches granolaTools's tool call as a bearer secret", async () => { - const { db, close } = createDB({ ...target, schema: SCHEMA }); - try { - await db.insert(schema.tenant).values({ - id: "tnt_credential_wiring_e2e", - name: "Credential Wiring E2E Tenant", - slug: "credential-wiring-e2e-tenant", - domain: "credential-wiring-e2e.workbench.test", - }); - // Seeded with `plugin: "http"`: the ONLY credential provider the - // sidecar's `createSidecarSubstrateFactory` registers - // (`createCredentialProviderRegistry(builtinCredentialProviders())`, - // `@intx/harness`'s single built-in origin-pinned bearer plugin). - await db.insert(schema.provider).values({ - id: "prov_granola_e2e", - tenantId: "tnt_credential_wiring_e2e", - name: "granola", - plugin: "http", - apiBaseUrl: "https://api.granola.ai", - }); - const credentialId = "cred_granola_e2e"; - await db.insert(schema.credential).values({ - id: credentialId, - tenantId: "tnt_credential_wiring_e2e", - providerId: "prov_granola_e2e", - name: "granola-key", - type: "api_key", - secret: await CIPHER.encrypt( - "seeded-granola-secret", - credentialAad(credentialId, "secret"), - ), - status: "active", - }); - - // Step 2: launch-time resolution, unmodified platform function. - const result = await buildCredentialDelivery({ - db, - tenantId: "tnt_credential_wiring_e2e", - bindings: [GRANOLA_BINDING], - creatorPrincipalId: null, - invokerPrincipalId: null, - credentialCipher: CIPHER, - }); - expect(result.ok).toBe(true); - if (!result.ok) throw new Error("expected delivery to resolve"); - const delivery = result.delivery; - if (delivery === undefined) throw new Error("expected a delivery"); - - // Step 3: the exact composition - // `createToolBearingAgentFactory`'s `credentialCapabilityFor` - // performs at a real step build. - const captured: { auth: string | null } = { auth: null }; - const providers = createCredentialProviderRegistry([ - createHttpCredentialProvider({ - fetch: async (_input, init) => { - captured.auth = (init?.headers as Headers | undefined)?.get("authorization") ?? null; - return new Response( - JSON.stringify({ - notes: [ - { - id: "note_1", - title: "Weekly sync", - createdAt: "2026-08-12T09:00:00.000Z", - }, - ], - }), - { status: 200 }, - ); - }, - }), - ]); - const capability = createCredentialCapability({ - consumer: CONSUMER, - bindings: deriveResolvedBindings(delivery, CONSUMER), - providers, - grants: delivery.bindings.map(toGrantRule), - }); - - // Step 4: the real tool bundle, driven exactly as - // `../src/tool.test.ts` drives it, sees the seeded secret. - const env = { credentials: capability } as unknown as GranolaEnv; - const bundle = granolaTools(env); - const call: ToolCall = { - id: "call_1", - name: GRANOLA_LIST_RECENT_NOTES_TOOL, - arguments: {}, - }; - const callResult = await bundle.run(call, new AbortController().signal); - - expect(callResult.isError).toBeUndefined(); - expect(captured.auth).toBe("Bearer seeded-granola-secret"); - expect(JSON.parse(callResult.content as string)).toEqual({ - notes: [ - { - id: "note_1", - title: "Weekly sync", - createdAt: "2026-08-12T09:00:00.000Z", - }, - ], - }); - - await capability.dispose(); - } finally { - await close(); - } - }); -}); diff --git a/tools/linear/README.md b/tools/linear/README.md index b083e3a6e9..d2e1ed2b21 100644 --- a/tools/linear/README.md +++ b/tools/linear/README.md @@ -39,7 +39,7 @@ proven in `test/credential-wiring-e2e.drizzle.test.ts`. `authorization`, not a `Bearer `-prefixed token. `@intx/harness`'s vendored `http` provider always sends Bearer, so a Linear provider row MUST set `plugin: "http-raw-authorization"` -(`@corbits/credential-providers`) rather than the `"http"` default other +(`@corbits/credential-header`) rather than the `"http"` default other connectors use — seeding it wrong sends the wrong header shape and Linear rejects the call. See `docs/credential-wiring.md` and `test/linear-raw-authorization-regression.test.ts`, a regression guard diff --git a/tools/linear/package.json b/tools/linear/package.json index 969222b112..733f7e2546 100644 --- a/tools/linear/package.json +++ b/tools/linear/package.json @@ -28,7 +28,6 @@ "arktype": "catalog:" }, "devDependencies": { - "@corbits/credential-providers": "workspace:*", "@intx/authz": "0.3.0", "@intx/crypto": "0.3.0", "@intx/db": "workspace:*", diff --git a/tools/linear/src/tool.test.ts b/tools/linear/src/tool.test.ts index f16a60e87a..779c129660 100644 --- a/tools/linear/src/tool.test.ts +++ b/tools/linear/src/tool.test.ts @@ -14,10 +14,10 @@ const CALL: ToolCall = { /** * A fake `credentials` capability mirroring the REAL provider a Linear * binding resolves through in production: - * `@corbits/credential-providers`'s `http-raw-authorization` plugin, not + * `@corbits/credential-header`'s `http-raw-authorization` preset, not * `@intx/harness`'s Bearer-prefixed `http` provider. Linear's API expects * the raw key verbatim in `authorization` (see - * `@corbits/credential-providers`'s `createHttpRawAuthorizationCredentialProvider`); + * `@corbits/credential-header`'s `rawAuthorizationCredentialProvider`); * a bound `secret` resolves to a mediated `fetch` that injects it * unprefixed and delegates to `globalThis.fetch`. An unbound handle * throws, matching the real gate's "no credential is bound to handle" diff --git a/tools/linear/test/credential-wiring-e2e.drizzle.test.ts b/tools/linear/test/credential-wiring-e2e.drizzle.test.ts deleted file mode 100644 index 6732e7a050..0000000000 --- a/tools/linear/test/credential-wiring-e2e.drizzle.test.ts +++ /dev/null @@ -1,215 +0,0 @@ -// DB-gated: skipped when no DATABASE_URL is reachable, mirroring -// `credential-delivery.drizzle.test.ts` (its own schema, never the -// developer's or the walking-skeleton suite's) and -// `@corbits/granola-tools`'s `test/credential-wiring-e2e.drizzle.test.ts` -//, which this test follows step for step. -// -// Proves the FULL "connect once, workflows just work" chain end to end -// through the platform's own, already-built functions -- never a -// hand-rolled resolver or a fake credential -- AND that the seeded -// provider row's `plugin: "http-raw-authorization"` reaches the tool -// call as Linear's raw-key `authorization` header, not the vendored -// `http` (Bearer) provider's shape a wrongly-seeded row would send (the -// bug a review caught; see `linear-raw-authorization-regression.test.ts` -// for the narrower regression guard): -// -// 1. seed a tenant-owned Linear credential in Postgres, on a provider -// row whose `plugin` is `http-raw-authorization` -// (`@corbits/credential-providers`), not `http`; -// 2. `buildCredentialDelivery` (`@intx/db`, launch-time resolution) -// resolves this package's declared "linear" handle to that -// credential's decrypted secret, plus the `credential:{id}` / `use` -// grant the launch stamps; -// 3. compose the consumer-scoped `credentials` capability exactly as -// `apps/sidecar/src/step-agent-tools.ts`'s `createToolBearingAgentFactory` -// does at a real step build -- `createCredentialCapability` -// (`@intx/harness`) over `createHttpRawAuthorizationCredentialProvider` -// and `deriveResolvedBindings` (both `@corbits/credential-providers`, -// the latter proven to agree with the sidecar's own -// `consumerBindings` by `apps/sidecar/test/ -// credential-bindings-parity.test.ts`) -- never reimplemented here; -// 4. run this package's real `linearTools` bundle against that -// capability and assert the tool call reaches the (stubbed) network -// carrying the seeded secret as Linear's raw, unprefixed header. -// -// What this does NOT cover: driving the call through a real `Agent` + -// LLM inference cycle -- see the granola-tools e2e test's header comment -// for why (no scripted tool-call inference adapter exists anywhere in -// this repo today). -import { afterAll, beforeAll, expect, test } from "bun:test"; -import { buildCredentialDelivery, createDB, runMigrations, dropSchema } from "@intx/db"; -import { schema } from "@intx/db"; -import { createEnvKeyCredentialCipher } from "@intx/crypto"; -import { credentialAad } from "@intx/types"; -import type { CredentialBinding } from "@intx/types"; -import { toolConsumer } from "@intx/authz"; -import type { GrantRule } from "@intx/authz"; -import { createCredentialCapability, createCredentialProviderRegistry } from "@intx/harness"; -import { - createHttpRawAuthorizationCredentialProvider, - deriveResolvedBindings, - HTTP_RAW_AUTHORIZATION_PROVIDER_KEY, -} from "@corbits/credential-providers"; -import type { ToolCall } from "@intx/types/runtime"; - -import { dbTargetFromUrl } from "../../../scripts/db-setup"; -import { e2eDatabaseUrl } from "../../../test/database-url"; -import { LINEAR_LIST_RECENT_ISSUES_TOOL, linearTools } from "../src/tool"; -import type { LinearEnv } from "../src/tool"; -import { dbGate } from "../../../test/db-gate"; - -const databaseUrl = e2eDatabaseUrl(); -const describeIfDb = dbGate(databaseUrl, import.meta.path); - -const SCHEMA = "linear_tools_credential_wiring_e2e_test"; -const KEY = new Uint8Array(32).fill(13); -const CIPHER = createEnvKeyCredentialCipher(KEY); -const CONSUMER = toolConsumer("@corbits/linear-tools"); - -const LINEAR_BINDING: CredentialBinding = { - package: "@corbits/linear-tools", - handle: "linear", - provider: "linear", - locator: "tenant", -}; - -/** A delivered binding descriptor, reshaped into the launch-time `GrantRule`. */ -function toGrantRule(descriptor: { credentialId: string; consumer: string }): GrantRule { - return { - id: "grant_launch_1", - resource: `credential:${descriptor.credentialId}`, - action: "use", - effect: "allow", - origin: "system", - conditions: { tool: descriptor.consumer }, - expiresAt: null, - roleId: null, - principalId: null, - }; -} - -describeIfDb("credential wiring end to end: seed -> delivery -> capability -> tool", () => { - const target = dbTargetFromUrl(databaseUrl ?? "postgres://localhost:5432/unused"); - - beforeAll(async () => { - await runMigrations(target, { schema: SCHEMA }); - }); - - afterAll(async () => { - await dropSchema(target, { schema: SCHEMA }); - }); - - test("a tenant-seeded credential reaches linearTools's tool call as Linear's raw-key header", async () => { - const { db, close } = createDB({ ...target, schema: SCHEMA }); - try { - await db.insert(schema.tenant).values({ - id: "tnt_credential_wiring_e2e_linear", - name: "Credential Wiring E2E Tenant (Linear)", - slug: "credential-wiring-e2e-tenant-linear", - domain: "credential-wiring-e2e-linear.workbench.test", - }); - // Seeded with `plugin: "http-raw-authorization"`: Linear's API - // expects the raw key in `authorization`, not a Bearer token, so - // its provider row must opt into - // `@corbits/credential-providers`'s plugin rather than the - // vendored `http` default other connectors use (see - // `docs/credential-wiring.md`). - await db.insert(schema.provider).values({ - id: "prov_linear_e2e", - tenantId: "tnt_credential_wiring_e2e_linear", - name: "linear", - plugin: HTTP_RAW_AUTHORIZATION_PROVIDER_KEY, - apiBaseUrl: "https://api.linear.app", - }); - const credentialId = "cred_linear_e2e"; - await db.insert(schema.credential).values({ - id: credentialId, - tenantId: "tnt_credential_wiring_e2e_linear", - providerId: "prov_linear_e2e", - name: "linear-key", - type: "api_key", - secret: await CIPHER.encrypt("seeded-linear-secret", credentialAad(credentialId, "secret")), - status: "active", - }); - - // Step 2: launch-time resolution, unmodified platform function. - const result = await buildCredentialDelivery({ - db, - tenantId: "tnt_credential_wiring_e2e_linear", - bindings: [LINEAR_BINDING], - creatorPrincipalId: null, - invokerPrincipalId: null, - credentialCipher: CIPHER, - }); - expect(result.ok).toBe(true); - if (!result.ok) throw new Error("expected delivery to resolve"); - const delivery = result.delivery; - if (delivery === undefined) throw new Error("expected a delivery"); - - // Step 3: the exact composition - // `createToolBearingAgentFactory`'s `credentialCapabilityFor` - // performs at a real step build. - const captured: { auth: string | null } = { auth: null }; - const providers = createCredentialProviderRegistry([ - createHttpRawAuthorizationCredentialProvider({ - fetch: async (_input, init) => { - captured.auth = (init?.headers as Headers | undefined)?.get("authorization") ?? null; - return new Response( - JSON.stringify({ - data: { - issues: { - nodes: [ - { - id: "issue_1", - identifier: "CL-1", - title: "Fix the thing", - updatedAt: "2026-08-12T09:00:00.000Z", - }, - ], - }, - }, - }), - { status: 200 }, - ); - }, - }), - ]); - const capability = createCredentialCapability({ - consumer: CONSUMER, - bindings: deriveResolvedBindings(delivery, CONSUMER), - providers, - grants: delivery.bindings.map(toGrantRule), - }); - - // Step 4: the real tool bundle, driven exactly as - // `../src/tool.test.ts` drives it, sees the seeded secret in - // Linear's expected header shape. - const env = { credentials: capability } as unknown as LinearEnv; - const bundle = linearTools(env); - const call: ToolCall = { - id: "call_1", - name: LINEAR_LIST_RECENT_ISSUES_TOOL, - arguments: {}, - }; - const callResult = await bundle.run(call, new AbortController().signal); - - expect(callResult.isError).toBeUndefined(); - expect(captured.auth).toBe("seeded-linear-secret"); - expect(captured.auth).not.toBe("Bearer seeded-linear-secret"); - expect(JSON.parse(callResult.content as string)).toEqual({ - issues: [ - { - id: "issue_1", - identifier: "CL-1", - title: "Fix the thing", - updatedAt: "2026-08-12T09:00:00.000Z", - }, - ], - }); - - await capability.dispose(); - } finally { - await close(); - } - }); -}); diff --git a/tools/linear/test/linear-raw-authorization-regression.test.ts b/tools/linear/test/linear-raw-authorization-regression.test.ts deleted file mode 100644 index 884378b481..0000000000 --- a/tools/linear/test/linear-raw-authorization-regression.test.ts +++ /dev/null @@ -1,74 +0,0 @@ -// Regression guard for a bug a review caught: driving the REAL platform -// capability (`createCredentialCapability`, `@intx/harness`) and this -// package's real client through the vendored Bearer-only -// `createHttpCredentialProvider` sent `authorization: Bearer ` — -// Linear's API expects the raw key verbatim, no "Bearer " prefix (the -// same convention this package's pre-credential-wiring client used -// directly). `@corbits/credential-providers`'s `http-raw-authorization` -// plugin fixes this without touching or forking the vendored provider; -// this test proves the fix by driving the REAL provider (not this -// package's own `tool.test.ts` fake) end to end and asserting the header -// Linear actually expects. -import { expect, test } from "bun:test"; -import { createCredentialCapability, createCredentialProviderRegistry } from "@intx/harness"; -import { toolConsumer } from "@intx/authz"; -import { - createHttpRawAuthorizationCredentialProvider, - HTTP_RAW_AUTHORIZATION_PROVIDER_KEY, -} from "@corbits/credential-providers"; - -import { listRecentLinearIssues } from "../src/client"; - -test("the real http-raw-authorization provider sends Linear's raw-key convention, not Bearer", async () => { - const captured: { auth: string | null } = { auth: null }; - const providers = createCredentialProviderRegistry([ - createHttpRawAuthorizationCredentialProvider({ - fetch: async (_input, init) => { - captured.auth = (init?.headers as Headers | undefined)?.get("authorization") ?? null; - return new Response(JSON.stringify({ data: { issues: { nodes: [] } } }), { - status: 200, - }); - }, - }), - ]); - const consumer = toolConsumer("@corbits/linear-tools"); - const capability = createCredentialCapability({ - consumer, - bindings: new Map([ - [ - "linear", - { - credentialId: "cred_1", - providerKey: HTTP_RAW_AUTHORIZATION_PROVIDER_KEY, - origin: "https://api.linear.app", - readCurrentMaterial: () => ({ secret: "lin_api_key_real" }), - }, - ], - ]), - providers, - grants: [ - { - id: "g1", - resource: "credential:cred_1", - action: "use", - effect: "allow", - origin: "system", - conditions: { tool: consumer }, - expiresAt: null, - roleId: null, - principalId: null, - }, - ], - }); - - const mediated = await capability.resolve("linear"); - await listRecentLinearIssues({ - fetchImpl: mediated.fetch as unknown as typeof fetch, - baseUrl: "https://api.linear.app", - }); - - expect(captured.auth).toBe("lin_api_key_real"); - expect(captured.auth).not.toBe("Bearer lin_api_key_real"); - - await capability.dispose(); -}); diff --git a/tools/manus/LICENSE b/tools/manus/LICENSE deleted file mode 100644 index 173c3a21d0..0000000000 --- a/tools/manus/LICENSE +++ /dev/null @@ -1,176 +0,0 @@ -GNU LESSER GENERAL PUBLIC LICENSE - -Version 2.1, February 1999 - -Copyright (C) 1991, 1999 Free Software Foundation, Inc. -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] - -Preamble - -The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. - -This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. - -When we speak of free software, we are referring to freedom of use, 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 this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. - -To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. - -For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. - -We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. - -To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. - -Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. - -Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. - -When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. - -We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. - -For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. - -In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. - -Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. - -The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. - -GNU LESSER GENERAL PUBLIC LICENSE -TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - -0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". - -A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. - -The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) - -"Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. - -Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. - -1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. - -You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. - -2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. - -(For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. - -3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. - -Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. - -This option is useful when you wish to copy part of the code of the Library into a program that is not a library. - -4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. - -If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. - -5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. - -However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. - -When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. - -If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) - -Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. - -6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. - -You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: - - a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. - - e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. - -For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. - -It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. - -7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. - - b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. - -8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. - -9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. - -10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. - -11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), 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 distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. - -This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. - -12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. - -13. The Free Software Foundation may publish revised and/or new versions of the Lesser 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 Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. - -14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. - -NO WARRANTY - -15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "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 LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - -16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY 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 LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - -END OF TERMS AND CONDITIONS - -How to Apply These Terms to Your New Libraries - -If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). - -To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. - - one line to give the library's name and an idea of what it does. - Copyright (C) year name of author - - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; version 2.1 of the License. - - This library 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 Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: - -Yoyodyne, Inc., hereby disclaims all copyright interest in -the library `Frob' (a library for tweaking knobs) written -by James Random Hacker. - -signature of Ty Coon, 1 April 1990 -Ty Coon, President of Vice -That's all there is to it! diff --git a/tools/manus/README.md b/tools/manus/README.md deleted file mode 100644 index f30920da89..0000000000 --- a/tools/manus/README.md +++ /dev/null @@ -1,40 +0,0 @@ -# @corbits/manus-tools - -Manus OpenAPI v2 integration: a typed client and an `@intx/agent` tool -bundle covering tasks, files, skills, projects, agents, webhooks, usage, -connectors, browser, and website endpoints. Slide-deck creation is the -passing demo — `create_slides` starts a task, polls messages until the -agent stops, and surfaces output files (filename, url, id). - -## Credential - -The bundle's env carries `credentials`, the harness's consumer-gated -`CredentialCapability`. When it is absent, or `credentials.resolve("manus")` -throws, the tool never throws itself: it returns a completed result with -`isError: true` and content `"Manus is not connected for this user."` - -This package declares one credential handle, `manus`, in -`package.json`'s `interchange.credentials`. Connect Manus once in Settings -· Connections (API key via `x-manus-api-key`). The client never attaches -that header — the `http-x-manus-api-key` credential plugin injects it. -The assistant workflow pins `@corbits/manus-tools` so the tools exist; it -does not require a Manus credential binding. An unconnected tenant -degrades at tool time to "Manus is not connected for this user." like -Granola, rather than failing launch. - -## Usage - -```ts -import { manusTools } from "@corbits/manus-tools"; - -const agent = defineAgent({ - // ... - tools: [manusTools], -}); -``` - -## Running tests - -``` -cd tools/manus && bun test -``` diff --git a/tools/manus/package.json b/tools/manus/package.json deleted file mode 100644 index 480c051933..0000000000 --- a/tools/manus/package.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "name": "@corbits/manus-tools", - "version": "0.0.12", - "description": "Manus integration: a v2 API client and an @intx/agent tool bundle for running tasks and retrieving files", - "license": "LGPL-2.1-only", - "repository": { - "type": "git", - "url": "https://github.com/corbitsdev/workbench.git", - "directory": "tools/manus" - }, - "files": [ - "src", - "LICENSE", - "README.md" - ], - "type": "module", - "exports": { - ".": "./src/index.ts" - }, - "publishConfig": { - "access": "public" - }, - "scripts": { - "typecheck": "tsc --noEmit", - "test": "bun test" - }, - "dependencies": { - "arktype": "catalog:" - }, - "devDependencies": { - "@types/bun": "catalog:", - "typescript": "catalog:" - }, - "peerDependencies": { - "@intx/agent": "0.3.0", - "@intx/types": "0.3.0" - }, - "interchange": { - "credentials": [ - { - "handle": "manus" - } - ] - } -} diff --git a/tools/manus/src/client.test.ts b/tools/manus/src/client.test.ts deleted file mode 100644 index 797094b40a..0000000000 --- a/tools/manus/src/client.test.ts +++ /dev/null @@ -1,685 +0,0 @@ -import { expect, test } from "bun:test"; - -import { - createSlideDeck, - createTask, - DEFAULT_SLIDE_MAX_POLLS, - DEFAULT_SLIDE_POLL_INTERVAL_MS, - extractOutputFiles, - getTaskDetail, - latestAgentStatus, - listTaskMessages, - manusRequest, - SLIDES_FORMAT_PPTX, -} from "./client"; - -test("createTask posts to /v2/task.create and parses the ok envelope", async () => { - const captured: { url: string; headers: Headers | null; body: string } = { - url: "", - headers: null, - body: "", - }; - const fetchImpl = (async (input: URL | string, init?: RequestInit) => { - captured.url = String(input); - captured.headers = init?.headers instanceof Headers ? init.headers : new Headers(init?.headers); - captured.body = typeof init?.body === "string" ? init.body : ""; - return new Response( - JSON.stringify({ - ok: true, - request_id: "req_1", - task_id: "task_1", - task_title: "Deck", - task_url: "https://manus.im/app/task_1", - }), - { status: 200 }, - ); - }) as unknown as typeof fetch; - - const created = await createTask({ fetchImpl }, { content: "Make slides" }); - expect(captured.url).toBe("https://api.manus.ai/v2/task.create"); - expect(captured.headers?.get("x-manus-api-key")).toBeNull(); - expect(captured.headers?.get("authorization")).toBeNull(); - expect(captured.headers?.get("x-api-key")).toBeNull(); - expect(JSON.parse(captured.body)).toEqual({ - message: { content: [{ type: "text", text: "Make slides" }] }, - agent_profile: "manus-1.6-lite", - }); - expect(created.task_id).toBe("task_1"); - expect(created.task_url).toBe("https://manus.im/app/task_1"); -}); - -test("createTask posts skill, connector, and schema fields only when set", async () => { - const captured: { body: string } = { body: "" }; - const fetchImpl = (async (_input: URL | string, init?: RequestInit) => { - captured.body = typeof init?.body === "string" ? init.body : ""; - return new Response( - JSON.stringify({ - ok: true, - task_id: "task_2", - }), - { status: 200 }, - ); - }) as unknown as typeof fetch; - - await createTask( - { fetchImpl }, - { - content: "Use the listed skill", - enable_skills: ["skill_abc"], - force_skills: ["skill_abc"], - connectors: ["conn_1"], - task_references: ["task_ref_1"], - structured_output_schema: { - type: "object", - properties: { title: { type: "string" } }, - required: ["title"], - additionalProperties: false, - }, - }, - ); - expect(JSON.parse(captured.body)).toEqual({ - message: { - content: [{ type: "text", text: "Use the listed skill" }], - enable_skills: ["skill_abc"], - force_skills: ["skill_abc"], - connectors: ["conn_1"], - task_references: ["task_ref_1"], - }, - structured_output_schema: { - type: "object", - properties: { title: { type: "string" } }, - required: ["title"], - additionalProperties: false, - }, - agent_profile: "manus-1.6-lite", - }); -}); - -test("getTaskDetail rejects a malformed successful task payload", async () => { - const fetchImpl = (async () => - new Response( - JSON.stringify({ - ok: true, - task: { id: "task_1", status: "completed" }, - }), - { status: 200 }, - )) as unknown as typeof fetch; - - await expect(getTaskDetail({ fetchImpl }, "task_1")).rejects.toThrow( - /task-detail response did not match the expected shape/, - ); -}); - -test("listTaskMessages GETs /v2/task.listMessages without an auth header", async () => { - const captured: { url: string; headers: Headers | null } = { - url: "", - headers: null, - }; - const fetchImpl = (async (input: URL | string, init?: RequestInit) => { - captured.url = String(input); - captured.headers = - init?.headers instanceof Headers - ? init.headers - : init?.headers !== undefined - ? new Headers(init.headers) - : null; - return new Response( - JSON.stringify({ - ok: true, - task_id: "task_1", - messages: [ - { - type: "status_update", - status_update: { agent_status: "stopped" }, - }, - ], - }), - { status: 200 }, - ); - }) as unknown as typeof fetch; - - const listed = await listTaskMessages({ fetchImpl }, { task_id: "task_1" }); - expect(captured.url).toBe("https://api.manus.ai/v2/task.listMessages?task_id=task_1"); - expect(captured.headers?.get("x-manus-api-key") ?? null).toBeNull(); - expect(listed.messages?.[0]?.status_update?.agent_status).toBe("stopped"); -}); - -test("listTaskMessages parses ISO string timestamps and still extracts status and attachments", async () => { - const fetchImpl = (async () => - new Response( - JSON.stringify({ - ok: true, - task_id: "task_1", - messages: [ - { - type: "status_update", - timestamp: "2026-08-26T12:00:00.000Z", - status_update: { agent_status: "stopped" }, - }, - { - type: "assistant_message", - timestamp: "2026-08-26T12:00:01.000Z", - assistant_message: { - content: "Here is the deck.", - attachments: [ - { - filename: "onboarding.pptx", - url: "https://files.manus.ai/onboarding.pptx", - }, - ], - }, - }, - ], - }), - { status: 200 }, - )) as unknown as typeof fetch; - - const listed = await listTaskMessages({ fetchImpl }, { task_id: "task_1" }); - expect(listed.messages?.[0]?.timestamp).toBe("2026-08-26T12:00:00.000Z"); - expect(latestAgentStatus(listed.messages)).toBe("stopped"); - expect(extractOutputFiles(listed.messages)).toEqual([ - { - filename: "onboarding.pptx", - url: "https://files.manus.ai/onboarding.pptx", - }, - ]); -}); - -test("listTaskMessages parses numeric timestamps", async () => { - const fetchImpl = (async () => - new Response( - JSON.stringify({ - ok: true, - task_id: "task_1", - messages: [ - { - type: "status_update", - timestamp: 1756224000, - status_update: { agent_status: "running" }, - }, - ], - }), - { status: 200 }, - )) as unknown as typeof fetch; - - const listed = await listTaskMessages({ fetchImpl }, { task_id: "task_1" }); - expect(listed.messages?.[0]?.timestamp).toBe(1756224000); - expect(listed.messages?.[0]?.status_update?.agent_status).toBe("running"); -}); - -test("maps a non-ok HTTP body with a Manus error envelope", async () => { - const fetchImpl = (async () => - new Response( - JSON.stringify({ - ok: false, - error: { code: "permission_denied", message: "bad key" }, - }), - { status: 401 }, - )) as unknown as typeof fetch; - - await expect( - manusRequest({ fetchImpl }, { method: "GET", path: "/v2/skill.list" }), - ).rejects.toThrow(/permission_denied: bad key/); -}); - -test("throws when a 200 body is not an ok envelope", async () => { - const fetchImpl = (async () => - new Response(JSON.stringify({ notes: [] }), { - status: 200, - })) as unknown as typeof fetch; - - await expect( - manusRequest({ fetchImpl }, { method: "GET", path: "/v2/skill.list" }), - ).rejects.toThrow(/did not match the expected shape/); -}); - -test("latestAgentStatus uses the first status_update under default desc order", () => { - expect( - latestAgentStatus([ - { type: "status_update", status_update: { agent_status: "stopped" } }, - { type: "status_update", status_update: { agent_status: "running" } }, - ]), - ).toBe("stopped"); -}); - -test("createSlideDeck treats mixed [stopped, running] desc as terminal", async () => { - const listUrls: string[] = []; - const fetchImpl = (async (input: URL | string, init?: RequestInit) => { - const url = String(input); - if (url.includes("/v2/task.create")) { - expect(JSON.parse(typeof init?.body === "string" ? init.body : "")).toEqual({ - message: { - content: [ - { - type: "text", - text: "Create a slide presentation in pptx format. Produce a presentation deck, not a document. Topic and requirements:\n\nOnboarding", - }, - ], - }, - agent_profile: "manus-1.6-lite", - }); - return new Response(JSON.stringify({ ok: true, task_id: "task_1" }), { - status: 200, - }); - } - if (url.includes("/v2/task.listMessages")) { - listUrls.push(url); - return new Response( - JSON.stringify({ - ok: true, - task_id: "task_1", - messages: [ - { - type: "status_update", - status_update: { agent_status: "stopped" }, - }, - { - type: "status_update", - status_update: { agent_status: "running" }, - }, - ], - }), - { status: 200 }, - ); - } - return new Response("unexpected", { status: 500 }); - }) as unknown as typeof fetch; - - const result = await createSlideDeck( - { fetchImpl }, - { content: "Onboarding", pollIntervalMs: 0, maxPolls: 3 }, - ); - expect(result.agent_status).toBe("stopped"); - expect(listUrls).toHaveLength(1); - expect(listUrls[0]).toContain(`slides_format=${SLIDES_FORMAT_PPTX}`); - expect(listUrls[0]).not.toContain("slides_format=pdf"); - expect(SLIDES_FORMAT_PPTX).toBe("pptx"); -}); - -test("createSlideDeck throws when the agent is still running after the poll budget", async () => { - const fetchImpl = (async (input: URL | string) => { - const url = String(input); - if (url.includes("/v2/task.create")) { - return new Response(JSON.stringify({ ok: true, task_id: "task_1" }), { - status: 200, - }); - } - return new Response( - JSON.stringify({ - ok: true, - task_id: "task_1", - messages: [ - { - type: "status_update", - status_update: { agent_status: "running" }, - }, - ], - }), - { status: 200 }, - ); - }) as unknown as typeof fetch; - - await expect( - createSlideDeck({ fetchImpl }, { content: "Onboarding", pollIntervalMs: 0, maxPolls: 2 }), - ).rejects.toThrow(/did not stop in time \(agent_status: running\)/); -}); - -test("createSlideDeck throws when the agent is waiting", async () => { - const fetchImpl = (async (input: URL | string) => { - const url = String(input); - if (url.includes("/v2/task.create")) { - return new Response(JSON.stringify({ ok: true, task_id: "task_1" }), { - status: 200, - }); - } - return new Response( - JSON.stringify({ - ok: true, - task_id: "task_1", - messages: [ - { - type: "status_update", - status_update: { agent_status: "waiting" }, - }, - ], - }), - { status: 200 }, - ); - }) as unknown as typeof fetch; - - await expect( - createSlideDeck({ fetchImpl }, { content: "Onboarding", pollIntervalMs: 0, maxPolls: 5 }), - ).rejects.toThrow(/waiting for confirmation/); -}); - -test("createSlideDeck throws when the agent_status is error", async () => { - const fetchImpl = (async (input: URL | string) => { - const url = String(input); - if (url.includes("/v2/task.create")) { - return new Response(JSON.stringify({ ok: true, task_id: "task_1" }), { - status: 200, - }); - } - return new Response( - JSON.stringify({ - ok: true, - task_id: "task_1", - messages: [ - { - type: "status_update", - status_update: { agent_status: "error" }, - }, - ], - }), - { status: 200 }, - ); - }) as unknown as typeof fetch; - - await expect( - createSlideDeck({ fetchImpl }, { content: "Onboarding", pollIntervalMs: 0, maxPolls: 5 }), - ).rejects.toThrow(/agent_status error/); -}); - -test("createSlideDeck aborts polling instead of waiting out the timeout", async () => { - const controller = new AbortController(); - const fetchImpl = (async (input: URL | string) => { - const url = String(input); - if (url.includes("/v2/task.create")) { - return new Response(JSON.stringify({ ok: true, task_id: "task_1" }), { - status: 200, - }); - } - return new Response( - JSON.stringify({ - ok: true, - task_id: "task_1", - messages: [ - { - type: "status_update", - status_update: { agent_status: "running" }, - }, - ], - }), - { status: 200 }, - ); - }) as unknown as typeof fetch; - - const pending = createSlideDeck( - { fetchImpl }, - { - content: "Onboarding", - pollIntervalMs: 30_000, - maxPolls: 10, - signal: controller.signal, - }, - ); - queueMicrotask(() => controller.abort()); - await expect(pending).rejects.toThrow(/cancelled/); -}); - -test("default slide-deck wait is several minutes", () => { - expect(DEFAULT_SLIDE_MAX_POLLS * DEFAULT_SLIDE_POLL_INTERVAL_MS).toBeGreaterThan(60_000); - expect(DEFAULT_SLIDE_MAX_POLLS * DEFAULT_SLIDE_POLL_INTERVAL_MS).toBe(5 * 60 * 1000); -}); - -test("createSlideDeck forwards optional skill fields on create", async () => { - let createBody = ""; - const fetchImpl = (async (input: URL | string, init?: RequestInit) => { - const url = String(input); - if (url.includes("/v2/task.create")) { - createBody = typeof init?.body === "string" ? init.body : ""; - return new Response(JSON.stringify({ ok: true, task_id: "task_1" }), { - status: 200, - }); - } - return new Response( - JSON.stringify({ - ok: true, - task_id: "task_1", - messages: [ - { - type: "status_update", - status_update: { agent_status: "stopped" }, - }, - ], - }), - { status: 200 }, - ); - }) as unknown as typeof fetch; - - await createSlideDeck( - { fetchImpl }, - { - content: "Onboarding", - enable_skills: ["skill_slides"], - force_skills: ["skill_slides"], - pollIntervalMs: 0, - maxPolls: 1, - }, - ); - const body = JSON.parse(createBody) as { - agent_profile?: string; - message: { - enable_skills?: string[]; - force_skills?: string[]; - }; - }; - expect(body.message.enable_skills).toEqual(["skill_slides"]); - expect(body.message.force_skills).toEqual(["skill_slides"]); - expect(body.agent_profile).toBe("manus-1.6-lite"); -}); - -test("createTask defaults agent_profile to manus-1.6-lite when omitted", async () => { - const captured: { body: string } = { body: "" }; - const fetchImpl = (async (_input: URL | string, init?: RequestInit) => { - captured.body = typeof init?.body === "string" ? init.body : ""; - return new Response(JSON.stringify({ ok: true, task_id: "task_1" }), { - status: 200, - }); - }) as unknown as typeof fetch; - - await createTask({ fetchImpl }, { content: "Hello" }); - expect(JSON.parse(captured.body)).toEqual({ - message: { content: [{ type: "text", text: "Hello" }] }, - agent_profile: "manus-1.6-lite", - }); -}); - -test("createTask keeps a caller-supplied agent_profile", async () => { - const captured: { body: string } = { body: "" }; - const fetchImpl = (async (_input: URL | string, init?: RequestInit) => { - captured.body = typeof init?.body === "string" ? init.body : ""; - return new Response(JSON.stringify({ ok: true, task_id: "task_1" }), { - status: 200, - }); - }) as unknown as typeof fetch; - - await createTask({ fetchImpl }, { content: "Hello", agent_profile: "manus-1.6-max" }); - expect(JSON.parse(captured.body)).toEqual({ - message: { content: [{ type: "text", text: "Hello" }] }, - agent_profile: "manus-1.6-max", - }); -}); - -test("createSlideDeck keeps a caller-supplied agent_profile", async () => { - let createBody = ""; - const fetchImpl = (async (input: URL | string, init?: RequestInit) => { - const url = String(input); - if (url.includes("/v2/task.create")) { - createBody = typeof init?.body === "string" ? init.body : ""; - return new Response(JSON.stringify({ ok: true, task_id: "task_1" }), { - status: 200, - }); - } - return new Response( - JSON.stringify({ - ok: true, - task_id: "task_1", - messages: [ - { - type: "status_update", - status_update: { agent_status: "stopped" }, - }, - ], - }), - { status: 200 }, - ); - }) as unknown as typeof fetch; - - await createSlideDeck( - { fetchImpl }, - { - content: "Onboarding", - agent_profile: "manus-1.6-max", - pollIntervalMs: 0, - maxPolls: 1, - }, - ); - expect(JSON.parse(createBody).agent_profile).toBe("manus-1.6-max"); -}); - -test("createSlideDeck retries listMessages not_found then succeeds when the task is readable", async () => { - let listCalls = 0; - const fetchImpl = (async (input: URL | string) => { - const url = String(input); - if (url.includes("/v2/task.create")) { - return new Response(JSON.stringify({ ok: true, task_id: "task_1" }), { - status: 200, - }); - } - if (url.includes("/v2/task.listMessages")) { - listCalls += 1; - if (listCalls === 1) { - return new Response( - JSON.stringify({ - ok: false, - error: { code: "not_found", message: "Task not found" }, - }), - { status: 404 }, - ); - } - return new Response( - JSON.stringify({ - ok: true, - task_id: "task_1", - messages: [ - { - type: "status_update", - status_update: { agent_status: "stopped" }, - }, - ], - }), - { status: 200 }, - ); - } - return new Response("unexpected", { status: 500 }); - }) as unknown as typeof fetch; - - const result = await createSlideDeck( - { fetchImpl }, - { content: "Onboarding", pollIntervalMs: 0, maxPolls: 3 }, - ); - expect(result.agent_status).toBe("stopped"); - expect(listCalls).toBe(2); -}); - -test("createSlideDeck retries listMessages not_found with lowercase task not found", async () => { - let listCalls = 0; - const fetchImpl = (async (input: URL | string) => { - const url = String(input); - if (url.includes("/v2/task.create")) { - return new Response(JSON.stringify({ ok: true, task_id: "task_1" }), { - status: 200, - }); - } - if (url.includes("/v2/task.listMessages")) { - listCalls += 1; - if (listCalls === 1) { - return new Response( - JSON.stringify({ - ok: false, - error: { code: "not_found", message: "task not found" }, - }), - { status: 404 }, - ); - } - return new Response( - JSON.stringify({ - ok: true, - task_id: "task_1", - messages: [ - { - type: "status_update", - status_update: { agent_status: "stopped" }, - }, - ], - }), - { status: 200 }, - ); - } - return new Response("unexpected", { status: 500 }); - }) as unknown as typeof fetch; - - const result = await createSlideDeck( - { fetchImpl }, - { content: "Onboarding", pollIntervalMs: 0, maxPolls: 3 }, - ); - expect(result.agent_status).toBe("stopped"); - expect(listCalls).toBe(2); -}); - -test("createSlideDeck still throws unrelated listMessages errors", async () => { - let listCalls = 0; - const fetchImpl = (async (input: URL | string) => { - const url = String(input); - if (url.includes("/v2/task.create")) { - return new Response(JSON.stringify({ ok: true, task_id: "task_1" }), { - status: 200, - }); - } - if (url.includes("/v2/task.listMessages")) { - listCalls += 1; - return new Response( - JSON.stringify({ - ok: false, - error: { code: "permission_denied", message: "bad key" }, - }), - { status: 401 }, - ); - } - return new Response("unexpected", { status: 500 }); - }) as unknown as typeof fetch; - - await expect( - createSlideDeck({ fetchImpl }, { content: "Onboarding", pollIntervalMs: 0, maxPolls: 3 }), - ).rejects.toThrow(/permission_denied: bad key/); - expect(listCalls).toBe(1); -}); - -test("createSlideDeck throws when listMessages stays not_found through the poll budget", async () => { - let listCalls = 0; - const fetchImpl = (async (input: URL | string) => { - const url = String(input); - if (url.includes("/v2/task.create")) { - return new Response(JSON.stringify({ ok: true, task_id: "task_1" }), { - status: 200, - }); - } - if (url.includes("/v2/task.listMessages")) { - listCalls += 1; - return new Response( - JSON.stringify({ - ok: false, - error: { code: "not_found", message: "Task not found" }, - }), - { status: 404 }, - ); - } - return new Response("unexpected", { status: 500 }); - }) as unknown as typeof fetch; - - await expect( - createSlideDeck({ fetchImpl }, { content: "Onboarding", pollIntervalMs: 0, maxPolls: 2 }), - ).rejects.toThrow(/did not stop in time|not_found: Task not found/); - expect(listCalls).toBe(2); -}); diff --git a/tools/manus/src/client.ts b/tools/manus/src/client.ts deleted file mode 100644 index f34cc8ef3a..0000000000 --- a/tools/manus/src/client.ts +++ /dev/null @@ -1,548 +0,0 @@ -// A Manus OpenAPI v2 client. Every workbench consumer of Manus goes -// through the same parsed, validated shape. Callers that need graceful -// degradation (the tool bundle) catch at their own boundary rather than -// this client silently swallowing errors. -// -// Auth is never attached here: a mediated credential's `fetch` injects -// `x-manus-api-key` per call (see `@corbits/credential-providers`'s -// `http-x-manus-api-key` plugin). Tests inject a `fetchImpl` and assert -// that this module does not add an auth header of its own. -import { type } from "arktype"; - -export const DEFAULT_MANUS_BASE_URL = "https://api.manus.ai"; - -export interface ManusClientConfig { - /** Override for tests; defaults to the real Manus API host. */ - readonly baseUrl?: string; - readonly fetchImpl?: typeof fetch; -} - -const ManusErrorEnvelope = type({ - ok: "false", - "request_id?": "string", - error: { - code: "string", - message: "string", - }, -}); - -const ManusOkEnvelope = type({ - ok: "true", - "request_id?": "string", -}); - -const TaskAttachment = type({ - "type?": "string", - "filename?": "string", - "url?": "string", - "id?": "string", - "content_type?": "string", -}); -export type TaskAttachment = typeof TaskAttachment.infer; - -const TaskEvent = type({ - "id?": "string", - "type?": "string", - "timestamp?": "number | string", - "assistant_message?": { - "content?": "string", - "attachments?": TaskAttachment.array(), - }, - "status_update?": { - "agent_status?": "string", - "brief?": "string", - "description?": "string", - }, - "error_message?": { - "error_type?": "string", - "content?": "string", - }, -}); -export type TaskEvent = typeof TaskEvent.infer; - -export const CreateTaskResponse = type({ - ok: "true", - "request_id?": "string", - task_id: "string", - "task_title?": "string", - "task_url?": "string", - "share_url?": "string", - "share_visibility?": "string", -}); -export type CreateTaskResponse = typeof CreateTaskResponse.infer; - -const TaskCreatorAPIKey = type({ - id: "string", - name: "string", -}); - -const TaskDetail = type({ - id: "string", - status: "'running' | 'stopped' | 'waiting' | 'error'", - "created_at?": "number", - "updated_at?": "number", - "task_type?": "'standard' | 'project' | 'agent_subtask'", - "share_visibility?": "'private' | 'team' | 'public'", - "title?": "string", - "credit_usage?": "number", - "task_url?": "string", - "created_by_api_key?": TaskCreatorAPIKey.or("null"), - "agent_profile?": "'manus-1.6' | 'manus-1.6-lite' | 'manus-1.6-max'", -}); -export type TaskDetail = typeof TaskDetail.infer; - -export const TaskDetailResponse = type({ - ok: "true", - "request_id?": "string", - task: TaskDetail, -}); -export type TaskDetailResponse = typeof TaskDetailResponse.infer; - -export const ListMessagesResponse = type({ - ok: "true", - "request_id?": "string", - "task_id?": "string", - "messages?": TaskEvent.array(), - "has_more?": "boolean", - "next_cursor?": "string", -}); -export type ListMessagesResponse = typeof ListMessagesResponse.infer; - -export type ManusHttpMethod = "GET" | "POST"; - -export type OutputFile = { - readonly filename?: string; - readonly url?: string; - readonly id?: string; - readonly type?: string; - readonly content_type?: string; -}; - -function jsonHeaders(): Record { - return { "content-type": "application/json" }; -} - -function throwManusFailure(status: number, statusText: string, body: unknown): never { - const parsed = ManusErrorEnvelope(body); - if (!(parsed instanceof type.errors)) { - throw new Error(`Manus request failed: ${parsed.error.code}: ${parsed.error.message}`); - } - throw new Error(`Manus request failed: ${status} ${statusText}`); -} - -function parseOkBody(body: unknown): Record { - const error = ManusErrorEnvelope(body); - if (!(error instanceof type.errors)) { - throw new Error(`Manus request failed: ${error.error.code}: ${error.error.message}`); - } - const parsed = ManusOkEnvelope(body); - if (parsed instanceof type.errors) { - throw new Error(`Manus response did not match the expected shape: ${parsed.summary}`); - } - if (typeof body !== "object" || body === null || Array.isArray(body)) { - throw new Error("Manus response did not match the expected shape: not an object"); - } - return body as Record; -} - -function queryString(params: Readonly>): string { - const search = new URLSearchParams(); - for (const [key, value] of Object.entries(params)) { - if (value === undefined || value === null) continue; - if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") { - search.set(key, String(value)); - } - } - const encoded = search.toString(); - return encoded === "" ? "" : `?${encoded}`; -} - -/** - * Calls one Manus v2 RPC path. GET arguments become query params; POST - * arguments become a JSON body. Throws on transport, HTTP, `ok: false`, - * or envelope-shape failure. - */ -export async function manusRequest( - config: ManusClientConfig, - args: { - readonly method: ManusHttpMethod; - readonly path: string; - readonly params?: Readonly>; - }, -): Promise> { - const doFetch = config.fetchImpl ?? fetch; - const base = config.baseUrl ?? DEFAULT_MANUS_BASE_URL; - const params = args.params ?? {}; - const url = - args.method === "GET" ? `${base}${args.path}${queryString(params)}` : `${base}${args.path}`; - const response = - args.method === "GET" - ? await doFetch(url, { method: "GET" }) - : await doFetch(url, { - method: "POST", - headers: jsonHeaders(), - body: JSON.stringify(params), - }); - let body: unknown; - try { - body = await response.json(); - } catch (cause) { - throw new Error(`Manus request failed: ${response.status} ${response.statusText}`, { cause }); - } - if (!response.ok) { - throwManusFailure(response.status, response.statusText, body); - } - return parseOkBody(body); -} - -/** Free/personal accounts persist tasks only on the lite profile. */ -export const DEFAULT_AGENT_PROFILE = "manus-1.6-lite"; - -export type CreateTaskParams = { - readonly content: string; - readonly title?: string; - readonly project_id?: string; - readonly locale?: string; - readonly interactive_mode?: boolean; - readonly hide_in_task_list?: boolean; - readonly share_visibility?: string; - readonly agent_profile?: string; - readonly enable_skills?: readonly string[]; - readonly force_skills?: readonly string[]; - readonly connectors?: readonly string[]; - readonly task_references?: readonly string[]; - readonly structured_output_schema?: Readonly>; -}; - -export type TaskTextContentPart = { - readonly type: "text"; - readonly text: string; -}; - -export type TaskMessageSkillFields = { - readonly enable_skills?: readonly string[]; - readonly force_skills?: readonly string[]; - readonly connectors?: readonly string[]; - readonly task_references?: readonly string[]; -}; - -export type TaskMessageBody = { - readonly content: readonly TaskTextContentPart[]; -} & TaskMessageSkillFields; - -/** - * Builds the v2 `message` object: prompt as a ContentPart array, with - * skill/connector/reference arrays omitted when unset. - */ -export function buildTaskMessage( - content: string, - fields?: TaskMessageSkillFields, -): TaskMessageBody { - const message: { - content: readonly TaskTextContentPart[]; - enable_skills?: readonly string[]; - force_skills?: readonly string[]; - connectors?: readonly string[]; - task_references?: readonly string[]; - } = { - content: [{ type: "text", text: content }], - }; - if (fields?.enable_skills !== undefined) { - message.enable_skills = fields.enable_skills; - } - if (fields?.force_skills !== undefined) { - message.force_skills = fields.force_skills; - } - if (fields?.connectors !== undefined) { - message.connectors = fields.connectors; - } - if (fields?.task_references !== undefined) { - message.task_references = fields.task_references; - } - return message; -} - -export async function createTask( - config: ManusClientConfig, - params: CreateTaskParams, -): Promise { - const body: Record = { - message: buildTaskMessage(params.content, params), - }; - if (params.title !== undefined) body["title"] = params.title; - if (params.project_id !== undefined) body["project_id"] = params.project_id; - if (params.locale !== undefined) body["locale"] = params.locale; - if (params.interactive_mode !== undefined) { - body["interactive_mode"] = params.interactive_mode; - } - if (params.hide_in_task_list !== undefined) { - body["hide_in_task_list"] = params.hide_in_task_list; - } - if (params.share_visibility !== undefined) { - body["share_visibility"] = params.share_visibility; - } - body["agent_profile"] = params.agent_profile ?? DEFAULT_AGENT_PROFILE; - if (params.structured_output_schema !== undefined) { - body["structured_output_schema"] = params.structured_output_schema; - } - const raw = await manusRequest(config, { - method: "POST", - path: "/v2/task.create", - params: body, - }); - const parsed = CreateTaskResponse(raw); - if (parsed instanceof type.errors) { - throw new Error( - `Manus create-task response did not match the expected shape: ${parsed.summary}`, - ); - } - return parsed; -} - -export async function getTaskDetail( - config: ManusClientConfig, - taskId: string, -): Promise { - const raw = await manusRequest(config, { - method: "GET", - path: "/v2/task.detail", - params: { task_id: taskId }, - }); - const parsed = TaskDetailResponse(raw); - if (parsed instanceof type.errors) { - throw new Error( - `Manus task-detail response did not match the expected shape: ${parsed.summary}`, - ); - } - return parsed; -} - -export type ListMessagesParams = { - readonly task_id: string; - readonly limit?: number; - readonly cursor?: string; - readonly order?: string; - readonly verbose?: boolean; - readonly slides_format?: string; -}; - -export async function listTaskMessages( - config: ManusClientConfig, - params: ListMessagesParams, -): Promise { - const query: Record = { task_id: params.task_id }; - if (params.limit !== undefined) query["limit"] = params.limit; - if (params.cursor !== undefined) query["cursor"] = params.cursor; - if (params.order !== undefined) query["order"] = params.order; - if (params.verbose !== undefined) query["verbose"] = params.verbose; - if (params.slides_format !== undefined) { - query["slides_format"] = params.slides_format; - } - const raw = await manusRequest(config, { - method: "GET", - path: "/v2/task.listMessages", - params: query, - }); - const parsed = ListMessagesResponse(raw); - if (parsed instanceof type.errors) { - throw new Error( - `Manus list-messages response did not match the expected shape: ${parsed.summary}`, - ); - } - return parsed; -} - -export function latestAgentStatus(messages: readonly TaskEvent[] | undefined): string | undefined { - if (messages === undefined) return undefined; - // task.listMessages defaults to desc (newest first). The first - // status_update is the current agent_status; walking to the last - // event would treat an older running state as current. - for (const event of messages) { - const next = event.status_update?.agent_status; - if (next !== undefined) return next; - } - return undefined; -} - -export function extractOutputFiles( - messages: readonly TaskEvent[] | undefined, -): readonly OutputFile[] { - if (messages === undefined) return []; - const files: OutputFile[] = []; - for (const event of messages) { - const attachments = event.assistant_message?.attachments ?? []; - for (const attachment of attachments) { - if ( - attachment.filename === undefined && - attachment.url === undefined && - attachment.id === undefined - ) { - continue; - } - const file: { - filename?: string; - url?: string; - id?: string; - type?: string; - content_type?: string; - } = {}; - if (attachment.filename !== undefined) file.filename = attachment.filename; - if (attachment.url !== undefined) file.url = attachment.url; - if (attachment.id !== undefined) file.id = attachment.id; - if (attachment.type !== undefined) file.type = attachment.type; - if (attachment.content_type !== undefined) { - file.content_type = attachment.content_type; - } - files.push(file); - } - } - return files; -} - -const TERMINAL_STATUSES = new Set(["stopped", "error"]); - -/** Manus `slides_format` accepts pptx or html — never pdf. */ -export const SLIDES_FORMAT_PPTX = "pptx"; - -export const DEFAULT_SLIDE_POLL_INTERVAL_MS = 2_000; -/** 5 minutes at the default interval — a real deck takes longer than 60s. */ -export const DEFAULT_SLIDE_MAX_POLLS = 150; - -export const SLIDE_DECK_AGENT_PROFILE = DEFAULT_AGENT_PROFILE; - -const SLIDE_DECK_PROMPT_PREFIX = - "Create a slide presentation in pptx format. Produce a presentation " + - "deck, not a document. Topic and requirements:\n\n"; - -export type CreateSlideDeckParams = CreateTaskParams & { - readonly pollIntervalMs?: number; - readonly maxPolls?: number; - readonly signal?: AbortSignal; -}; - -function isManusTaskNotFoundError(error: unknown): boolean { - return ( - error instanceof Error && - error.message.toLowerCase().includes("manus request failed: not_found") - ); -} - -function throwIfSlideWaitAborted(signal: AbortSignal | undefined): void { - if (signal?.aborted) { - throw new Error("Manus slide-deck wait was cancelled"); - } -} - -function sleep(ms: number, signal?: AbortSignal): Promise { - if (ms <= 0) { - throwIfSlideWaitAborted(signal); - return Promise.resolve(); - } - return new Promise((resolve, reject) => { - const timer = setTimeout(() => { - signal?.removeEventListener("abort", onAbort); - resolve(); - }, ms); - const onAbort = () => { - clearTimeout(timer); - reject(new Error("Manus slide-deck wait was cancelled")); - }; - if (signal === undefined) return; - if (signal.aborted) { - clearTimeout(timer); - reject(new Error("Manus slide-deck wait was cancelled")); - return; - } - signal.addEventListener("abort", onAbort, { once: true }); - }); -} - -/** - * Creates a task whose prompt asks Manus to produce a slide deck, then - * polls `task.listMessages` until the agent stops and returns any output - * files so a caller can retrieve them. A timeout, a still-running or - * waiting agent, an `error` status, or an abort is a thrown error — - * never a successful deck. - */ -export async function createSlideDeck( - config: ManusClientConfig, - params: CreateSlideDeckParams, -): Promise<{ - readonly task_id: string; - readonly task_title?: string; - readonly task_url?: string; - readonly agent_status?: string; - readonly files: readonly OutputFile[]; - readonly error?: string; -}> { - const { pollIntervalMs, maxPolls, signal, ...taskParams } = params; - const created = await createTask(config, { - ...taskParams, - content: `${SLIDE_DECK_PROMPT_PREFIX}${taskParams.content}`, - agent_profile: - taskParams.agent_profile !== undefined ? taskParams.agent_profile : SLIDE_DECK_AGENT_PROFILE, - }); - const intervalMs = pollIntervalMs ?? DEFAULT_SLIDE_POLL_INTERVAL_MS; - const polls = maxPolls ?? DEFAULT_SLIDE_MAX_POLLS; - let messages: ListMessagesResponse | undefined; - for (let i = 0; i < polls; i += 1) { - throwIfSlideWaitAborted(signal); - try { - messages = await listTaskMessages(config, { - task_id: created.task_id, - slides_format: SLIDES_FORMAT_PPTX, - }); - } catch (error) { - if (!isManusTaskNotFoundError(error)) throw error; - if (i < polls - 1) { - await sleep(intervalMs, signal); - } - continue; - } - const status = latestAgentStatus(messages.messages); - if (status !== undefined && TERMINAL_STATUSES.has(status)) break; - if (status === "waiting") { - throw new Error( - `Manus task ${created.task_id} is waiting for confirmation and cannot finish unattended`, - ); - } - if (i < polls - 1) { - await sleep(intervalMs, signal); - } - } - const status = latestAgentStatus(messages?.messages); - if (status === undefined || !TERMINAL_STATUSES.has(status)) { - throw new Error( - `Manus task ${created.task_id} did not stop in time` + - (status !== undefined ? ` (agent_status: ${status})` : ""), - ); - } - if (status === "error") { - const errorEvent = messages?.messages?.find((event) => event.error_message); - const detail = errorEvent?.error_message?.content; - throw new Error( - `Manus task ${created.task_id} ended with agent_status error` + - (detail !== undefined ? `: ${detail}` : ""), - ); - } - const files = extractOutputFiles(messages?.messages); - const errorEvent = messages?.messages?.find((event) => event.error_message); - const result: { - task_id: string; - task_title?: string; - task_url?: string; - agent_status?: string; - files: readonly OutputFile[]; - error?: string; - } = { - task_id: created.task_id, - files, - }; - if (created.task_title !== undefined) result.task_title = created.task_title; - if (created.task_url !== undefined) result.task_url = created.task_url; - if (status !== undefined) result.agent_status = status; - if (errorEvent?.error_message?.content !== undefined) { - result.error = errorEvent.error_message.content; - } - return result; -} diff --git a/tools/manus/src/index.ts b/tools/manus/src/index.ts deleted file mode 100644 index 5c570ae8df..0000000000 --- a/tools/manus/src/index.ts +++ /dev/null @@ -1,40 +0,0 @@ -export { - CreateTaskResponse, - ListMessagesResponse, - TaskDetailResponse, - buildTaskMessage, - createSlideDeck, - createTask, - extractOutputFiles, - getTaskDetail, - latestAgentStatus, - listTaskMessages, - manusRequest, - DEFAULT_MANUS_BASE_URL, - DEFAULT_SLIDE_MAX_POLLS, - DEFAULT_SLIDE_POLL_INTERVAL_MS, - DEFAULT_AGENT_PROFILE, - SLIDE_DECK_AGENT_PROFILE, - SLIDES_FORMAT_PPTX, -} from "./client"; -export type { - CreateSlideDeckParams, - CreateTaskParams, - ListMessagesParams, - ManusClientConfig, - OutputFile, - TaskAttachment, - TaskDetail, - TaskEvent, - TaskMessageBody, - TaskMessageSkillFields, - TaskTextContentPart, -} from "./client"; -export { - CREATE_SLIDES_TOOL, - MANUS_CREDENTIAL_HANDLE, - MANUS_ENDPOINTS, - MANUS_NOT_CONNECTED, - manusTools, -} from "./tool"; -export type { ManusEnv } from "./tool"; diff --git a/tools/manus/src/manifest.test.ts b/tools/manus/src/manifest.test.ts deleted file mode 100644 index 55d82b5c97..0000000000 --- a/tools/manus/src/manifest.test.ts +++ /dev/null @@ -1,21 +0,0 @@ -// Proves this package's own `package.json` satisfies the vendored -// `PackageJSON` manifest schema with an `interchange.credentials` -// declaration the deploy-time `ToolPackageManifest` harvests. -import { expect, test } from "bun:test"; -import { type } from "arktype"; -import { PackageJSON } from "@intx/types/package-json"; - -import packageJson from "../package.json"; - -test("package.json parses against the vendored PackageJSON manifest schema", () => { - const parsed = PackageJSON(packageJson); - expect(parsed instanceof type.errors).toBe(false); -}); - -test("declares exactly one credential handle: manus", () => { - const parsed = PackageJSON(packageJson); - if (parsed instanceof type.errors) { - throw new Error(parsed.summary); - } - expect(parsed.interchange?.credentials).toEqual([{ handle: "manus" }]); -}); diff --git a/tools/manus/src/tool.test.ts b/tools/manus/src/tool.test.ts deleted file mode 100644 index add5d768a5..0000000000 --- a/tools/manus/src/tool.test.ts +++ /dev/null @@ -1,482 +0,0 @@ -import { expect, test } from "bun:test"; -import type { ToolCall } from "@intx/types/runtime"; -import type { CredentialCapability, MediatedCredential } from "@intx/types"; - -import { CREATE_SLIDES_TOOL, MANUS_ENDPOINTS, MANUS_NOT_CONNECTED, manusTools } from "./tool"; -import type { ManusEnv } from "./tool"; - -const CREATE_SLIDES_CALL: ToolCall = { - id: "call_1", - name: CREATE_SLIDES_TOOL, - arguments: { prompt: "Make a five-slide deck about onboarding" }, -}; - -function fakeCredentials(secret: string | undefined): CredentialCapability { - return { - resolve(handle: string): Promise { - if (secret === undefined) { - return Promise.reject(new Error(`no credential is bound to handle "${handle}"`)); - } - return Promise.resolve({ - kind: "http", - fetch: (input, init) => fetch(input as string | URL, init), - dispose: () => {}, - }); - }, - }; -} - -function fakeEnv(credentials: CredentialCapability | undefined): ManusEnv { - return { credentials } as unknown as ManusEnv; -} - -const STOPPED_WITH_DECK = { - ok: true, - task_id: "task_1", - messages: [ - { - type: "status_update", - status_update: { agent_status: "stopped" }, - }, - { - type: "assistant_message", - assistant_message: { - content: "Here is the deck.", - attachments: [ - { - type: "slides", - filename: "onboarding.pptx", - url: "https://files.manus.ai/onboarding.pptx", - id: "file_deck_1", - content_type: - "application/vnd.openxmlformats-officedocument.presentationml.presentation", - }, - ], - }, - }, - ], -}; - -test("declares create_slides plus thin tools covering the v2 surface", () => { - const bundle = manusTools(fakeEnv(fakeCredentials("key"))); - const names = bundle.definitions.map((d) => d.name); - expect(names).toContain(CREATE_SLIDES_TOOL); - expect(names).toContain("task_create"); - expect(names).toContain("task_list_msgs"); - expect(names).toContain("file_upload"); - expect(names).toContain("skill_list"); - expect(names).toContain("project_list"); - expect(names).toContain("agent_list"); - expect(names).toContain("webhook_list"); - expect(names).toContain("usage_credits"); - expect(names).toContain("connector_list"); - expect(names).toContain("browser_online"); - expect(names).toContain("website_status"); - expect(names.length).toBe(MANUS_ENDPOINTS.length + 1); -}); - -test("mutating admin tools declare approval ask; create_slides and read-ish tools stay ungated", () => { - const byName = new Map(manusTools.definitions.map((d) => [d.name, d])); - for (const name of [ - "webhook_create", - "webhook_delete", - "webhook_list", - "webhook_pubkey", - "website_publish", - "website_update", - "task_delete", - "file_delete", - ] as const) { - expect(byName.get(name)).toEqual({ name, approval: "ask" }); - } - expect(byName.get(CREATE_SLIDES_TOOL)).toEqual({ name: CREATE_SLIDES_TOOL }); - expect(byName.get("task_list")).toEqual({ name: "task_list" }); - expect(byName.get("task_list_msgs")).toEqual({ name: "task_list_msgs" }); - expect(byName.get("file_detail")).toEqual({ name: "file_detail" }); -}); - -test("task_list_msgs describes slides_format as pptx or html, never pdf", () => { - const listMsgs = MANUS_ENDPOINTS.find((spec) => spec.name === "task_list_msgs"); - expect(listMsgs?.properties["slides_format"]?.description).toContain("pptx"); - expect(listMsgs?.properties["slides_format"]?.description).toContain("html"); - expect(listMsgs?.properties["slides_format"]?.description).not.toMatch(/pdf/i); -}); - -test("degrades to a non-throwing 'not connected' error when no credential is bound", async () => { - const bundle = manusTools(fakeEnv(fakeCredentials(undefined))); - const result = await bundle.run(CREATE_SLIDES_CALL, new AbortController().signal); - expect(result.isError).toBe(true); - expect(result.content).toBe(MANUS_NOT_CONNECTED); -}); - -test("degrades the same way when the step carries no credentials capability at all", async () => { - const bundle = manusTools(fakeEnv(undefined)); - const result = await bundle.run(CREATE_SLIDES_CALL, new AbortController().signal); - expect(result.isError).toBe(true); - expect(result.content).toBe(MANUS_NOT_CONNECTED); -}); - -test("create_slides creates a task, polls messages, and surfaces the presentation file", async () => { - const originalFetch = globalThis.fetch; - const urls: string[] = []; - globalThis.fetch = (async (input: unknown, init?: RequestInit) => { - const url = String(input); - urls.push(url); - if (url.includes("/v2/task.create")) { - expect(init?.method).toBe("POST"); - const body = JSON.parse(typeof init?.body === "string" ? init.body : ""); - expect(body.message.content).toEqual([ - expect.objectContaining({ - type: "text", - }), - ]); - expect(body.message.content[0].text).toContain("slide presentation"); - expect(body.message.content[0].text).toContain("pptx"); - expect(body.message.content[0].text).toContain("Make a five-slide deck about onboarding"); - expect(body.message.enable_skills).toBeUndefined(); - expect(body.message.force_skills).toBeUndefined(); - expect(body.agent_profile).toBe("manus-1.6-lite"); - return new Response( - JSON.stringify({ - ok: true, - task_id: "task_1", - task_title: "Onboarding", - task_url: "https://manus.im/app/task_1", - }), - { status: 200 }, - ); - } - if (url.includes("/v2/task.listMessages")) { - expect(url).toContain("slides_format=pptx"); - expect(url).not.toContain("slides_format=pdf"); - return new Response(JSON.stringify(STOPPED_WITH_DECK), { status: 200 }); - } - return new Response("unexpected", { status: 500 }); - }) as unknown as typeof fetch; - try { - const bundle = manusTools(fakeEnv(fakeCredentials("key"))); - const result = await bundle.run(CREATE_SLIDES_CALL, new AbortController().signal); - expect(result.isError).toBeUndefined(); - const parsed = JSON.parse(result.content as string) as { - task_id: string; - agent_status: string; - files: readonly { - filename: string; - url: string; - id: string; - type: string; - content_type: string; - }[]; - }; - expect(parsed.task_id).toBe("task_1"); - expect(parsed.agent_status).toBe("stopped"); - expect(parsed.files).toEqual([ - { - filename: "onboarding.pptx", - url: "https://files.manus.ai/onboarding.pptx", - id: "file_deck_1", - type: "slides", - content_type: "application/vnd.openxmlformats-officedocument.presentationml.presentation", - }, - ]); - expect(urls.some((url) => url.includes("/v2/task.create"))).toBe(true); - expect(urls.some((url) => url.includes("/v2/task.listMessages"))).toBe(true); - } finally { - globalThis.fetch = originalFetch; - } -}); - -test("create_slides returns isError when the agent is waiting", async () => { - const originalFetch = globalThis.fetch; - globalThis.fetch = (async (input: unknown) => { - const url = String(input); - if (url.includes("/v2/task.create")) { - return new Response(JSON.stringify({ ok: true, task_id: "task_1" }), { - status: 200, - }); - } - return new Response( - JSON.stringify({ - ok: true, - task_id: "task_1", - messages: [ - { - type: "status_update", - status_update: { agent_status: "waiting" }, - }, - ], - }), - { status: 200 }, - ); - }) as unknown as typeof fetch; - try { - const bundle = manusTools(fakeEnv(fakeCredentials("key"))); - const result = await bundle.run(CREATE_SLIDES_CALL, new AbortController().signal); - expect(result.isError).toBe(true); - expect(result.content).toMatch(/waiting for confirmation/); - } finally { - globalThis.fetch = originalFetch; - } -}); - -test("create_slides returns isError when the agent_status is error", async () => { - const originalFetch = globalThis.fetch; - globalThis.fetch = (async (input: unknown) => { - const url = String(input); - if (url.includes("/v2/task.create")) { - return new Response(JSON.stringify({ ok: true, task_id: "task_1" }), { - status: 200, - }); - } - return new Response( - JSON.stringify({ - ok: true, - task_id: "task_1", - messages: [ - { - type: "status_update", - status_update: { agent_status: "error" }, - }, - ], - }), - { status: 200 }, - ); - }) as unknown as typeof fetch; - try { - const bundle = manusTools(fakeEnv(fakeCredentials("key"))); - const result = await bundle.run(CREATE_SLIDES_CALL, new AbortController().signal); - expect(result.isError).toBe(true); - expect(result.content).toMatch(/agent_status error/); - } finally { - globalThis.fetch = originalFetch; - } -}); - -test("degrades to an error result (never throws) when the underlying call fails", async () => { - const originalFetch = globalThis.fetch; - globalThis.fetch = (async () => new Response("nope", { status: 500 })) as unknown as typeof fetch; - try { - const bundle = manusTools(fakeEnv(fakeCredentials("key"))); - const result = await bundle.run(CREATE_SLIDES_CALL, new AbortController().signal); - expect(result.isError).toBe(true); - } finally { - globalThis.fetch = originalFetch; - } -}); - -test("task_create and task_send_msg expose skill and connector fields", () => { - const create = MANUS_ENDPOINTS.find((spec) => spec.name === "task_create"); - const send = MANUS_ENDPOINTS.find((spec) => spec.name === "task_send_msg"); - for (const spec of [create, send]) { - expect(spec?.properties["enable_skills"]?.type).toBe("array"); - expect(spec?.properties["force_skills"]?.type).toBe("array"); - expect(spec?.properties["connectors"]?.type).toBe("array"); - expect(spec?.properties["task_references"]?.type).toBe("array"); - } - expect(create?.properties["structured_output_schema"]?.type).toBe("object"); - expect(send?.properties["structured_output_schema"]).toBeUndefined(); - expect(create?.properties["agent_profile"]?.description).toContain("manus-1.6-lite"); - expect(create?.properties["agent_profile"]?.description).toMatch(/default/i); -}); - -test("task_create without agent_profile posts manus-1.6-lite", async () => { - const originalFetch = globalThis.fetch; - let createBody = ""; - globalThis.fetch = (async (_input: unknown, init?: RequestInit) => { - createBody = typeof init?.body === "string" ? init.body : ""; - return new Response(JSON.stringify({ ok: true, task_id: "task_1" }), { - status: 200, - }); - }) as unknown as typeof fetch; - try { - const bundle = manusTools(fakeEnv(fakeCredentials("key"))); - const result = await bundle.run( - { - id: "call_create_default_profile", - name: "task_create", - arguments: { content: "Hello" }, - }, - new AbortController().signal, - ); - expect(result.isError).toBeUndefined(); - expect(JSON.parse(createBody).agent_profile).toBe("manus-1.6-lite"); - } finally { - globalThis.fetch = originalFetch; - } -}); - -test("task_create result feeds task_detail through the validated GET boundary", async () => { - const originalFetch = globalThis.fetch; - const createdTaskId = "task_created_42"; - globalThis.fetch = (async (input: unknown, init?: RequestInit) => { - const url = String(input); - if (url === "https://api.manus.ai/v2/task.create") { - return new Response(JSON.stringify({ ok: true, task_id: createdTaskId }), { status: 200 }); - } - expect(url).toBe(`https://api.manus.ai/v2/task.detail?task_id=${createdTaskId}`); - expect(init?.method).toBe("GET"); - return new Response( - JSON.stringify({ - ok: true, - request_id: "req_detail_1", - task: { - id: createdTaskId, - status: "running", - title: "Deterministic read", - task_type: "standard", - share_visibility: "private", - agent_profile: "manus-1.6-lite", - }, - }), - { status: 200 }, - ); - }) as unknown as typeof fetch; - try { - const bundle = manusTools(fakeEnv(fakeCredentials("key"))); - const created = await bundle.run( - { - id: "call_create_then_read", - name: "task_create", - arguments: { content: "Create a deterministic task" }, - }, - new AbortController().signal, - ); - expect(created.isError).toBeUndefined(); - const createResult = JSON.parse(created.content as string) as { - task_id: string; - }; - - const detail = await bundle.run( - { - id: "call_task_detail", - name: "task_detail", - arguments: { task_id: createResult.task_id }, - }, - new AbortController().signal, - ); - expect(detail.isError).toBeUndefined(); - expect(JSON.parse(detail.content as string)).toEqual({ - ok: true, - request_id: "req_detail_1", - task: { - id: createdTaskId, - status: "running", - title: "Deterministic read", - task_type: "standard", - share_visibility: "private", - agent_profile: "manus-1.6-lite", - }, - }); - } finally { - globalThis.fetch = originalFetch; - } -}); - -test("task_create omits skill fields unless the assistant passes ids", async () => { - const originalFetch = globalThis.fetch; - let createBody = ""; - globalThis.fetch = (async (_input: unknown, init?: RequestInit) => { - createBody = typeof init?.body === "string" ? init.body : ""; - return new Response(JSON.stringify({ ok: true, task_id: "task_1" }), { - status: 200, - }); - }) as unknown as typeof fetch; - try { - const bundle = manusTools(fakeEnv(fakeCredentials("key"))); - const omitted = await bundle.run( - { - id: "call_create", - name: "task_create", - arguments: { content: "Hello" }, - }, - new AbortController().signal, - ); - expect(omitted.isError).toBeUndefined(); - expect(JSON.parse(createBody)).toEqual({ - message: { content: [{ type: "text", text: "Hello" }] }, - agent_profile: "manus-1.6-lite", - }); - - const present = await bundle.run( - { - id: "call_create_skills", - name: "task_create", - arguments: { - content: "Hello with skills", - enable_skills: ["skill_abc"], - force_skills: ["skill_abc"], - connectors: ["conn_1"], - task_references: ["task_ref_1"], - structured_output_schema: { type: "object" }, - }, - }, - new AbortController().signal, - ); - expect(present.isError).toBeUndefined(); - expect(JSON.parse(createBody)).toEqual({ - message: { - content: [{ type: "text", text: "Hello with skills" }], - enable_skills: ["skill_abc"], - force_skills: ["skill_abc"], - connectors: ["conn_1"], - task_references: ["task_ref_1"], - }, - structured_output_schema: { type: "object" }, - agent_profile: "manus-1.6-lite", - }); - } finally { - globalThis.fetch = originalFetch; - } -}); - -test("task_send_msg posts ContentPart content and optional skill fields", async () => { - const originalFetch = globalThis.fetch; - let sendBody = ""; - globalThis.fetch = (async (_input: unknown, init?: RequestInit) => { - sendBody = typeof init?.body === "string" ? init.body : ""; - return new Response(JSON.stringify({ ok: true }), { status: 200 }); - }) as unknown as typeof fetch; - try { - const bundle = manusTools(fakeEnv(fakeCredentials("key"))); - const omitted = await bundle.run( - { - id: "call_send", - name: "task_send_msg", - arguments: { task_id: "task_1", content: "Follow up" }, - }, - new AbortController().signal, - ); - expect(omitted.isError).toBeUndefined(); - expect(JSON.parse(sendBody)).toEqual({ - task_id: "task_1", - message: { content: [{ type: "text", text: "Follow up" }] }, - }); - - const present = await bundle.run( - { - id: "call_send_skills", - name: "task_send_msg", - arguments: { - task_id: "task_1", - content: "Follow up with skills", - enable_skills: ["skill_abc"], - connectors: ["conn_1"], - task_references: ["task_ref_1"], - }, - }, - new AbortController().signal, - ); - expect(present.isError).toBeUndefined(); - expect(JSON.parse(sendBody)).toEqual({ - task_id: "task_1", - message: { - content: [{ type: "text", text: "Follow up with skills" }], - enable_skills: ["skill_abc"], - connectors: ["conn_1"], - task_references: ["task_ref_1"], - }, - }); - } finally { - globalThis.fetch = originalFetch; - } -}); diff --git a/tools/manus/src/tool.ts b/tools/manus/src/tool.ts deleted file mode 100644 index 08a689c665..0000000000 --- a/tools/manus/src/tool.ts +++ /dev/null @@ -1,809 +0,0 @@ -// The Manus tool bundle: an agent-facing wrapper around `./client.ts` -// that never throws. A missing credential or a failed call both come -// back as a completed `ToolResult` with `isError: true`. -import { defineTool } from "@intx/agent"; -import type { BaseEnv } from "@intx/agent"; -import type { CredentialCapability } from "@intx/types"; -import type { ToolCall, ToolResult } from "@intx/types/runtime"; - -import { - buildTaskMessage, - createSlideDeck, - createTask, - getTaskDetail, - listTaskMessages, - manusRequest, - type ManusClientConfig, - type ManusHttpMethod, -} from "./client"; - -/** The handle this package declares in `interchange.credentials`. */ -export const MANUS_CREDENTIAL_HANDLE = "manus"; - -export const MANUS_NOT_CONNECTED = "Manus is not connected for this user."; - -export const CREATE_SLIDES_TOOL = "create_slides"; - -type JsonSchemaProperty = { - readonly type: string; - readonly description: string; - readonly items?: { readonly type: string }; -}; - -type EndpointSpec = { - readonly name: string; - readonly method: ManusHttpMethod; - readonly path: string; - readonly description: string; - readonly required: readonly string[]; - readonly properties: Readonly>; - readonly approval?: "ask"; -}; - -const STRING = (description: string): JsonSchemaProperty => ({ - type: "string", - description, -}); -const NUMBER = (description: string): JsonSchemaProperty => ({ - type: "number", - description, -}); -const BOOLEAN = (description: string): JsonSchemaProperty => ({ - type: "boolean", - description, -}); -const OBJECT = (description: string): JsonSchemaProperty => ({ - type: "object", - description, -}); -const STRING_ARRAY = (description: string): JsonSchemaProperty => ({ - type: "array", - description, - items: { type: "string" }, -}); - -const MESSAGE_SKILL_PROPERTIES = { - enable_skills: STRING_ARRAY( - "Skill ids from skill_list to make available. If omitted, the account default skills are used.", - ), - force_skills: STRING_ARRAY( - "Skill ids the agent must invoke. Forced skills are available even when not listed in enable_skills.", - ), - connectors: STRING_ARRAY("Connector ids from connector_list to attach to this message."), - task_references: STRING_ARRAY( - "Task ids (up to 20) the agent may browse. Pass the 22-character id, not a URL.", - ), -} as const; - -export const MANUS_ENDPOINTS: readonly EndpointSpec[] = [ - { - name: "task_create", - method: "POST", - path: "/v2/task.create", - description: - "Creates a Manus task. Pass content as the prompt text (sent as message.content ContentPart text). Poll task_list_msgs for progress. Pass skill ids from skill_list via enable_skills or force_skills.", - required: ["content"], - properties: { - content: STRING("Prompt text that starts the task."), - title: STRING("Optional custom task title."), - project_id: STRING("Project to associate this task with."), - locale: STRING("Output locale, e.g. en or zh-CN."), - interactive_mode: BOOLEAN("When true, the agent may pause to ask questions."), - hide_in_task_list: BOOLEAN("When true, hide the task from the Manus task list."), - share_visibility: STRING("private, team, or public."), - agent_profile: STRING("Defaults to manus-1.6-lite. Other values: manus-1.6, manus-1.6-max."), - ...MESSAGE_SKILL_PROPERTIES, - structured_output_schema: OBJECT( - "JSON Schema for structured output extraction. Sent on the create body, not inside message.", - ), - }, - }, - { - name: "task_detail", - method: "GET", - path: "/v2/task.detail", - description: "Fetches one Manus task by task_id.", - required: ["task_id"], - properties: { task_id: STRING("Task id.") }, - }, - { - name: "task_list", - method: "GET", - path: "/v2/task.list", - description: "Lists Manus tasks.", - required: [], - properties: { - limit: NUMBER("Page size."), - cursor: STRING("Pagination cursor."), - order: STRING("Sort order."), - scope: STRING("List scope."), - agent_id: STRING("Filter by agent id."), - project_id: STRING("Filter by project id."), - }, - }, - { - name: "task_update", - method: "POST", - path: "/v2/task.update", - description: "Updates a Manus task's title, visibility, or list visibility.", - required: ["task_id"], - properties: { - task_id: STRING("Task id."), - title: STRING("New title."), - share_visibility: STRING("private, team, or public."), - enable_visible_in_task_list: BOOLEAN("Show the task in the Manus task list."), - }, - }, - { - name: "task_stop", - method: "POST", - path: "/v2/task.stop", - description: "Stops a running Manus task.", - required: ["task_id"], - properties: { task_id: STRING("Task id.") }, - }, - { - name: "task_delete", - method: "POST", - path: "/v2/task.delete", - description: "Deletes a Manus task.", - required: ["task_id"], - properties: { task_id: STRING("Task id.") }, - approval: "ask", - }, - { - name: "task_send_msg", - method: "POST", - path: "/v2/task.sendMessage", - description: - "Sends a follow-up message to an existing Manus task. Pass skill ids from skill_list via enable_skills or force_skills.", - required: ["task_id", "content"], - properties: { - task_id: STRING("Task id."), - content: STRING("Follow-up prompt text (sent as message.content ContentPart text)."), - agent_profile: STRING("Optional agent profile override."), - ...MESSAGE_SKILL_PROPERTIES, - }, - }, - { - name: "task_list_msgs", - method: "GET", - path: "/v2/task.listMessages", - description: - "Lists messages and status events for a Manus task. Poll until agent_status is stopped. Output files appear as assistant_message attachments.", - required: ["task_id"], - properties: { - task_id: STRING("Task id."), - limit: NUMBER("Page size."), - cursor: STRING("Pagination cursor."), - order: STRING("Sort order."), - verbose: BOOLEAN("Include tool/plan events."), - slides_format: STRING("Preferred slides download format: pptx or html."), - }, - }, - { - name: "task_confirm", - method: "POST", - path: "/v2/task.confirmAction", - description: "Confirms a waiting Manus task action (event_id from a waiting status).", - required: ["task_id", "event_id"], - properties: { - task_id: STRING("Task id."), - event_id: STRING("Waiting event id."), - input: OBJECT("Optional confirmation input object."), - }, - }, - { - name: "project_create", - method: "POST", - path: "/v2/project.create", - description: "Creates a Manus project.", - required: ["name"], - properties: { - name: STRING("Project name."), - instruction: STRING("Optional project instruction."), - }, - }, - { - name: "project_list", - method: "GET", - path: "/v2/project.list", - description: "Lists Manus projects.", - required: [], - properties: {}, - }, - { - name: "skill_list", - method: "GET", - path: "/v2/skill.list", - description: "Lists available Manus skills.", - required: [], - properties: { project_id: STRING("Optional project id to scope skills.") }, - }, - { - name: "agent_list", - method: "GET", - path: "/v2/agent.list", - description: "Lists Manus agents.", - required: [], - properties: {}, - }, - { - name: "agent_detail", - method: "GET", - path: "/v2/agent.detail", - description: "Fetches one Manus agent by agent_id.", - required: ["agent_id"], - properties: { agent_id: STRING("Agent id.") }, - }, - { - name: "agent_update", - method: "POST", - path: "/v2/agent.update", - description: "Updates a Manus agent's nickname or about text.", - required: ["agent_id"], - properties: { - agent_id: STRING("Agent id."), - nickname: STRING("New nickname."), - about: STRING("New about text."), - }, - }, - { - name: "file_upload", - method: "POST", - path: "/v2/file.upload", - description: - "Creates a pending Manus file and returns a presigned upload_url. PUT the file bytes to that URL before it expires.", - required: ["filename"], - properties: { filename: STRING("File name to upload.") }, - }, - { - name: "file_detail", - method: "GET", - path: "/v2/file.detail", - description: "Fetches one Manus file by file_id.", - required: ["file_id"], - properties: { file_id: STRING("File id.") }, - }, - { - name: "file_delete", - method: "POST", - path: "/v2/file.delete", - description: "Deletes a Manus file.", - required: ["file_id"], - properties: { file_id: STRING("File id.") }, - approval: "ask", - }, - { - name: "webhook_create", - method: "POST", - path: "/v2/webhook.create", - description: "Creates a Manus webhook.", - required: ["url"], - properties: { url: STRING("Webhook callback URL.") }, - approval: "ask", - }, - { - name: "webhook_list", - method: "GET", - path: "/v2/webhook.list", - description: "Lists Manus webhooks.", - required: [], - properties: {}, - approval: "ask", - }, - { - name: "webhook_delete", - method: "POST", - path: "/v2/webhook.delete", - description: "Deletes a Manus webhook.", - required: ["webhook_id"], - properties: { webhook_id: STRING("Webhook id.") }, - approval: "ask", - }, - { - name: "webhook_pubkey", - method: "GET", - path: "/v2/webhook.publicKey", - description: "Returns the Manus webhook signing public key.", - required: [], - properties: {}, - approval: "ask", - }, - { - name: "usage_list", - method: "GET", - path: "/v2/usage.list", - description: "Lists Manus usage records.", - required: [], - properties: { - limit: NUMBER("Page size."), - cursor: STRING("Pagination cursor."), - }, - }, - { - name: "usage_credits", - method: "GET", - path: "/v2/usage.availableCredits", - description: "Returns available Manus credits.", - required: [], - properties: {}, - }, - { - name: "usage_team_stat", - method: "GET", - path: "/v2/usage.teamStatistic", - description: "Returns Manus team usage statistics.", - required: [], - properties: { - start_date: NUMBER("Start date as a unix timestamp."), - end_date: NUMBER("End date as a unix timestamp."), - }, - }, - { - name: "usage_team_log", - method: "GET", - path: "/v2/usage.teamLog", - description: "Returns the Manus team usage log.", - required: [], - properties: { - limit: NUMBER("Page size."), - cursor: STRING("Pagination cursor."), - start_date: NUMBER("Start date as a unix timestamp."), - end_date: NUMBER("End date as a unix timestamp."), - sort_by: STRING("Sort field."), - is_asc: BOOLEAN("Sort ascending when true."), - }, - }, - { - name: "connector_list", - method: "GET", - path: "/v2/connector.list", - description: "Lists Manus connectors available to this account.", - required: [], - properties: {}, - }, - { - name: "browser_online", - method: "GET", - path: "/v2/browser.onlineList", - description: "Lists online Manus browser clients.", - required: [], - properties: {}, - }, - { - name: "website_status", - method: "GET", - path: "/v2/website.status", - description: "Returns Manus website publish status for a task or website.", - required: [], - properties: { - task_id: STRING("Task id."), - website_id: STRING("Website id."), - }, - }, - { - name: "website_publish", - method: "POST", - path: "/v2/website.publish", - description: "Publishes a Manus website.", - required: [], - properties: { - task_id: STRING("Task id."), - website_id: STRING("Website id."), - visibility: STRING("Visibility."), - }, - approval: "ask", - }, - { - name: "website_update", - method: "POST", - path: "/v2/website.update", - description: "Updates a Manus website title or visibility.", - required: [], - properties: { - task_id: STRING("Task id."), - website_id: STRING("Website id."), - title: STRING("New title."), - visibility: STRING("Visibility."), - }, - approval: "ask", - }, - { - name: "website_ckpts", - method: "GET", - path: "/v2/website.listCheckpoints", - description: "Lists Manus website checkpoints.", - required: [], - properties: { - task_id: STRING("Task id."), - website_id: STRING("Website id."), - }, - }, -]; - -export interface ManusEnv extends BaseEnv { - readonly credentials?: CredentialCapability; -} - -function notConnectedResult(callId: string): ToolResult { - return { - callId, - content: MANUS_NOT_CONNECTED, - isError: true, - }; -} - -async function resolveManusCredential(env: ManusEnv): Promise<{ fetchImpl: typeof fetch } | null> { - if (env.credentials === undefined) return null; - try { - const mediated = await env.credentials.resolve(MANUS_CREDENTIAL_HANDLE); - return { fetchImpl: mediated.fetch as unknown as typeof fetch }; - } catch { - return null; - } -} - -function asClientConfig(credential: { fetchImpl: typeof fetch }): ManusClientConfig { - return { fetchImpl: credential.fetchImpl }; -} - -function stringArg(call: ToolCall, key: string): string | undefined { - const value = call.arguments[key]; - return typeof value === "string" ? value : undefined; -} - -function pickParams(call: ToolCall, keys: readonly string[]): Record { - const params: Record = {}; - for (const key of keys) { - const value = call.arguments[key]; - if (value !== undefined) params[key] = value; - } - return params; -} - -function missingRequired(call: ToolCall, required: readonly string[]): string | undefined { - for (const key of required) { - const value = call.arguments[key]; - if (value === undefined || value === "") return key; - } - return undefined; -} - -function errorResult(callId: string, err: unknown): ToolResult { - return { - callId, - content: err instanceof Error ? err.message : String(err), - isError: true, - }; -} - -async function runEndpoint(env: ManusEnv, call: ToolCall, spec: EndpointSpec): Promise { - const credential = await resolveManusCredential(env); - if (credential === null) return notConnectedResult(call.id); - const missing = missingRequired(call, spec.required); - if (missing !== undefined) { - return { - callId: call.id, - content: `${spec.name} requires a non-empty ${missing} argument`, - isError: true, - }; - } - const params = pickParams(call, Object.keys(spec.properties)); - if (spec.name === "task_create") { - const content = stringArg(call, "content"); - if (content === undefined || content === "") { - return { - callId: call.id, - content: "task_create requires a non-empty content argument", - isError: true, - }; - } - try { - const created = await createTask(asClientConfig(credential), { - content, - ...optionalCreateFields(call), - }); - return { callId: call.id, content: JSON.stringify(created) }; - } catch (err) { - return errorResult(call.id, err); - } - } - if (spec.name === "task_detail") { - const taskId = stringArg(call, "task_id"); - if (taskId === undefined || taskId === "") { - return { - callId: call.id, - content: "task_detail requires a non-empty task_id argument", - isError: true, - }; - } - try { - const detail = await getTaskDetail(asClientConfig(credential), taskId); - return { callId: call.id, content: JSON.stringify(detail) }; - } catch (err) { - return errorResult(call.id, err); - } - } - if (spec.name === "task_send_msg") { - const content = stringArg(call, "content"); - const taskId = stringArg(call, "task_id"); - if (content === undefined || taskId === undefined) { - return { - callId: call.id, - content: "task_send_msg requires task_id and content", - isError: true, - }; - } - const body: Record = { - task_id: taskId, - message: buildTaskMessage(content, messageSkillFields(call)), - }; - const profile = stringArg(call, "agent_profile"); - if (profile !== undefined) body["agent_profile"] = profile; - try { - const result = await manusRequest(asClientConfig(credential), { - method: spec.method, - path: spec.path, - params: body, - }); - return { callId: call.id, content: JSON.stringify(result) }; - } catch (err) { - return errorResult(call.id, err); - } - } - if (spec.name === "task_list_msgs") { - const taskId = stringArg(call, "task_id"); - if (taskId === undefined || taskId === "") { - return { - callId: call.id, - content: "task_list_msgs requires a non-empty task_id argument", - isError: true, - }; - } - try { - const listed = await listTaskMessages(asClientConfig(credential), { - task_id: taskId, - ...optionalListMessageFields(call), - }); - return { callId: call.id, content: JSON.stringify(listed) }; - } catch (err) { - return errorResult(call.id, err); - } - } - try { - const result = await manusRequest(asClientConfig(credential), { - method: spec.method, - path: spec.path, - params, - }); - return { callId: call.id, content: JSON.stringify(result) }; - } catch (err) { - return errorResult(call.id, err); - } -} - -function optionalCreateFields(call: ToolCall): { - title?: string; - project_id?: string; - locale?: string; - interactive_mode?: boolean; - hide_in_task_list?: boolean; - share_visibility?: string; - agent_profile?: string; - enable_skills?: readonly string[]; - force_skills?: readonly string[]; - connectors?: readonly string[]; - task_references?: readonly string[]; - structured_output_schema?: Readonly>; -} { - const fields: { - title?: string; - project_id?: string; - locale?: string; - interactive_mode?: boolean; - hide_in_task_list?: boolean; - share_visibility?: string; - agent_profile?: string; - enable_skills?: readonly string[]; - force_skills?: readonly string[]; - connectors?: readonly string[]; - task_references?: readonly string[]; - structured_output_schema?: Readonly>; - } = {}; - const title = stringArg(call, "title"); - if (title !== undefined) fields.title = title; - const projectId = stringArg(call, "project_id"); - if (projectId !== undefined) fields.project_id = projectId; - const locale = stringArg(call, "locale"); - if (locale !== undefined) fields.locale = locale; - if (typeof call.arguments["interactive_mode"] === "boolean") { - fields.interactive_mode = call.arguments["interactive_mode"]; - } - if (typeof call.arguments["hide_in_task_list"] === "boolean") { - fields.hide_in_task_list = call.arguments["hide_in_task_list"]; - } - const visibility = stringArg(call, "share_visibility"); - if (visibility !== undefined) fields.share_visibility = visibility; - const profile = stringArg(call, "agent_profile"); - if (profile !== undefined) fields.agent_profile = profile; - const skills = messageSkillFields(call); - if (skills.enable_skills !== undefined) { - fields.enable_skills = skills.enable_skills; - } - if (skills.force_skills !== undefined) { - fields.force_skills = skills.force_skills; - } - if (skills.connectors !== undefined) { - fields.connectors = skills.connectors; - } - if (skills.task_references !== undefined) { - fields.task_references = skills.task_references; - } - const schema = objectArg(call, "structured_output_schema"); - if (schema !== undefined) fields.structured_output_schema = schema; - return fields; -} - -function stringArrayArg(call: ToolCall, key: string): readonly string[] | undefined { - const value = call.arguments[key]; - if (!Array.isArray(value)) return undefined; - if (!value.every((item) => typeof item === "string")) return undefined; - return value; -} - -function objectArg(call: ToolCall, key: string): Readonly> | undefined { - const value = call.arguments[key]; - if (typeof value !== "object" || value === null || Array.isArray(value)) { - return undefined; - } - const record: Record = {}; - for (const [field, fieldValue] of Object.entries(value)) { - record[field] = fieldValue; - } - return record; -} - -function messageSkillFields(call: ToolCall): { - enable_skills?: readonly string[]; - force_skills?: readonly string[]; - connectors?: readonly string[]; - task_references?: readonly string[]; -} { - const fields: { - enable_skills?: readonly string[]; - force_skills?: readonly string[]; - connectors?: readonly string[]; - task_references?: readonly string[]; - } = {}; - const enableSkills = stringArrayArg(call, "enable_skills"); - if (enableSkills !== undefined) fields.enable_skills = enableSkills; - const forceSkills = stringArrayArg(call, "force_skills"); - if (forceSkills !== undefined) fields.force_skills = forceSkills; - const connectors = stringArrayArg(call, "connectors"); - if (connectors !== undefined) fields.connectors = connectors; - const taskReferences = stringArrayArg(call, "task_references"); - if (taskReferences !== undefined) fields.task_references = taskReferences; - return fields; -} - -function optionalListMessageFields(call: ToolCall): { - limit?: number; - cursor?: string; - order?: string; - verbose?: boolean; - slides_format?: string; -} { - const fields: { - limit?: number; - cursor?: string; - order?: string; - verbose?: boolean; - slides_format?: string; - } = {}; - if (typeof call.arguments["limit"] === "number") { - fields.limit = call.arguments["limit"]; - } - const cursor = stringArg(call, "cursor"); - if (cursor !== undefined) fields.cursor = cursor; - const order = stringArg(call, "order"); - if (order !== undefined) fields.order = order; - if (typeof call.arguments["verbose"] === "boolean") { - fields.verbose = call.arguments["verbose"]; - } - const slidesFormat = stringArg(call, "slides_format"); - if (slidesFormat !== undefined) fields.slides_format = slidesFormat; - return fields; -} - -async function runCreateSlides( - env: ManusEnv, - call: ToolCall, - signal: AbortSignal, -): Promise { - const credential = await resolveManusCredential(env); - if (credential === null) return notConnectedResult(call.id); - const prompt = stringArg(call, "prompt"); - if (prompt === undefined || prompt === "") { - return { - callId: call.id, - content: `${CREATE_SLIDES_TOOL} requires a non-empty prompt argument`, - isError: true, - }; - } - const title = stringArg(call, "title"); - try { - const result = await createSlideDeck(asClientConfig(credential), { - content: prompt, - ...(title !== undefined ? { title } : {}), - signal, - }); - return { callId: call.id, content: JSON.stringify(result) }; - } catch (err) { - return errorResult(call.id, err); - } -} - -const CREATE_SLIDES_DEFINITION = { - name: CREATE_SLIDES_TOOL, - description: - "Creates a Manus task that produces a slide deck from a prompt, waits until the agent stops, and returns output files (filename, url, id) so they can be retrieved.", - inputSchema: { - type: "object", - properties: { - prompt: { - type: "string", - description: "What the slide deck should cover.", - }, - title: { - type: "string", - description: "Optional task title.", - }, - }, - required: ["prompt"], - }, -} as const; - -/** - * The `@corbits/manus-tools` bundle factory. The bundle id's local - * segment is kept short — the wire encoding of `:` must - * fit the 64-char OpenAI function-name cap. - */ -export const manusTools = defineTool({ - id: "@corbits/manus-tools/mn", - requires: ["credentials"], - definitions: [ - { name: CREATE_SLIDES_TOOL }, - ...MANUS_ENDPOINTS.map((spec) => - spec.approval === "ask" ? { name: spec.name, approval: "ask" as const } : { name: spec.name }, - ), - ], - factory: (env) => ({ - definitions: [ - CREATE_SLIDES_DEFINITION, - ...MANUS_ENDPOINTS.map((spec) => ({ - name: spec.name, - description: spec.description, - inputSchema: { - type: "object", - properties: spec.properties, - ...(spec.required.length > 0 ? { required: [...spec.required] } : {}), - }, - })), - ], - run: (call, signal) => { - if (call.name === CREATE_SLIDES_TOOL) { - return runCreateSlides(env, call, signal); - } - const spec = MANUS_ENDPOINTS.find((entry) => entry.name === call.name); - if (spec === undefined) { - return Promise.resolve({ - callId: call.id, - content: `Unknown Manus tool: ${call.name}`, - isError: true, - }); - } - return runEndpoint(env, call, spec); - }, - }), -}); diff --git a/tools/manus/tsconfig.json b/tools/manus/tsconfig.json deleted file mode 100644 index e125e90614..0000000000 --- a/tools/manus/tsconfig.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "extends": "./tsconfig.src.json", - "compilerOptions": { - "composite": false, - "noEmit": true, - "disableSourceOfProjectReferenceRedirect": true, - "declaration": false, - "declarationMap": false, - "emitDeclarationOnly": false, - "tsBuildInfoFile": "tsconfig.tsbuildinfo", - "rootDir": "../.." - }, - "include": ["src"], - "exclude": [] -} diff --git a/tools/manus/tsconfig.src.json b/tools/manus/tsconfig.src.json deleted file mode 100644 index fc8724305f..0000000000 --- a/tools/manus/tsconfig.src.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "include": ["src", "package.json", "src/**/*.json"], - "exclude": ["src/**/*.test.ts", "src/**/*.test.tsx"], - "compilerOptions": { - "types": ["bun"], - "composite": true, - "emitDeclarationOnly": true, - "outDir": "dist", - "tsBuildInfoFile": "dist/tsconfig.tsbuildinfo" - } -} diff --git a/tsconfig.build.json b/tsconfig.build.json index fba5446fa8..bc40745724 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -22,9 +22,6 @@ { "path": "./packages/collections/tsconfig.src.json" }, - { - "path": "./packages/credential-providers/tsconfig.src.json" - }, { "path": "./packages/cron/tsconfig.src.json" }, @@ -76,9 +73,6 @@ { "path": "./tools/linear/tsconfig.src.json" }, - { - "path": "./tools/manus/tsconfig.src.json" - }, { "path": "./tools/reddit/tsconfig.src.json" }, From 654f4765dcd20d0f5c7e4a1461ad37552299dac0 Mon Sep 17 00:00:00 2001 From: Sawyer Date: Thu, 17 Sep 2026 17:54:40 -0700 Subject: [PATCH 2/2] feat(sidecar): register credential-header and credential-mcp providers --- VENDORED.md | 2 +- apps/sidecar/package.json | 2 + .../sidecar/src/workflow-substrate-factory.ts | 22 +++++++++-- bun.lock | 38 +++---------------- 4 files changed, 27 insertions(+), 37 deletions(-) diff --git a/VENDORED.md b/VENDORED.md index df8b04b626..18a480b7f6 100644 --- a/VENDORED.md +++ b/VENDORED.md @@ -27,7 +27,7 @@ Pinned to [faremeter/interchange](https://github.com/faremeter/interchange) | Vendored path | What it is | Owner | Kill date | | ------------------------------ | ------------------------------------------------------------------------ | ------ | ---------- | -| `apps/sidecar` | Byte-identical copy of upstream's sidecar app; apps are never npm-published | sawyer | 2026-11-03 | +| `apps/sidecar` | Copy of upstream's sidecar app; apps are never npm-published. One local delta: `workflow-substrate-factory.ts` registers `@corbits/credential-header`'s and `@corbits/credential-mcp`'s providers alongside `builtinCredentialProviders()` | sawyer | 2026-11-03 | | `vendor/intx/agent` | `@intx/agent` at a newer commit than npm has published | sawyer | 2026-11-03 | | `vendor/intx/db` | `@intx/db`, with one local serving-time credential-refresh delta | sawyer | 2026-11-03 | | `vendor/intx/harness` | `@intx/harness` at a newer commit than npm has published | sawyer | 2026-11-03 | diff --git a/apps/sidecar/package.json b/apps/sidecar/package.json index a663a96f38..7472de6abb 100644 --- a/apps/sidecar/package.json +++ b/apps/sidecar/package.json @@ -15,6 +15,8 @@ "test": "bun test" }, "dependencies": { + "@corbits/credential-header": "github:corbitsdev/corbits-credential-header#eee7b7eb79755fd1ddc3eb2b9a57c4e50982e293", + "@corbits/credential-mcp": "github:corbitsdev/corbits-credential-mcp#fb9ec3a6754348cd33c388c70c0830b8844c83de", "@intx/agent": "workspace:*", "@intx/authz": "0.3.0", "@intx/crypto": "0.3.0", diff --git a/apps/sidecar/src/workflow-substrate-factory.ts b/apps/sidecar/src/workflow-substrate-factory.ts index 374ff4fd92..e0f41981eb 100644 --- a/apps/sidecar/src/workflow-substrate-factory.ts +++ b/apps/sidecar/src/workflow-substrate-factory.ts @@ -53,6 +53,11 @@ import { type ConnectorReplyDrain, type CredentialProviderRegistry, } from "@intx/harness"; +import { + rawAuthorizationCredentialProvider, + xApiKeyCredentialProvider, +} from "@corbits/credential-header"; +import { createMcpStreamableHttpCredentialProvider } from "@corbits/credential-mcp"; import { createSSHSignature } from "@intx/crypto"; import { createAgentRepoStore, @@ -2226,9 +2231,20 @@ export function createSidecarSubstrateFactory( // The credential provider registry that shapes a delivered credential into // a mediated handle. Built once here from the sidecar-static built-ins (the - // origin-pinned http provider) and shared by every per-step build; the - // per-run material and grants ride in separately at each invoke. - const credentialProviders = createCredentialProviderRegistry(builtinCredentialProviders()); + // origin-pinned http provider) plus the header-shaped presets + // (`@corbits/credential-header`, for a provider row whose API expects + // the raw secret in `authorization` or an `x-api-key` header instead of + // a Bearer-prefixed `authorization`) and the MCP streamable-HTTP + // provider (`@corbits/credential-mcp`, for a tenant-connected MCP + // server, including its keyless-connection sentinel) — shared by every + // per-step build; the per-run material and grants ride in separately at + // each invoke. + const credentialProviders = createCredentialProviderRegistry([ + ...builtinCredentialProviders(), + xApiKeyCredentialProvider(), + rawAuthorizationCredentialProvider(), + createMcpStreamableHttpCredentialProvider(), + ]); // Spawned-child step build env (INTR-310). Every spawned child's steps -- // a childWorkflow child's and an onTrigger section body's alike -- run real, diff --git a/bun.lock b/bun.lock index 4b47eb14cc..c41b2cc9ee 100644 --- a/bun.lock +++ b/bun.lock @@ -57,7 +57,6 @@ "@corbits/artifact-ui": "workspace:*", "@corbits/artifacts": "github:corbitsdev/corbits-artifacts#5309a15d4aa504f132c54b4da08bb672b4903873", "@corbits/codex-provider": "github:corbitsdev/corbits-codex-provider#a1f475f341261c05fa8dade0c82f1246c175b5b3", - "@corbits/credential-providers": "workspace:*", "@corbits/cron": "workspace:*", "@corbits/error-sink": "workspace:*", "@corbits/hub-api-client": "workspace:*", @@ -101,6 +100,8 @@ "workflow-child": "./bin/workflow-child", }, "dependencies": { + "@corbits/credential-header": "github:corbitsdev/corbits-credential-header#eee7b7eb79755fd1ddc3eb2b9a57c4e50982e293", + "@corbits/credential-mcp": "github:corbitsdev/corbits-credential-mcp#fb9ec3a6754348cd33c388c70c0830b8844c83de", "@intx/agent": "workspace:*", "@intx/authz": "0.3.0", "@intx/crypto": "0.3.0", @@ -257,18 +258,6 @@ "typescript": "catalog:", }, }, - "packages/credential-providers": { - "name": "@corbits/credential-providers", - "version": "0.0.1", - "dependencies": { - "@intx/harness": "workspace:*", - "@intx/types": "workspace:*", - }, - "devDependencies": { - "@types/bun": "catalog:", - "typescript": "catalog:", - }, - }, "packages/cron": { "name": "@corbits/cron", "version": "0.0.1", @@ -520,7 +509,6 @@ "arktype": "catalog:", }, "devDependencies": { - "@corbits/credential-providers": "workspace:*", "@intx/authz": "0.3.0", "@intx/crypto": "0.3.0", "@intx/db": "workspace:*", @@ -556,7 +544,6 @@ "arktype": "catalog:", }, "devDependencies": { - "@corbits/credential-providers": "workspace:*", "@intx/authz": "0.3.0", "@intx/crypto": "0.3.0", "@intx/db": "workspace:*", @@ -569,21 +556,6 @@ "@intx/types": "0.3.0", }, }, - "tools/manus": { - "name": "@corbits/manus-tools", - "version": "0.0.12", - "dependencies": { - "arktype": "catalog:", - }, - "devDependencies": { - "@types/bun": "catalog:", - "typescript": "catalog:", - }, - "peerDependencies": { - "@intx/agent": "0.3.0", - "@intx/types": "0.3.0", - }, - }, "tools/reddit": { "name": "@corbits/reddit-tools", "version": "0.0.2", @@ -1057,7 +1029,9 @@ "@corbits/collections": ["@corbits/collections@workspace:packages/collections"], - "@corbits/credential-providers": ["@corbits/credential-providers@workspace:packages/credential-providers"], + "@corbits/credential-header": ["@corbits/credential-header@github:corbitsdev/corbits-credential-header#eee7b7e", { "peerDependencies": { "@intx/harness": ">=0.3.0", "@intx/types": ">=0.3.0" } }, "corbitsdev-corbits-credential-header-eee7b7e", "sha512-jCgdLZDxHSqL7PJo/xwp/xTCXTBdBgTQb4ZMBwRYCS6x29j8EPtuQiX0mvzZPRXVi02cmz45Shbc2/xQsjZ1oQ=="], + + "@corbits/credential-mcp": ["@corbits/credential-mcp@github:corbitsdev/corbits-credential-mcp#fb9ec3a", { "peerDependencies": { "@intx/harness": ">=0.3.0", "@intx/types": ">=0.3.0" } }, "corbitsdev-corbits-credential-mcp-fb9ec3a", "sha512-Co4jR+L3pfBbVYY7I6jRftoHeSb5+LCxzEEaAhVLYA3aY2PrPHZV37+DWxj3fcK/KdzboqbT3XSnqU8DyHRU9Q=="], "@corbits/cron": ["@corbits/cron@workspace:packages/cron"], @@ -1079,8 +1053,6 @@ "@corbits/mailbox": ["@corbits/mailbox@github:corbitsdev/corbits-mailbox#e85b81e", { "dependencies": { "@hono/standard-validator": "0.2.3", "@intx/crypto": "0.3.0", "@standard-community/standard-json": "0.3.5", "@standard-community/standard-openapi": "0.2.9", "arktype": "2.1.29", "hono-openapi": "1.3.1" }, "peerDependencies": { "@intx/log": "^0.2.2", "drizzle-orm": "^0.45.2", "hono": "^4.12.0", "postgres": "^3.4.0" } }, "corbitsdev-corbits-mailbox-e85b81e", "sha512-ATPP/pll1sYG1DLKV1HvtboK8q1tFkqayQqRXdUmRUIsFJx5wqzd8YA1XELjXzLu1P2f2uCMe2CjsJHGv6E90Q=="], - "@corbits/manus-tools": ["@corbits/manus-tools@workspace:tools/manus"], - "@corbits/memory": ["@corbits/memory@github:corbitsdev/corbits-memory#9e6f213", { "dependencies": { "@intx/agent": "0.2.2", "@intx/authz": "0.2.2", "@intx/hub-api": "0.2.2", "@intx/log": "0.2.2", "@intx/workflow": "0.2.2", "arktype": "^2.1.29", "drizzle-orm": "^0.45.1", "hono": "^4.9.0", "hono-openapi": "^1.3.1", "postgres": "^3.4.7" } }, "corbitsdev-corbits-memory-9e6f213", "sha512-utnM4ZT2zmslcPXYWAAqxlDNLcpGsXFiTOtj8h7+OXnhCP0Eaw8yl25+yCTyHpvt3jcdeG4h5uFsSj7ou0BZCA=="], "@corbits/migration-runner": ["@corbits/migration-runner@workspace:packages/migration-runner"],