@vendoai/vendo 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +28 -0
- package/bin/vendo.mjs +4 -0
- package/dist/ai-sdk.d.ts +35 -0
- package/dist/ai-sdk.js +62 -0
- package/dist/auth-presets/auth-js.d.ts +14 -0
- package/dist/auth-presets/auth-js.js +91 -0
- package/dist/auth-presets/auth0.d.ts +23 -0
- package/dist/auth-presets/auth0.js +98 -0
- package/dist/auth-presets/clerk.d.ts +23 -0
- package/dist/auth-presets/clerk.js +65 -0
- package/dist/auth-presets/conformance.d.ts +42 -0
- package/dist/auth-presets/conformance.js +139 -0
- package/dist/auth-presets/identity.d.ts +56 -0
- package/dist/auth-presets/identity.js +152 -0
- package/dist/auth-presets/index.d.ts +14 -0
- package/dist/auth-presets/index.js +12 -0
- package/dist/auth-presets/jwt.d.ts +16 -0
- package/dist/auth-presets/jwt.js +54 -0
- package/dist/auth-presets/shared.d.ts +35 -0
- package/dist/auth-presets/shared.js +1 -0
- package/dist/auth-presets/supabase.d.ts +42 -0
- package/dist/auth-presets/supabase.js +229 -0
- package/dist/byo-approvals.d.ts +37 -0
- package/dist/byo-approvals.js +189 -0
- package/dist/capability-misses.d.ts +38 -0
- package/dist/capability-misses.js +172 -0
- package/dist/catalog.d.ts +19 -0
- package/dist/catalog.js +152 -0
- package/dist/cli/cloud/args.d.ts +3 -0
- package/dist/cli/cloud/args.js +32 -0
- package/dist/cli/cloud/auth.d.ts +17 -0
- package/dist/cli/cloud/auth.js +123 -0
- package/dist/cli/cloud/client.d.ts +28 -0
- package/dist/cli/cloud/client.js +133 -0
- package/dist/cli/cloud/command.d.ts +22 -0
- package/dist/cli/cloud/command.js +73 -0
- package/dist/cli/cloud/deploy.d.ts +26 -0
- package/dist/cli/cloud/deploy.js +187 -0
- package/dist/cli/cloud/device-login.d.ts +32 -0
- package/dist/cli/cloud/device-login.js +259 -0
- package/dist/cli/cloud/index.d.ts +5 -0
- package/dist/cli/cloud/index.js +59 -0
- package/dist/cli/cloud/keys.d.ts +2 -0
- package/dist/cli/cloud/keys.js +31 -0
- package/dist/cli/cloud/members.d.ts +3 -0
- package/dist/cli/cloud/members.js +25 -0
- package/dist/cli/cloud/output.d.ts +4 -0
- package/dist/cli/cloud/output.js +12 -0
- package/dist/cli/cloud/pending-claim.d.ts +29 -0
- package/dist/cli/cloud/pending-claim.js +38 -0
- package/dist/cli/cloud/read.d.ts +3 -0
- package/dist/cli/cloud/read.js +12 -0
- package/dist/cli/cloud/services.d.ts +2 -0
- package/dist/cli/cloud/services.js +9 -0
- package/dist/cli/cloud/session.d.ts +13 -0
- package/dist/cli/cloud/session.js +41 -0
- package/dist/cli/cloud-init.d.ts +60 -0
- package/dist/cli/cloud-init.js +149 -0
- package/dist/cli/dep-versions.d.ts +26 -0
- package/dist/cli/dep-versions.js +77 -0
- package/dist/cli/doctor-codes.d.ts +58 -0
- package/dist/cli/doctor-codes.js +60 -0
- package/dist/cli/doctor-live.d.ts +67 -0
- package/dist/cli/doctor-live.js +169 -0
- package/dist/cli/doctor.d.ts +52 -0
- package/dist/cli/doctor.js +467 -0
- package/dist/cli/eject.d.ts +29 -0
- package/dist/cli/eject.js +141 -0
- package/dist/cli/extract/apply.d.ts +26 -0
- package/dist/cli/extract/apply.js +123 -0
- package/dist/cli/extract/claude-cli-harness.d.ts +18 -0
- package/dist/cli/extract/claude-cli-harness.js +132 -0
- package/dist/cli/extract/claude-harness.d.ts +14 -0
- package/dist/cli/extract/claude-harness.js +127 -0
- package/dist/cli/extract/codex-cli-harness.d.ts +31 -0
- package/dist/cli/extract/codex-cli-harness.js +154 -0
- package/dist/cli/extract/delegate.d.ts +21 -0
- package/dist/cli/extract/delegate.js +77 -0
- package/dist/cli/extract/extraction.d.ts +65 -0
- package/dist/cli/extract/extraction.js +300 -0
- package/dist/cli/extract/gateway-fuel.d.ts +69 -0
- package/dist/cli/extract/gateway-fuel.js +69 -0
- package/dist/cli/extract/harness.d.ts +114 -0
- package/dist/cli/extract/harness.js +84 -0
- package/dist/cli/extract/index.d.ts +9 -0
- package/dist/cli/extract/index.js +9 -0
- package/dist/cli/extract/npx-engine-harness.d.ts +73 -0
- package/dist/cli/extract/npx-engine-harness.js +225 -0
- package/dist/cli/extract/stages.d.ts +149 -0
- package/dist/cli/extract/stages.js +398 -0
- package/dist/cli/framework.d.ts +8 -0
- package/dist/cli/framework.js +36 -0
- package/dist/cli/init-auth.d.ts +67 -0
- package/dist/cli/init-auth.js +142 -0
- package/dist/cli/init-scaffolds.d.ts +28 -0
- package/dist/cli/init-scaffolds.js +235 -0
- package/dist/cli/init.d.ts +115 -0
- package/dist/cli/init.js +1008 -0
- package/dist/cli/mcp/index.d.ts +7 -0
- package/dist/cli/mcp/index.js +59 -0
- package/dist/cli/mcp/registry.d.ts +9 -0
- package/dist/cli/mcp/registry.js +117 -0
- package/dist/cli/mcp/server-json.d.ts +12 -0
- package/dist/cli/mcp/server-json.js +65 -0
- package/dist/cli/mcp/server.schema.json +574 -0
- package/dist/cli/mcp/verify-domain.d.ts +11 -0
- package/dist/cli/mcp/verify-domain.js +48 -0
- package/dist/cli/playground/app/embed-entry.d.ts +20 -0
- package/dist/cli/playground/app/embed-entry.js +46 -0
- package/dist/cli/playground/app/fake-client.d.ts +3 -0
- package/dist/cli/playground/app/fake-client.js +215 -0
- package/dist/cli/playground/app/fixtures.d.ts +47 -0
- package/dist/cli/playground/app/fixtures.js +472 -0
- package/dist/cli/playground/app/main.d.ts +1 -0
- package/dist/cli/playground/app/main.js +108 -0
- package/dist/cli/playground/app/scenario-mount.d.ts +13 -0
- package/dist/cli/playground/app/scenario-mount.js +48 -0
- package/dist/cli/playground/app/scenarios.d.ts +25 -0
- package/dist/cli/playground/app/scenarios.js +152 -0
- package/dist/cli/playground/app/theme-editor.d.ts +13 -0
- package/dist/cli/playground/app/theme-editor.js +149 -0
- package/dist/cli/playground/app/theme-state.d.ts +29 -0
- package/dist/cli/playground/app/theme-state.js +151 -0
- package/dist/cli/playground/bundle.gen.d.ts +2 -0
- package/dist/cli/playground/bundle.gen.js +2 -0
- package/dist/cli/playground/embed-bundle.gen.d.ts +2 -0
- package/dist/cli/playground/embed-bundle.gen.js +2 -0
- package/dist/cli/playground.d.ts +33 -0
- package/dist/cli/playground.js +120 -0
- package/dist/cli/pretty.d.ts +48 -0
- package/dist/cli/pretty.js +330 -0
- package/dist/cli/refine.d.ts +43 -0
- package/dist/cli/refine.js +181 -0
- package/dist/cli/semantics.d.ts +31 -0
- package/dist/cli/semantics.js +122 -0
- package/dist/cli/shared.d.ts +68 -0
- package/dist/cli/shared.js +184 -0
- package/dist/cli/sync.d.ts +36 -0
- package/dist/cli/sync.js +202 -0
- package/dist/cli/theme/color.d.ts +15 -0
- package/dist/cli/theme/color.js +188 -0
- package/dist/cli/theme/css-vars.d.ts +13 -0
- package/dist/cli/theme/css-vars.js +40 -0
- package/dist/cli/theme/entry-candidates.d.ts +5 -0
- package/dist/cli/theme/entry-candidates.js +22 -0
- package/dist/cli/theme/extract-theme.d.ts +184 -0
- package/dist/cli/theme/extract-theme.js +358 -0
- package/dist/cli/theme/walk.d.ts +2 -0
- package/dist/cli/theme/walk.js +24 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +333 -0
- package/dist/cloud-apps.d.ts +17 -0
- package/dist/cloud-apps.js +46 -0
- package/dist/cloud-console.d.ts +32 -0
- package/dist/cloud-console.js +72 -0
- package/dist/cloud-tools.d.ts +23 -0
- package/dist/cloud-tools.js +196 -0
- package/dist/connections.d.ts +71 -0
- package/dist/connections.js +192 -0
- package/dist/deployment-identity.d.ts +12 -0
- package/dist/deployment-identity.js +69 -0
- package/dist/dev-creds/model.d.ts +65 -0
- package/dist/dev-creds/model.js +159 -0
- package/dist/dev-creds/resolve.d.ts +36 -0
- package/dist/dev-creds/resolve.js +57 -0
- package/dist/hosted-store.d.ts +52 -0
- package/dist/hosted-store.js +322 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +1 -0
- package/dist/mastra.d.ts +46 -0
- package/dist/mastra.js +88 -0
- package/dist/react.d.ts +10 -0
- package/dist/react.js +32 -0
- package/dist/refine.d.ts +244 -0
- package/dist/refine.js +599 -0
- package/dist/remixable.d.ts +18 -0
- package/dist/remixable.js +42 -0
- package/dist/runtime-capture.d.ts +18 -0
- package/dist/runtime-capture.js +111 -0
- package/dist/sandbox-wire.d.ts +101 -0
- package/dist/sandbox-wire.js +101 -0
- package/dist/sandbox.d.ts +38 -0
- package/dist/sandbox.js +389 -0
- package/dist/server.d.ts +216 -0
- package/dist/server.js +1320 -0
- package/dist/sync-impact.d.ts +14 -0
- package/dist/sync-impact.js +75 -0
- package/dist/turn-liveness.d.ts +33 -0
- package/dist/turn-liveness.js +105 -0
- package/dist/wire/approvals.d.ts +10 -0
- package/dist/wire/approvals.js +59 -0
- package/dist/wire/apps.d.ts +5 -0
- package/dist/wire/apps.js +155 -0
- package/dist/wire/automations.d.ts +5 -0
- package/dist/wire/automations.js +57 -0
- package/dist/wire/box.d.ts +3 -0
- package/dist/wire/box.js +268 -0
- package/dist/wire/connections.d.ts +5 -0
- package/dist/wire/connections.js +47 -0
- package/dist/wire/context.d.ts +22 -0
- package/dist/wire/context.js +190 -0
- package/dist/wire/doctor.d.ts +19 -0
- package/dist/wire/doctor.js +116 -0
- package/dist/wire/misc.d.ts +18 -0
- package/dist/wire/misc.js +227 -0
- package/dist/wire/shared.d.ts +158 -0
- package/dist/wire/shared.js +134 -0
- package/dist/wire/threads.d.ts +3 -0
- package/dist/wire/threads.js +68 -0
- package/package.json +151 -0
- package/skills/vendo-setup/SKILL.md +128 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# @vendoai/vendo
|
|
2
|
+
|
|
3
|
+
Vendo puts an agent inside your product. Customers can build views, act through
|
|
4
|
+
your APIs, and automate work inside your brand and guardrails.
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
npm install @vendoai/vendo
|
|
8
|
+
npx vendo init
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
This is the default composition: the public wire handler, React provider,
|
|
12
|
+
policy-bound agent and app blocks, persistence, MCP door, and the `vendo` CLI.
|
|
13
|
+
Install individual `@vendoai/*` blocks only when you want to compose Vendo
|
|
14
|
+
yourself.
|
|
15
|
+
|
|
16
|
+
Vendo extracts host APIs as signed-in-user tools, renders theme-driven React
|
|
17
|
+
surfaces, applies approvals and audit at one execution choke point, and uses
|
|
18
|
+
PGlite locally with the same schema on production Postgres. The store runtime
|
|
19
|
+
(`createStore`, `envSecrets`, `storeSecrets`, `secretStore`) is re-exported
|
|
20
|
+
from `@vendoai/vendo/server` for production deploys.
|
|
21
|
+
|
|
22
|
+
The composed agent reads `.vendo/brief.md` and the component catalog + theme
|
|
23
|
+
into its system prompt, cancels a turn when the client disconnects, and caps
|
|
24
|
+
tool steps per turn via `agent.maxSteps` (default 20) with a visible
|
|
25
|
+
step-limit notice in the stream.
|
|
26
|
+
|
|
27
|
+
Read the [quickstart](https://docs.vendo.run/quickstart) and
|
|
28
|
+
[CLI reference](https://docs.vendo.run/reference/cli).
|
package/bin/vendo.mjs
ADDED
package/dist/ai-sdk.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type ToolSet } from "ai";
|
|
2
|
+
import type { Vendo } from "./server.js";
|
|
3
|
+
/**
|
|
4
|
+
* `@vendoai/vendo/ai-sdk` — the BYO-agent seam for AI SDK loops (frozen
|
|
5
|
+
* contract: docs/superpowers/specs/2026-07-20-existing-agents-contracts.md §2).
|
|
6
|
+
* One thin format shim over the framework-neutral tool pack in
|
|
7
|
+
* `@vendoai/agent`, executing through `vendo.guardedTools` — the guard-bound
|
|
8
|
+
* registry Vendo's own loop shares, decorated to park pending-approval calls
|
|
9
|
+
* so `<VendoApprovalEmbed>` can resume them over the wire — plus
|
|
10
|
+
* `agent.asRunner()` behind `vendo_delegate`. No tool reachable from the host
|
|
11
|
+
* loop has an unguarded route.
|
|
12
|
+
*/
|
|
13
|
+
export { VENDO_CREATE_APP_TOOL, VENDO_DELEGATE_TOOL, VENDO_TOOL_PACK_PREFIX, type VendoDelegateResult, type VendoToolPackFilter, type VendoToolPackOptions, } from "@vendoai/agent";
|
|
14
|
+
import type { VendoToolPackOptions } from "@vendoai/agent";
|
|
15
|
+
/**
|
|
16
|
+
* Build the Vendo tool pack as an AI SDK `ToolSet` for `streamText`/
|
|
17
|
+
* `generateText`. Built PER REQUEST: tool execution needs a principal-scoped
|
|
18
|
+
* RunContext, so resolve the caller's principal first and spread the result
|
|
19
|
+
* into your route handler's `tools`:
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* const result = streamText({
|
|
23
|
+
* model,
|
|
24
|
+
* messages,
|
|
25
|
+
* tools: { ...myTools, ...(await vendoTools(vendo, { principal })) },
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* A `vendo_*` tool returns either a versioned envelope — `vendo/app-ref@1`
|
|
30
|
+
* (render with `<VendoAppEmbed>`) or `vendo/approval-ref@1` (parks server-side;
|
|
31
|
+
* render with `<VendoApprovalEmbed>`) — or plain data, meaning the guarded call
|
|
32
|
+
* executed cleanly. `options.sessionId` carries the host session id into audit;
|
|
33
|
+
* unset, the shim mints one per pack build.
|
|
34
|
+
*/
|
|
35
|
+
export declare function vendoTools(vendo: Vendo, options: VendoToolPackOptions): Promise<ToolSet>;
|
package/dist/ai-sdk.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { buildVendoToolPack } from "@vendoai/agent";
|
|
2
|
+
import { VendoError } from "@vendoai/core";
|
|
3
|
+
import { dynamicTool, jsonSchema } from "ai";
|
|
4
|
+
/**
|
|
5
|
+
* `@vendoai/vendo/ai-sdk` — the BYO-agent seam for AI SDK loops (frozen
|
|
6
|
+
* contract: docs/superpowers/specs/2026-07-20-existing-agents-contracts.md §2).
|
|
7
|
+
* One thin format shim over the framework-neutral tool pack in
|
|
8
|
+
* `@vendoai/agent`, executing through `vendo.guardedTools` — the guard-bound
|
|
9
|
+
* registry Vendo's own loop shares, decorated to park pending-approval calls
|
|
10
|
+
* so `<VendoApprovalEmbed>` can resume them over the wire — plus
|
|
11
|
+
* `agent.asRunner()` behind `vendo_delegate`. No tool reachable from the host
|
|
12
|
+
* loop has an unguarded route.
|
|
13
|
+
*/
|
|
14
|
+
export { VENDO_CREATE_APP_TOOL, VENDO_DELEGATE_TOOL, VENDO_TOOL_PACK_PREFIX, } from "@vendoai/agent";
|
|
15
|
+
/**
|
|
16
|
+
* Build the Vendo tool pack as an AI SDK `ToolSet` for `streamText`/
|
|
17
|
+
* `generateText`. Built PER REQUEST: tool execution needs a principal-scoped
|
|
18
|
+
* RunContext, so resolve the caller's principal first and spread the result
|
|
19
|
+
* into your route handler's `tools`:
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* const result = streamText({
|
|
23
|
+
* model,
|
|
24
|
+
* messages,
|
|
25
|
+
* tools: { ...myTools, ...(await vendoTools(vendo, { principal })) },
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* A `vendo_*` tool returns either a versioned envelope — `vendo/app-ref@1`
|
|
30
|
+
* (render with `<VendoAppEmbed>`) or `vendo/approval-ref@1` (parks server-side;
|
|
31
|
+
* render with `<VendoApprovalEmbed>`) — or plain data, meaning the guarded call
|
|
32
|
+
* executed cleanly. `options.sessionId` carries the host session id into audit;
|
|
33
|
+
* unset, the shim mints one per pack build.
|
|
34
|
+
*/
|
|
35
|
+
export async function vendoTools(vendo, options) {
|
|
36
|
+
if (typeof options?.principal?.kind !== "string" || typeof options.principal.subject !== "string") {
|
|
37
|
+
throw new VendoError("validation", "vendoTools requires a principal — resolve the host session's user before building the pack");
|
|
38
|
+
}
|
|
39
|
+
// The frozen context tuple for a BYO loop: a chat surface that is not
|
|
40
|
+
// Vendo's, with the user present. Park-and-resume replays pin this tuple.
|
|
41
|
+
const ctx = {
|
|
42
|
+
principal: options.principal,
|
|
43
|
+
venue: "chat",
|
|
44
|
+
presence: "present",
|
|
45
|
+
sessionId: options.sessionId ?? `session_${globalThis.crypto.randomUUID()}`,
|
|
46
|
+
};
|
|
47
|
+
const pack = await buildVendoToolPack({
|
|
48
|
+
registry: vendo.guardedTools,
|
|
49
|
+
runner: vendo.agent.asRunner(),
|
|
50
|
+
...(options.include === undefined ? {} : { include: options.include }),
|
|
51
|
+
...(options.exclude === undefined ? {} : { exclude: options.exclude }),
|
|
52
|
+
});
|
|
53
|
+
const tools = {};
|
|
54
|
+
for (const entry of pack) {
|
|
55
|
+
tools[entry.name] = dynamicTool({
|
|
56
|
+
description: entry.description,
|
|
57
|
+
inputSchema: jsonSchema(entry.inputSchema),
|
|
58
|
+
execute: (input, { toolCallId }) => entry.execute(input, { ctx, callId: toolCallId }),
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return tools;
|
|
62
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { HostAuthPreset, HostAuthPresetOptions } from "./shared.js";
|
|
2
|
+
/**
|
|
3
|
+
* 09-vendo §2.1 — the Auth.js host-identity preset. Zero-argument in the
|
|
4
|
+
* standard case: the secret is AUTH_SECRET, the secure-cookie posture follows
|
|
5
|
+
* VENDO_BASE_URL (https → `__Secure-` names), and the principal's display
|
|
6
|
+
* derives from the session token's name/email claims. An optional subject→user
|
|
7
|
+
* resolver overrides claims-derived identity for BOTH the principal display and
|
|
8
|
+
* the actAs session claims; its null means "subject unknown to host" (the
|
|
9
|
+
* session is treated as absent, actAs declines, the door's lookup returns null).
|
|
10
|
+
*
|
|
11
|
+
* The actAs half IS the shipped `@vendoai/actions/presets` authJsPreset — one
|
|
12
|
+
* minting story (04 §2.1), configured from these same options.
|
|
13
|
+
*/
|
|
14
|
+
export declare function authJs(options?: HostAuthPresetOptions): HostAuthPreset;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// authJsPreset ships on its own subpath, not the shared "@vendoai/actions/presets"
|
|
2
|
+
// barrel: it is the only preset there with a top-level optional-peer dynamic
|
|
3
|
+
// import (@auth/core/jwt), and bundlers resolve every `export ... from` target
|
|
4
|
+
// in a barrel file regardless of which export a consumer uses (corpus-triage
|
|
5
|
+
// Task 9 — mirrors the same split done for this file's own vendo-side barrel).
|
|
6
|
+
import { authJsPreset } from "@vendoai/actions/presets/auth-js";
|
|
7
|
+
import { environment } from "../wire/shared.js";
|
|
8
|
+
import { actAsClaimsFromUser, composeHostAuthPreset, lazyActAs, lazyModule, loginRedirect, makeUserResolver, resolvePresetSecret, userFromNameEmailClaims, } from "./identity.js";
|
|
9
|
+
/** Same optional-dependency strategy as the actions preset's own encoder
|
|
10
|
+
(packages/actions presets/auth-js.ts): `@auth/core` is an optional
|
|
11
|
+
peerDependency loaded lazily on first use — a host wiring authJs() already
|
|
12
|
+
runs Auth.js, so it is present next to their auth setup. The failure is an
|
|
13
|
+
actionable install instruction, not a bare module-not-found. */
|
|
14
|
+
const MISSING_AUTH_CORE_MESSAGE = "authJs() reads the Auth.js session through @auth/core, which is not installed. Install it alongside your Auth.js setup: npm install @auth/core";
|
|
15
|
+
const MISSING_SECRET_MESSAGE = "authJs() has no session secret: set AUTH_SECRET (mirroring Auth.js itself) or pass authJs({ secret }).";
|
|
16
|
+
/** Node's dynamic-import failure for a package that simply isn't installed. */
|
|
17
|
+
function isAuthCoreNotFound(error) {
|
|
18
|
+
return error instanceof Error
|
|
19
|
+
&& error.code === "ERR_MODULE_NOT_FOUND"
|
|
20
|
+
&& error.message.includes("@auth/core");
|
|
21
|
+
}
|
|
22
|
+
const loadGetToken = lazyModule(() => import("@auth/core/jwt").then((module) => module.getToken), MISSING_AUTH_CORE_MESSAGE);
|
|
23
|
+
/** Secure-cookie posture, generalized from demo-bank's isSecureDeployment: the
|
|
24
|
+
deployment is secure exactly when the operator-set VENDO_BASE_URL parses as
|
|
25
|
+
an https URL — TLS terminates at a trusted proxy and Auth.js is using its
|
|
26
|
+
`__Secure-` cookie names. Same trusted-origin channel the umbrella already
|
|
27
|
+
uses for anon-cookie hardening and door metadata; never derived from
|
|
28
|
+
forwarded headers. */
|
|
29
|
+
function isSecureDeployment() {
|
|
30
|
+
const base = environment("VENDO_BASE_URL");
|
|
31
|
+
if (base === undefined)
|
|
32
|
+
return false;
|
|
33
|
+
try {
|
|
34
|
+
return new URL(base).protocol === "https:";
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* 09-vendo §2.1 — the Auth.js host-identity preset. Zero-argument in the
|
|
42
|
+
* standard case: the secret is AUTH_SECRET, the secure-cookie posture follows
|
|
43
|
+
* VENDO_BASE_URL (https → `__Secure-` names), and the principal's display
|
|
44
|
+
* derives from the session token's name/email claims. An optional subject→user
|
|
45
|
+
* resolver overrides claims-derived identity for BOTH the principal display and
|
|
46
|
+
* the actAs session claims; its null means "subject unknown to host" (the
|
|
47
|
+
* session is treated as absent, actAs declines, the door's lookup returns null).
|
|
48
|
+
*
|
|
49
|
+
* The actAs half IS the shipped `@vendoai/actions/presets` authJsPreset — one
|
|
50
|
+
* minting story (04 §2.1), configured from these same options.
|
|
51
|
+
*/
|
|
52
|
+
export function authJs(options = {}) {
|
|
53
|
+
const { secret, user } = options;
|
|
54
|
+
const sessionClaims = async (request) => {
|
|
55
|
+
const getToken = await loadGetToken();
|
|
56
|
+
return getToken({
|
|
57
|
+
req: request,
|
|
58
|
+
secret: await resolvePresetSecret(secret, "AUTH_SECRET", MISSING_SECRET_MESSAGE),
|
|
59
|
+
secureCookie: isSecureDeployment(),
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
// Away + MCP execution: the shipped Auth.js minting preset, fed the same
|
|
63
|
+
// secret/posture/identity this preset resolves sessions with. Built lazily
|
|
64
|
+
// on FIRST MINT and cached (its TokenCache survives across calls): the
|
|
65
|
+
// secure-cookie posture then resolves at use time like the secret does,
|
|
66
|
+
// never racing env loading at composition. A missing @auth/core fails with
|
|
67
|
+
// the same actionable install error as the other two halves, not the
|
|
68
|
+
// encoder's bare module-not-found.
|
|
69
|
+
const mint = lazyActAs(() => authJsPreset({
|
|
70
|
+
...(secret === undefined ? {} : { secret }),
|
|
71
|
+
secureCookie: isSecureDeployment(),
|
|
72
|
+
...(user === undefined ? {} : { claims: actAsClaimsFromUser(user) }),
|
|
73
|
+
}));
|
|
74
|
+
const actAs = async (principal, grant) => {
|
|
75
|
+
try {
|
|
76
|
+
return await mint(principal, grant);
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
if (isAuthCoreNotFound(error)) {
|
|
80
|
+
throw new Error(MISSING_AUTH_CORE_MESSAGE, { cause: error });
|
|
81
|
+
}
|
|
82
|
+
throw error;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
return composeHostAuthPreset({
|
|
86
|
+
sessionClaims,
|
|
87
|
+
resolveUser: makeUserResolver(user, userFromNameEmailClaims),
|
|
88
|
+
actAs,
|
|
89
|
+
login: (request, returnTo) => loginRedirect(request, returnTo),
|
|
90
|
+
});
|
|
91
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { HostAuthPreset, HostAuthPresetOptions } from "./shared.js";
|
|
2
|
+
/**
|
|
3
|
+
* 09-vendo §2.1 — the Auth0 host-identity preset. Zero-argument in the
|
|
4
|
+
* standard case: the tenant reads Auth0's own env (AUTH0_DOMAIN, or the v3
|
|
5
|
+
* AUTH0_ISSUER_BASE_URL; AUTH0_AUDIENCE enforced when set), the session is
|
|
6
|
+
* the Auth0-issued RS256 JWT presented as Authorization: Bearer and verified
|
|
7
|
+
* against the tenant JWKS with the issuer check, and display derives from the
|
|
8
|
+
* OIDC name/email claims. The optional subject→user resolver has the same
|
|
9
|
+
* semantics as authJs (null = subject unknown → decline/null). The Auth0
|
|
10
|
+
* SDK's encrypted `appSession` cookie is SDK-internal and stays with the
|
|
11
|
+
* host's own middleware — it is not a verifiable token.
|
|
12
|
+
*
|
|
13
|
+
* Auth0 holds the private keys for its RS256 sessions, so the actAs half is
|
|
14
|
+
* the shipped away-token producer (`auth0Preset`, 04 §2.1) — minting a
|
|
15
|
+
* host-owned `VendoAway` token under VENDO_AWAY_TOKEN_SECRET; the matching
|
|
16
|
+
* verify half stays host-mounted middleware (producer/verify split). The
|
|
17
|
+
* `secret` option therefore overrides the AWAY-TOKEN secret (the preset's
|
|
18
|
+
* system-equivalent shared secret).
|
|
19
|
+
*
|
|
20
|
+
* The door's sessionless redirect follows the Auth0 v4 SDK's route
|
|
21
|
+
* convention: /auth/login, which natively honors returnTo.
|
|
22
|
+
*/
|
|
23
|
+
export declare function auth0(options?: HostAuthPresetOptions): HostAuthPreset;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { auth0Preset } from "@vendoai/actions/presets";
|
|
2
|
+
import { environment } from "../wire/shared.js";
|
|
3
|
+
import { actAsClaimsFromUser, bearerToken, composeHostAuthPreset, lazyActAs, lazyModule, loginRedirect, makeUserResolver, userFromNameEmailClaims, } from "./identity.js";
|
|
4
|
+
/** Same optional-dependency strategy as authJs's @auth/core: jose is an
|
|
5
|
+
optional peerDependency loaded lazily on first use (Auth0's RS256 tokens
|
|
6
|
+
verify against the tenant JWKS — provider-held keys, 04 §2.1, so a JOSE
|
|
7
|
+
verifier is required and jose is the SDK Auth0's own libraries build on).
|
|
8
|
+
The failure is an actionable install instruction, not a bare
|
|
9
|
+
module-not-found. */
|
|
10
|
+
const MISSING_JOSE_MESSAGE = "auth0() verifies Auth0 session tokens through jose, which is not installed. Install it next to your Auth0 setup: npm install jose";
|
|
11
|
+
const MISSING_DOMAIN_MESSAGE = "auth0() has no tenant domain: set AUTH0_DOMAIN (e.g. your-tenant.us.auth0.com — mirroring the Auth0 SDKs) or AUTH0_ISSUER_BASE_URL.";
|
|
12
|
+
const loadJose = lazyModule(() => import("jose").then((module) => module), MISSING_JOSE_MESSAGE);
|
|
13
|
+
/** The tenant issuer per Auth0's env conventions: AUTH0_DOMAIN (the v4 SDK's
|
|
14
|
+
bare domain, scheme tolerated), else AUTH0_ISSUER_BASE_URL (the v3 SDK's
|
|
15
|
+
full URL). Auth0 issuers always carry the trailing slash. */
|
|
16
|
+
function tenantIssuer() {
|
|
17
|
+
const domain = environment("AUTH0_DOMAIN");
|
|
18
|
+
if (domain !== undefined) {
|
|
19
|
+
return domain.startsWith("http://") || domain.startsWith("https://")
|
|
20
|
+
? `${new URL(domain).origin}/`
|
|
21
|
+
: `https://${domain}/`;
|
|
22
|
+
}
|
|
23
|
+
const base = environment("AUTH0_ISSUER_BASE_URL");
|
|
24
|
+
if (base !== undefined) {
|
|
25
|
+
try {
|
|
26
|
+
return `${new URL(base).origin}/`;
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
throw new Error(MISSING_DOMAIN_MESSAGE);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
throw new Error(MISSING_DOMAIN_MESSAGE);
|
|
33
|
+
}
|
|
34
|
+
/** jose's remote JWKS resolvers cache fetched keys per instance — keep one per
|
|
35
|
+
tenant URL so verification never refetches per request. */
|
|
36
|
+
const jwksByUrl = new Map();
|
|
37
|
+
function tenantJwks(jose, issuer) {
|
|
38
|
+
const url = new URL(".well-known/jwks.json", issuer).toString();
|
|
39
|
+
let jwks = jwksByUrl.get(url);
|
|
40
|
+
if (jwks === undefined) {
|
|
41
|
+
jwks = jose.createRemoteJWKSet(new URL(url));
|
|
42
|
+
jwksByUrl.set(url, jwks);
|
|
43
|
+
}
|
|
44
|
+
return jwks;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* 09-vendo §2.1 — the Auth0 host-identity preset. Zero-argument in the
|
|
48
|
+
* standard case: the tenant reads Auth0's own env (AUTH0_DOMAIN, or the v3
|
|
49
|
+
* AUTH0_ISSUER_BASE_URL; AUTH0_AUDIENCE enforced when set), the session is
|
|
50
|
+
* the Auth0-issued RS256 JWT presented as Authorization: Bearer and verified
|
|
51
|
+
* against the tenant JWKS with the issuer check, and display derives from the
|
|
52
|
+
* OIDC name/email claims. The optional subject→user resolver has the same
|
|
53
|
+
* semantics as authJs (null = subject unknown → decline/null). The Auth0
|
|
54
|
+
* SDK's encrypted `appSession` cookie is SDK-internal and stays with the
|
|
55
|
+
* host's own middleware — it is not a verifiable token.
|
|
56
|
+
*
|
|
57
|
+
* Auth0 holds the private keys for its RS256 sessions, so the actAs half is
|
|
58
|
+
* the shipped away-token producer (`auth0Preset`, 04 §2.1) — minting a
|
|
59
|
+
* host-owned `VendoAway` token under VENDO_AWAY_TOKEN_SECRET; the matching
|
|
60
|
+
* verify half stays host-mounted middleware (producer/verify split). The
|
|
61
|
+
* `secret` option therefore overrides the AWAY-TOKEN secret (the preset's
|
|
62
|
+
* system-equivalent shared secret).
|
|
63
|
+
*
|
|
64
|
+
* The door's sessionless redirect follows the Auth0 v4 SDK's route
|
|
65
|
+
* convention: /auth/login, which natively honors returnTo.
|
|
66
|
+
*/
|
|
67
|
+
export function auth0(options = {}) {
|
|
68
|
+
const { secret, user } = options;
|
|
69
|
+
const sessionClaims = async (request) => {
|
|
70
|
+
const token = bearerToken(request);
|
|
71
|
+
if (token === undefined)
|
|
72
|
+
return null;
|
|
73
|
+
const issuer = tenantIssuer();
|
|
74
|
+
const audience = environment("AUTH0_AUDIENCE");
|
|
75
|
+
const jose = await loadJose();
|
|
76
|
+
try {
|
|
77
|
+
const { payload } = await jose.jwtVerify(token, tenantJwks(jose, issuer), {
|
|
78
|
+
issuer,
|
|
79
|
+
...(audience === undefined ? {} : { audience }),
|
|
80
|
+
});
|
|
81
|
+
return payload;
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
return null; // unverifiable/expired/foreign token = no session
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
return composeHostAuthPreset({
|
|
88
|
+
sessionClaims,
|
|
89
|
+
resolveUser: makeUserResolver(user, userFromNameEmailClaims),
|
|
90
|
+
// Away + MCP execution: the shipped away-token producer half (04 §2.1);
|
|
91
|
+
// the host mounts the matching verify middleware on its API.
|
|
92
|
+
actAs: lazyActAs(() => auth0Preset({
|
|
93
|
+
...(secret === undefined ? {} : { secret }),
|
|
94
|
+
...(user === undefined ? {} : { claims: actAsClaimsFromUser(user) }),
|
|
95
|
+
}).actAs),
|
|
96
|
+
login: (request, returnTo) => loginRedirect(request, returnTo, "/auth/login"),
|
|
97
|
+
});
|
|
98
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { HostAuthPreset, HostAuthPresetOptions } from "./shared.js";
|
|
2
|
+
/**
|
|
3
|
+
* 09-vendo §2.1 — the Clerk host-identity preset. Zero-argument in the
|
|
4
|
+
* standard case: session verification reads Clerk's own env (CLERK_SECRET_KEY;
|
|
5
|
+
* CLERK_JWT_KEY when set enables Clerk's networkless path and is preferred),
|
|
6
|
+
* the session token comes off the request per Clerk's conventions (the
|
|
7
|
+
* `__session` cookie or Authorization: Bearer), and display derives from
|
|
8
|
+
* name/email claims. The optional subject→user resolver has the same
|
|
9
|
+
* semantics as authJs (null = subject unknown → decline/null).
|
|
10
|
+
*
|
|
11
|
+
* Clerk holds the private keys for its RS256 sessions, so the actAs half is
|
|
12
|
+
* the shipped away-token producer (`clerkPreset`, 04 §2.1) — minting a
|
|
13
|
+
* host-owned `VendoAway` token under VENDO_AWAY_TOKEN_SECRET; the matching
|
|
14
|
+
* verify half stays host-mounted middleware (producer/verify split). The
|
|
15
|
+
* `secret` option therefore overrides the AWAY-TOKEN secret (the preset's
|
|
16
|
+
* system-equivalent shared secret), never the Clerk secret key, which is an
|
|
17
|
+
* API credential and stays env-only.
|
|
18
|
+
*
|
|
19
|
+
* The door's sessionless redirect follows Clerk's sign-in convention:
|
|
20
|
+
* NEXT_PUBLIC_CLERK_SIGN_IN_URL when set, else /sign-in, carrying both the
|
|
21
|
+
* standard returnTo and Clerk's redirect_url.
|
|
22
|
+
*/
|
|
23
|
+
export declare function clerk(options?: HostAuthPresetOptions): HostAuthPreset;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { clerkPreset } from "@vendoai/actions/presets";
|
|
2
|
+
import { environment } from "../wire/shared.js";
|
|
3
|
+
import { actAsClaimsFromUser, bearerToken, composeHostAuthPreset, cookieValue, lazyActAs, lazyModule, loginRedirect, makeUserResolver, userFromNameEmailClaims, } from "./identity.js";
|
|
4
|
+
/** Same optional-dependency strategy as authJs's @auth/core: @clerk/backend is
|
|
5
|
+
an optional peerDependency loaded lazily on first use — a host wiring
|
|
6
|
+
clerk() already runs Clerk, so it is present next to their auth setup. The
|
|
7
|
+
failure is an actionable install instruction, not a bare module-not-found. */
|
|
8
|
+
const MISSING_CLERK_BACKEND_MESSAGE = "clerk() reads the Clerk session through @clerk/backend, which is not installed. Install it alongside your Clerk setup: npm install @clerk/backend";
|
|
9
|
+
const MISSING_KEY_MESSAGE = "clerk() has no verification key: set CLERK_SECRET_KEY (mirroring Clerk's own SDKs), optionally with CLERK_JWT_KEY (the instance's PEM public key) for networkless verification.";
|
|
10
|
+
const loadVerifyToken = lazyModule(() => import("@clerk/backend").then((module) => module.verifyToken), MISSING_CLERK_BACKEND_MESSAGE);
|
|
11
|
+
/**
|
|
12
|
+
* 09-vendo §2.1 — the Clerk host-identity preset. Zero-argument in the
|
|
13
|
+
* standard case: session verification reads Clerk's own env (CLERK_SECRET_KEY;
|
|
14
|
+
* CLERK_JWT_KEY when set enables Clerk's networkless path and is preferred),
|
|
15
|
+
* the session token comes off the request per Clerk's conventions (the
|
|
16
|
+
* `__session` cookie or Authorization: Bearer), and display derives from
|
|
17
|
+
* name/email claims. The optional subject→user resolver has the same
|
|
18
|
+
* semantics as authJs (null = subject unknown → decline/null).
|
|
19
|
+
*
|
|
20
|
+
* Clerk holds the private keys for its RS256 sessions, so the actAs half is
|
|
21
|
+
* the shipped away-token producer (`clerkPreset`, 04 §2.1) — minting a
|
|
22
|
+
* host-owned `VendoAway` token under VENDO_AWAY_TOKEN_SECRET; the matching
|
|
23
|
+
* verify half stays host-mounted middleware (producer/verify split). The
|
|
24
|
+
* `secret` option therefore overrides the AWAY-TOKEN secret (the preset's
|
|
25
|
+
* system-equivalent shared secret), never the Clerk secret key, which is an
|
|
26
|
+
* API credential and stays env-only.
|
|
27
|
+
*
|
|
28
|
+
* The door's sessionless redirect follows Clerk's sign-in convention:
|
|
29
|
+
* NEXT_PUBLIC_CLERK_SIGN_IN_URL when set, else /sign-in, carrying both the
|
|
30
|
+
* standard returnTo and Clerk's redirect_url.
|
|
31
|
+
*/
|
|
32
|
+
export function clerk(options = {}) {
|
|
33
|
+
const { secret, user } = options;
|
|
34
|
+
const sessionClaims = async (request) => {
|
|
35
|
+
const token = bearerToken(request) ?? cookieValue(request, "__session");
|
|
36
|
+
if (token === undefined)
|
|
37
|
+
return null;
|
|
38
|
+
const jwtKey = environment("CLERK_JWT_KEY");
|
|
39
|
+
const secretKey = environment("CLERK_SECRET_KEY");
|
|
40
|
+
if (jwtKey === undefined && secretKey === undefined) {
|
|
41
|
+
throw new Error(MISSING_KEY_MESSAGE);
|
|
42
|
+
}
|
|
43
|
+
const verifyToken = await loadVerifyToken();
|
|
44
|
+
try {
|
|
45
|
+
return await verifyToken(token, {
|
|
46
|
+
...(jwtKey === undefined ? {} : { jwtKey }),
|
|
47
|
+
...(secretKey === undefined ? {} : { secretKey }),
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return null; // unverifiable/expired token = no session, mirroring authJs
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
return composeHostAuthPreset({
|
|
55
|
+
sessionClaims,
|
|
56
|
+
resolveUser: makeUserResolver(user, userFromNameEmailClaims),
|
|
57
|
+
// Away + MCP execution: the shipped away-token producer half (04 §2.1);
|
|
58
|
+
// the host mounts the matching verify middleware on its API.
|
|
59
|
+
actAs: lazyActAs(() => clerkPreset({
|
|
60
|
+
...(secret === undefined ? {} : { secret }),
|
|
61
|
+
...(user === undefined ? {} : { claims: actAsClaimsFromUser(user) }),
|
|
62
|
+
}).actAs),
|
|
63
|
+
login: (request, returnTo) => loginRedirect(request, returnTo, environment("NEXT_PUBLIC_CLERK_SIGN_IN_URL") ?? "/sign-in", { redirect_url: returnTo }),
|
|
64
|
+
});
|
|
65
|
+
}
|