@open-everywhere/adapters 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +21 -0
  3. package/README.md +43 -0
  4. package/agent/aws/cli.ts +121 -0
  5. package/agent/aws/config.ts +71 -0
  6. package/agent/aws/register.ts +65 -0
  7. package/agent/aws/sso.ts +567 -0
  8. package/agent/aws/sts.ts +191 -0
  9. package/agent/blob/hosting.ts +24 -0
  10. package/agent/browser/config.ts +62 -0
  11. package/agent/browser/register.ts +66 -0
  12. package/agent/browser/sandbox.ts +39 -0
  13. package/agent/contributions.ts +12 -0
  14. package/agent/directory/config.ts +138 -0
  15. package/agent/directory/okta.ts +226 -0
  16. package/agent/directory/register.ts +16 -0
  17. package/agent/instrumentation.ts +42 -0
  18. package/agent/model/approval-judge.ts +57 -0
  19. package/agent/model/dream-judge.ts +105 -0
  20. package/agent/model/gateway-vision.ts +162 -0
  21. package/agent/model/gateway.ts +85 -0
  22. package/agent/oe-oauth/config.ts +246 -0
  23. package/agent/oe-oauth/errors.ts +77 -0
  24. package/agent/oe-oauth/oauth-client.ts +376 -0
  25. package/agent/oe-oauth/pkce.ts +21 -0
  26. package/agent/oe-oauth/register.ts +32 -0
  27. package/agent/oe-oauth/token-vault.ts +652 -0
  28. package/agent/oe-oauth/user-auth-flow.ts +76 -0
  29. package/agent/postgres/neon.ts +108 -0
  30. package/agent/sandbox/backend-stop.ts +259 -0
  31. package/agent/sandbox/created-sandbox-registry.ts +27 -0
  32. package/agent/sandbox/extend-workspace-time.ts +77 -0
  33. package/agent/sandbox/vercel-lifecycle.ts +252 -0
  34. package/dist/agent/aws/cli.d.ts +24 -0
  35. package/dist/agent/aws/cli.d.ts.map +1 -0
  36. package/dist/agent/aws/cli.js +89 -0
  37. package/dist/agent/aws/cli.js.map +1 -0
  38. package/dist/agent/aws/config.d.ts +27 -0
  39. package/dist/agent/aws/config.d.ts.map +1 -0
  40. package/dist/agent/aws/config.js +46 -0
  41. package/dist/agent/aws/config.js.map +1 -0
  42. package/dist/agent/aws/register.d.ts +23 -0
  43. package/dist/agent/aws/register.d.ts.map +1 -0
  44. package/dist/agent/aws/register.js +39 -0
  45. package/dist/agent/aws/register.js.map +1 -0
  46. package/dist/agent/aws/sso.d.ts +109 -0
  47. package/dist/agent/aws/sso.d.ts.map +1 -0
  48. package/dist/agent/aws/sso.js +421 -0
  49. package/dist/agent/aws/sso.js.map +1 -0
  50. package/dist/agent/aws/sts.d.ts +27 -0
  51. package/dist/agent/aws/sts.d.ts.map +1 -0
  52. package/dist/agent/aws/sts.js +135 -0
  53. package/dist/agent/aws/sts.js.map +1 -0
  54. package/dist/agent/blob/hosting.d.ts +4 -0
  55. package/dist/agent/blob/hosting.d.ts.map +1 -0
  56. package/dist/agent/blob/hosting.js +20 -0
  57. package/dist/agent/blob/hosting.js.map +1 -0
  58. package/dist/agent/browser/config.d.ts +24 -0
  59. package/dist/agent/browser/config.d.ts.map +1 -0
  60. package/dist/agent/browser/config.js +50 -0
  61. package/dist/agent/browser/config.js.map +1 -0
  62. package/dist/agent/browser/register.d.ts +7 -0
  63. package/dist/agent/browser/register.d.ts.map +1 -0
  64. package/dist/agent/browser/register.js +47 -0
  65. package/dist/agent/browser/register.js.map +1 -0
  66. package/dist/agent/browser/sandbox.d.ts +23 -0
  67. package/dist/agent/browser/sandbox.d.ts.map +1 -0
  68. package/dist/agent/browser/sandbox.js +27 -0
  69. package/dist/agent/browser/sandbox.js.map +1 -0
  70. package/dist/agent/contributions.d.ts +16 -0
  71. package/dist/agent/contributions.d.ts.map +1 -0
  72. package/dist/agent/contributions.js +11 -0
  73. package/dist/agent/contributions.js.map +1 -0
  74. package/dist/agent/directory/config.d.ts +39 -0
  75. package/dist/agent/directory/config.d.ts.map +1 -0
  76. package/dist/agent/directory/config.js +101 -0
  77. package/dist/agent/directory/config.js.map +1 -0
  78. package/dist/agent/directory/okta.d.ts +19 -0
  79. package/dist/agent/directory/okta.d.ts.map +1 -0
  80. package/dist/agent/directory/okta.js +178 -0
  81. package/dist/agent/directory/okta.js.map +1 -0
  82. package/dist/agent/directory/register.d.ts +6 -0
  83. package/dist/agent/directory/register.d.ts.map +1 -0
  84. package/dist/agent/directory/register.js +16 -0
  85. package/dist/agent/directory/register.js.map +1 -0
  86. package/dist/agent/instrumentation.d.ts +5 -0
  87. package/dist/agent/instrumentation.d.ts.map +1 -0
  88. package/dist/agent/instrumentation.js +39 -0
  89. package/dist/agent/instrumentation.js.map +1 -0
  90. package/dist/agent/model/approval-judge.d.ts +15 -0
  91. package/dist/agent/model/approval-judge.d.ts.map +1 -0
  92. package/dist/agent/model/approval-judge.js +46 -0
  93. package/dist/agent/model/approval-judge.js.map +1 -0
  94. package/dist/agent/model/dream-judge.d.ts +40 -0
  95. package/dist/agent/model/dream-judge.d.ts.map +1 -0
  96. package/dist/agent/model/dream-judge.js +80 -0
  97. package/dist/agent/model/dream-judge.js.map +1 -0
  98. package/dist/agent/model/gateway-vision.d.ts +53 -0
  99. package/dist/agent/model/gateway-vision.d.ts.map +1 -0
  100. package/dist/agent/model/gateway-vision.js +129 -0
  101. package/dist/agent/model/gateway-vision.js.map +1 -0
  102. package/dist/agent/model/gateway.d.ts +30 -0
  103. package/dist/agent/model/gateway.d.ts.map +1 -0
  104. package/dist/agent/model/gateway.js +55 -0
  105. package/dist/agent/model/gateway.js.map +1 -0
  106. package/dist/agent/oe-oauth/config.d.ts +69 -0
  107. package/dist/agent/oe-oauth/config.d.ts.map +1 -0
  108. package/dist/agent/oe-oauth/config.js +182 -0
  109. package/dist/agent/oe-oauth/config.js.map +1 -0
  110. package/dist/agent/oe-oauth/errors.d.ts +63 -0
  111. package/dist/agent/oe-oauth/errors.d.ts.map +1 -0
  112. package/dist/agent/oe-oauth/errors.js +73 -0
  113. package/dist/agent/oe-oauth/errors.js.map +1 -0
  114. package/dist/agent/oe-oauth/oauth-client.d.ts +124 -0
  115. package/dist/agent/oe-oauth/oauth-client.d.ts.map +1 -0
  116. package/dist/agent/oe-oauth/oauth-client.js +262 -0
  117. package/dist/agent/oe-oauth/oauth-client.js.map +1 -0
  118. package/dist/agent/oe-oauth/pkce.d.ts +8 -0
  119. package/dist/agent/oe-oauth/pkce.d.ts.map +1 -0
  120. package/dist/agent/oe-oauth/pkce.js +18 -0
  121. package/dist/agent/oe-oauth/pkce.js.map +1 -0
  122. package/dist/agent/oe-oauth/register.d.ts +17 -0
  123. package/dist/agent/oe-oauth/register.d.ts.map +1 -0
  124. package/dist/agent/oe-oauth/register.js +24 -0
  125. package/dist/agent/oe-oauth/register.js.map +1 -0
  126. package/dist/agent/oe-oauth/token-vault.d.ts +107 -0
  127. package/dist/agent/oe-oauth/token-vault.d.ts.map +1 -0
  128. package/dist/agent/oe-oauth/token-vault.js +498 -0
  129. package/dist/agent/oe-oauth/token-vault.js.map +1 -0
  130. package/dist/agent/oe-oauth/user-auth-flow.d.ts +10 -0
  131. package/dist/agent/oe-oauth/user-auth-flow.d.ts.map +1 -0
  132. package/dist/agent/oe-oauth/user-auth-flow.js +66 -0
  133. package/dist/agent/oe-oauth/user-auth-flow.js.map +1 -0
  134. package/dist/agent/postgres/neon.d.ts +29 -0
  135. package/dist/agent/postgres/neon.d.ts.map +1 -0
  136. package/dist/agent/postgres/neon.js +76 -0
  137. package/dist/agent/postgres/neon.js.map +1 -0
  138. package/dist/agent/sandbox/backend-stop.d.ts +98 -0
  139. package/dist/agent/sandbox/backend-stop.d.ts.map +1 -0
  140. package/dist/agent/sandbox/backend-stop.js +188 -0
  141. package/dist/agent/sandbox/backend-stop.js.map +1 -0
  142. package/dist/agent/sandbox/created-sandbox-registry.d.ts +15 -0
  143. package/dist/agent/sandbox/created-sandbox-registry.d.ts.map +1 -0
  144. package/dist/agent/sandbox/created-sandbox-registry.js +26 -0
  145. package/dist/agent/sandbox/created-sandbox-registry.js.map +1 -0
  146. package/dist/agent/sandbox/extend-workspace-time.d.ts +31 -0
  147. package/dist/agent/sandbox/extend-workspace-time.d.ts.map +1 -0
  148. package/dist/agent/sandbox/extend-workspace-time.js +63 -0
  149. package/dist/agent/sandbox/extend-workspace-time.js.map +1 -0
  150. package/dist/agent/sandbox/vercel-lifecycle.d.ts +38 -0
  151. package/dist/agent/sandbox/vercel-lifecycle.d.ts.map +1 -0
  152. package/dist/agent/sandbox/vercel-lifecycle.js +244 -0
  153. package/dist/agent/sandbox/vercel-lifecycle.js.map +1 -0
  154. package/package.json +204 -0
  155. package/tsconfig.build.json +22 -0
  156. package/tsconfig.json +22 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your Exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Tommy Long
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,21 @@
1
+ Open Everywhere
2
+ Copyright 2026 Tommy Long
3
+
4
+ This product is licensed under the Apache License, Version 2.0 (see LICENSE).
5
+
6
+ ---
7
+
8
+ Built on Vercel Eve (https://github.com/vercel/eve), licensed under the
9
+ Apache License, Version 2.0.
10
+
11
+ @open-everywhere/core also ships a patch that modifies Vercel Eve (the file in
12
+ its patches/ directory), with the oe-eve-patch command that applies it to a
13
+ consumer's own installed copy. The patch is licensed under the Apache License,
14
+ Version 2.0. No modified Vercel Eve files are distributed.
15
+
16
+ ---
17
+
18
+ Open Everywhere is an independent, open-source project. It is NOT affiliated
19
+ with, endorsed by, or sponsored by Anthropic. "Claude", "Claude Code", and
20
+ "Claude Tag" are referenced only to describe the prior art Open Everywhere is
21
+ inspired by, and are trademarks of their respective owner.
package/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # @open-everywhere/adapters
2
+
3
+ The reference Vercel-hosted backends for Open Everywhere.
4
+
5
+ Part of [Open Everywhere](https://github.com/open-everywhere/open-everywhere) — an open, self-hostable autonomous teammate you tag where your
6
+ team works. This package supplies the hosted backends the reference deployment runs on.
7
+
8
+ It implements core's host seams against concrete services:
9
+
10
+ - **AI Gateway** — model routing and the pricing the spend reports read
11
+ - **Sandbox** — the isolated workspace a turn runs its commands in
12
+ - **Blob** — file storage
13
+ - **Neon** — Postgres for the operational and memory stores
14
+ - **OpenTelemetry** — the traces and the telemetry export
15
+ - **AWS** and **Okta** — the directory and credential integrations
16
+
17
+ Core defines these seams and ships no host of its own, so a different host is a different adapters
18
+ package rather than a fork of the runtime.
19
+
20
+ ## Install
21
+
22
+ ```sh
23
+ npm i @open-everywhere/core @open-everywhere/adapters eve@0.54.3
24
+ npx oe-eve-patch
25
+ ```
26
+
27
+ **Both commands are required.** Core refuses to boot on an unpatched `eve`. A registry `eve` carries
28
+ no patch, so `npx oe-eve-patch` applies the copy `@open-everywhere/core` ships.
29
+
30
+ `eve` and `@agent-browser/eve` are peer dependencies, pinned to exact versions. The `eve` version
31
+ above is the pin `@open-everywhere/core` declares as `peerDependencies.eve`.
32
+
33
+ `npx oe-eve-patch` applies the `eve` patch only. `@agent-browser/eve` installs unpatched, and
34
+ `@open-everywhere/core` packs no patch for it. Node 24 or newer.
35
+
36
+ ## Docs
37
+
38
+ - [Hosting overview](https://github.com/open-everywhere/open-everywhere/blob/main/docs/deploy/hosting-overview.md)
39
+ - [Documentation index](https://github.com/open-everywhere/open-everywhere/blob/main/docs/README.md)
40
+
41
+ ## Licence
42
+
43
+ Apache 2.0. The tarball carries `LICENSE` and `NOTICE`.
@@ -0,0 +1,121 @@
1
+ // The AWS-EXECUTOR adapter — the ONE place the `aws` binary is spawned. Credentials go in the child ENV,
2
+ // never on argv, and that env is DENY-BY-DEFAULT. A non-zero exit returns; only a launch failure throws.
3
+
4
+ import { execFile } from "node:child_process";
5
+ import type { AwsCredentials, AwsExecRequest, AwsExecResult, AwsExecutor } from "@open-everywhere/core/agent/adapter-api.js";
6
+
7
+ export interface AwsExecInvocation {
8
+ /** The binary to launch (default "aws"). */
9
+ readonly file: string;
10
+ /** Argv AFTER the binary (creds are NEVER here). */
11
+ readonly args: readonly string[];
12
+ /** The child's full environment, with creds + region injected and ambient AWS identity stripped. */
13
+ readonly env: NodeJS.ProcessEnv;
14
+ }
15
+
16
+ /** A runner resolves with the captured outcome (ANY exit code) and REJECTS only on a launch failure —
17
+ * the DI seam the offline test injects to assert env/argv without running `aws`. */
18
+ export type AwsRunner = (inv: AwsExecInvocation) => Promise<AwsExecResult>;
19
+
20
+ /** Construction options — DI seams for the offline test; each has a real default. */
21
+ export interface AwsCliExecutorOptions {
22
+ /** The invocation runner. Default: a `node:child_process.execFile` wrapper. */
23
+ readonly run?: AwsRunner;
24
+ /** The AWS CLI binary name/path. Default "aws". */
25
+ readonly binary?: string;
26
+ /** Operator default region (OE_AWS_REGION) applied when the resolved identity names none, so the
27
+ * CLI runs in the same region STS minted for. */
28
+ readonly defaultRegion?: string;
29
+ }
30
+
31
+ /** Default runner — `execFile` the CLI, capturing stdout/stderr/exit. Resolves for every exit code
32
+ * (non-zero included); rejects ONLY when the process could not be launched (ENOENT etc.). */
33
+ const defaultRunner: AwsRunner = (inv) =>
34
+ new Promise<AwsExecResult>((resolve, reject) => {
35
+ execFile(inv.file, [...inv.args], { env: inv.env, maxBuffer: 64 * 1024 * 1024 }, (err, stdout, stderr) => {
36
+ if (err) {
37
+ const code = (err as NodeJS.ErrnoException & { code?: unknown }).code;
38
+ // execFile sets a NUMBER `code` for a non-zero exit, a STRING errno (e.g. "ENOENT") for a
39
+ // launch failure. Return the former; reject the latter.
40
+ if (typeof code === "number") {
41
+ resolve({ exitCode: code, stdout: String(stdout), stderr: String(stderr) });
42
+ return;
43
+ }
44
+ reject(err);
45
+ return;
46
+ }
47
+ resolve({ exitCode: 0, stdout: String(stdout), stderr: String(stderr) });
48
+ });
49
+ });
50
+
51
+ /**
52
+ * The ONLY parent-env keys the child inherits — deny-by-default. The framework process's environment holds
53
+ * the deployment's real secrets, and this child's argv is model-controlled.
54
+ */
55
+ const CHILD_ENV_PASSTHROUGH = [
56
+ "PATH",
57
+ "HOME",
58
+ "TMPDIR",
59
+ "TMP",
60
+ "TEMP",
61
+ "LANG",
62
+ "TZ",
63
+ "HTTPS_PROXY",
64
+ "HTTP_PROXY",
65
+ "NO_PROXY",
66
+ "https_proxy",
67
+ "http_proxy",
68
+ "no_proxy",
69
+ ] as const;
70
+
71
+ /** Build the child env DENY-BY-DEFAULT: the enumerated pass-through + LC_* locale keys, the
72
+ * injected temp creds + region, config/credential files pinned to /dev/null, IMDS disabled —
73
+ * so the injected creds are the ONLY identity the CLI can resolve, from any source. */
74
+ function childEnv(credentials: AwsCredentials, region: string | undefined): NodeJS.ProcessEnv {
75
+ const env: NodeJS.ProcessEnv = {};
76
+ for (const k of CHILD_ENV_PASSTHROUGH) {
77
+ if (process.env[k] !== undefined) env[k] = process.env[k];
78
+ }
79
+ for (const k of Object.keys(process.env)) {
80
+ if (k.startsWith("LC_")) env[k] = process.env[k];
81
+ }
82
+ // No on-host profile/credential/config file is ever readable, whatever the box carries.
83
+ env.AWS_CONFIG_FILE = "/dev/null";
84
+ env.AWS_SHARED_CREDENTIALS_FILE = "/dev/null";
85
+ // No instance-metadata fallback: a cloud host's IMDS role must never answer for the CLI.
86
+ env.AWS_EC2_METADATA_DISABLED = "true";
87
+ env.AWS_ACCESS_KEY_ID = credentials.accessKeyId;
88
+ env.AWS_SECRET_ACCESS_KEY = credentials.secretAccessKey;
89
+ env.AWS_SESSION_TOKEN = credentials.sessionToken;
90
+ if (region) {
91
+ env.AWS_REGION = region;
92
+ env.AWS_DEFAULT_REGION = region;
93
+ }
94
+ return env;
95
+ }
96
+
97
+ export function makeAwsCliExecutor(opts: AwsCliExecutorOptions = {}): AwsExecutor {
98
+ const runner = opts.run ?? defaultRunner;
99
+ const binary = opts.binary ?? "aws";
100
+ const defaultRegion = opts.defaultRegion;
101
+
102
+ return {
103
+ async run(req: AwsExecRequest): Promise<AwsExecResult> {
104
+ const inv: AwsExecInvocation = {
105
+ file: binary,
106
+ args: req.args,
107
+ env: childEnv(req.credentials, req.region ?? defaultRegion),
108
+ };
109
+ try {
110
+ return await runner(inv);
111
+ } catch (err) {
112
+ // A rejection here means the process never launched (the runner returns non-zero exits).
113
+ throw new Error(
114
+ `failed to launch the AWS CLI ("${binary}") — is it installed and on PATH? ${
115
+ err instanceof Error ? err.message : String(err)
116
+ }`,
117
+ );
118
+ }
119
+ },
120
+ };
121
+ }
@@ -0,0 +1,71 @@
1
+ // The `aws` access master arming flag and config block. Flag-off ⇒ NOTHING registers and core's AWS paths
2
+ // fail closed, with no fallback. Config is env-sourced at the adapter boundary, like DATABASE_URL.
3
+
4
+ /** The master arming flag env var — one string this module's readers share. */
5
+ const OE_AWS_ENABLED_ENV = "OE_AWS_ENABLED";
6
+ /** Optional default region for STS + the CLI when a grant names none. */
7
+ const OE_AWS_REGION_ENV = "OE_AWS_REGION";
8
+
9
+ // The per-user Identity Center link config. These vars configure the LINK flow only — a mint needs the
10
+ // region and the stored token. NO secrets here: the OIDC client is a PUBLIC PKCE client.
11
+
12
+ /** The Identity Center region (where oidc.<region>.amazonaws.com + portal.sso.<region>.amazonaws.com
13
+ * live). Falls back to the general default region ({@link OE_AWS_REGION_ENV} / AWS_REGION). */
14
+ const OE_AWS_SSO_REGION_ENV = "OE_AWS_SSO_REGION";
15
+ /** The pre-registered PUBLIC OIDC client id for the Identity Center auth-code + PKCE link flow. */
16
+ const OE_AWS_SSO_CLIENT_ID_ENV = "OE_AWS_SSO_CLIENT_ID";
17
+ /** Optional space-separated OAuth scopes for the link (default "sso:account:access"). */
18
+ const OE_AWS_SSO_SCOPES_ENV = "OE_AWS_SSO_SCOPES";
19
+
20
+ /** Truthiness for the master flag — same off-spellings as the other connector-plane flags (default
21
+ * OFF: off is the inert posture; arming is a deliberate operator act). */
22
+ export function awsAccessEnabled(): boolean {
23
+ const raw = process.env[OE_AWS_ENABLED_ENV];
24
+ if (raw === undefined) return false;
25
+ const v = raw.trim().toLowerCase();
26
+ return v !== "" && v !== "0" && v !== "false" && v !== "off" && v !== "no";
27
+ }
28
+
29
+ /** The AWS-access config block (env-sourced). Only a default region today; the identity/executor DI
30
+ * seams are passed by the caller (register.ts), not env. */
31
+ export interface AwsAccessConfig {
32
+ /** Default region applied when a role grant names none. STS itself further falls back to
33
+ * `AWS_REGION` then `us-east-1` (sts.ts), so this is purely the operator's override. */
34
+ readonly defaultRegion?: string;
35
+ }
36
+
37
+ /** Load the AWS-access config block from env. Always returns a (possibly empty) config — unlike the
38
+ * oe-oauth block there is no REQUIRED field, so the master flag alone gates arming. */
39
+ export function loadAwsAccessConfig(): AwsAccessConfig {
40
+ const defaultRegion = process.env[OE_AWS_REGION_ENV]?.trim() || process.env.AWS_REGION?.trim();
41
+ return { ...(defaultRegion ? { defaultRegion } : {}) };
42
+ }
43
+
44
+ /** The Identity Center (SSO) link config block (env-sourced). Every field is optional here — the
45
+ * minter fails closed with an actionable message at LINK time if a piece the link flow needs (region,
46
+ * client id) is missing, so arming the master flag never requires SSO to be configured. */
47
+ export interface AwsSsoConfig {
48
+ /** Identity Center region for the OIDC + portal endpoints. Undefined ⇒ fall back to the default. */
49
+ readonly region?: string;
50
+ /** The public PKCE OIDC client id for the link flow. Undefined ⇒ the link flow fails closed loudly. */
51
+ readonly clientId?: string;
52
+ /** OAuth scopes requested on the link (default applied by the minter). */
53
+ readonly scopes?: readonly string[];
54
+ }
55
+
56
+ /** Load the Identity Center SSO link config from env. Region falls back to the general AWS default. */
57
+ export function loadAwsSsoConfig(): AwsSsoConfig {
58
+ const region =
59
+ process.env[OE_AWS_SSO_REGION_ENV]?.trim() ||
60
+ process.env[OE_AWS_REGION_ENV]?.trim() ||
61
+ process.env.AWS_REGION?.trim();
62
+ const clientId = process.env[OE_AWS_SSO_CLIENT_ID_ENV]?.trim();
63
+ const scopes = process.env[OE_AWS_SSO_SCOPES_ENV]?.trim()
64
+ ? process.env[OE_AWS_SSO_SCOPES_ENV]!.trim().split(/\s+/u).filter(Boolean)
65
+ : undefined;
66
+ return {
67
+ ...(region ? { region } : {}),
68
+ ...(clientId ? { clientId } : {}),
69
+ ...(scopes && scopes.length ? { scopes } : {}),
70
+ };
71
+ }
@@ -0,0 +1,65 @@
1
+ // Register the AWS-access layer, called only when the OE_AWS_ENABLED master flag is armed. Flag-off ⇒
2
+ // nothing registers and core's AWS mint, exec and link paths fail closed; rollback is not arming the flag.
3
+
4
+ import {
5
+ registerAwsIdentityProvider,
6
+ registerAwsExecutor,
7
+ registerAwsSsoLinkStore,
8
+ registerAwsSsoCallbackCompleter,
9
+ registerCredentialPurgeHook,
10
+ type AwsIdentityProvider,
11
+ type AwsExecutor,
12
+ } from "@open-everywhere/core/agent/adapter-api.js";
13
+ import { makeAwsStsProvider, type AwsStsProviderOptions } from "./sts.js";
14
+ import { makeAwsCliExecutor, type AwsCliExecutorOptions } from "./cli.js";
15
+ import { makeAwsSsoMinter, makeAwsSsoLinkStore, makeAwsSsoPurgeHook, type AwsSsoMinter, type AwsSsoMinterOptions } from "./sso.js";
16
+ import { loadAwsAccessConfig, loadAwsSsoConfig } from "./config.js";
17
+
18
+ /** Registration input — the DI seams for tests (the boot call passes none). */
19
+ export interface RegisterAwsAccessOptions {
20
+ /** STS identity-provider seams (injectable fetch + token-file reader). */
21
+ readonly identity?: AwsStsProviderOptions;
22
+ /** CLI executor seams (injectable runner + binary). */
23
+ readonly executor?: AwsCliExecutorOptions;
24
+ /** Identity Center (SSO) minter seams (injectable fetch + stores + config). */
25
+ readonly sso?: AwsSsoMinterOptions;
26
+ }
27
+
28
+ /**
29
+ * Construct the STS provider (with its delegated SSO minter), the `aws` CLI executor and the per-principal
30
+ * link store, and register all three for core lookup. Idempotent overwrite in the registries — last wins.
31
+ */
32
+ export function registerAwsAccess(opts: RegisterAwsAccessOptions = {}): {
33
+ provider: AwsIdentityProvider;
34
+ executor: AwsExecutor;
35
+ sso: AwsSsoMinter;
36
+ } {
37
+ // The operator's default region (OE_AWS_REGION / AWS_REGION) — applied when a role grant names none,
38
+ // consistently to both the STS mint and the CLI. Explicit test seams (opts.*) win over it.
39
+ const { defaultRegion } = loadAwsAccessConfig();
40
+ const ssoCfg = loadAwsSsoConfig();
41
+
42
+ // Phase 1: the per-principal Identity Center link store (vault-backed) + the SSO minter. Register the
43
+ // store on core's port FIRST so the minter's requireAwsSsoLinkStore() resolves it.
44
+ registerAwsSsoLinkStore(makeAwsSsoLinkStore());
45
+ // The purge hook registers ALONGSIDE the link store: a deployment that can mint per-person AWS credentials
46
+ // and cannot destroy them on offboarding is the state this closed. Registration is KEYED, so this ADDS.
47
+ registerCredentialPurgeHook("aws-sso", makeAwsSsoPurgeHook());
48
+ const sso = makeAwsSsoMinter({
49
+ ...(ssoCfg.region ? { region: ssoCfg.region } : defaultRegion ? { region: defaultRegion } : {}),
50
+ ...(ssoCfg.clientId ? { clientId: ssoCfg.clientId } : {}),
51
+ ...(ssoCfg.scopes ? { scopes: ssoCfg.scopes } : {}),
52
+ ...opts.sso,
53
+ });
54
+
55
+ // Wire the `GET OE_AWS_SSO_CALLBACK_PATH` route to the SSO minter's code→token exchange, mirroring the
56
+ // own-rolled OAuth adapter's registerOeOauthCallbackCompleter. Fires under the OE_AWS_ENABLED boot
57
+ // guard; flag-off ⇒ the completer is never registered and the route fails closed (generic error page).
58
+ registerAwsSsoCallbackCompleter({ complete: ({ state, code }) => sso.completeLink(state, code) });
59
+
60
+ const provider = makeAwsStsProvider({ defaultRegion, mintUserSso: (req) => sso.mint(req), ...opts.identity });
61
+ const executor = makeAwsCliExecutor({ defaultRegion, ...opts.executor });
62
+ registerAwsIdentityProvider(provider);
63
+ registerAwsExecutor(executor);
64
+ return { provider, executor, sso };
65
+ }