@mongodb-js/agent-engine-runner-shared 0.11.3

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 (220) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/LICENSE.md +201 -0
  3. package/README.md +29 -0
  4. package/dist/agent_config.d.ts +167 -0
  5. package/dist/agent_config.d.ts.map +1 -0
  6. package/dist/agent_config.js +544 -0
  7. package/dist/call_interrupted.d.ts +12 -0
  8. package/dist/call_interrupted.d.ts.map +1 -0
  9. package/dist/call_interrupted.js +11 -0
  10. package/dist/checkpoint_workspace.d.ts +25 -0
  11. package/dist/checkpoint_workspace.d.ts.map +1 -0
  12. package/dist/checkpoint_workspace.js +44 -0
  13. package/dist/context.d.ts +235 -0
  14. package/dist/context.d.ts.map +1 -0
  15. package/dist/context.js +322 -0
  16. package/dist/db_config.d.ts +28 -0
  17. package/dist/db_config.d.ts.map +1 -0
  18. package/dist/db_config.js +66 -0
  19. package/dist/db_naming.d.ts +54 -0
  20. package/dist/db_naming.d.ts.map +1 -0
  21. package/dist/db_naming.js +94 -0
  22. package/dist/error_reporting.d.ts +67 -0
  23. package/dist/error_reporting.d.ts.map +1 -0
  24. package/dist/error_reporting.js +311 -0
  25. package/dist/generated/workflow/v1/activity_pb.d.ts +342 -0
  26. package/dist/generated/workflow/v1/activity_pb.d.ts.map +1 -0
  27. package/dist/generated/workflow/v1/activity_pb.js +115 -0
  28. package/dist/generated/workflow/v1/common_pb.d.ts +184 -0
  29. package/dist/generated/workflow/v1/common_pb.d.ts.map +1 -0
  30. package/dist/generated/workflow/v1/common_pb.js +86 -0
  31. package/dist/generated/workflow/v1/runtime_pb.d.ts +200 -0
  32. package/dist/generated/workflow/v1/runtime_pb.d.ts.map +1 -0
  33. package/dist/generated/workflow/v1/runtime_pb.js +40 -0
  34. package/dist/generated/workflow/v1/state_pb.d.ts +254 -0
  35. package/dist/generated/workflow/v1/state_pb.d.ts.map +1 -0
  36. package/dist/generated/workflow/v1/state_pb.js +68 -0
  37. package/dist/guardrails_evaluator/core.d.ts +23 -0
  38. package/dist/guardrails_evaluator/core.d.ts.map +1 -0
  39. package/dist/guardrails_evaluator/core.js +122 -0
  40. package/dist/guardrails_evaluator/index.d.ts +10 -0
  41. package/dist/guardrails_evaluator/index.d.ts.map +1 -0
  42. package/dist/guardrails_evaluator/index.js +11 -0
  43. package/dist/guardrails_evaluator/regex.d.ts +20 -0
  44. package/dist/guardrails_evaluator/regex.d.ts.map +1 -0
  45. package/dist/guardrails_evaluator/regex.js +233 -0
  46. package/dist/hooks.d.ts +109 -0
  47. package/dist/hooks.d.ts.map +1 -0
  48. package/dist/hooks.js +216 -0
  49. package/dist/http_path.d.ts +18 -0
  50. package/dist/http_path.d.ts.map +1 -0
  51. package/dist/http_path.js +53 -0
  52. package/dist/index.d.ts +35 -0
  53. package/dist/index.d.ts.map +1 -0
  54. package/dist/index.js +41 -0
  55. package/dist/launcher.d.ts +130 -0
  56. package/dist/launcher.d.ts.map +1 -0
  57. package/dist/launcher.js +325 -0
  58. package/dist/logger.d.ts +96 -0
  59. package/dist/logger.d.ts.map +1 -0
  60. package/dist/logger.js +204 -0
  61. package/dist/mcp_oauth.d.ts +51 -0
  62. package/dist/mcp_oauth.d.ts.map +1 -0
  63. package/dist/mcp_oauth.js +389 -0
  64. package/dist/mcp_oauth_secret.d.ts +21 -0
  65. package/dist/mcp_oauth_secret.d.ts.map +1 -0
  66. package/dist/mcp_oauth_secret.js +122 -0
  67. package/dist/mcp_tools.d.ts +71 -0
  68. package/dist/mcp_tools.d.ts.map +1 -0
  69. package/dist/mcp_tools.js +301 -0
  70. package/dist/memory_appbound.d.ts +42 -0
  71. package/dist/memory_appbound.d.ts.map +1 -0
  72. package/dist/memory_appbound.js +159 -0
  73. package/dist/memory_writer.d.ts +49 -0
  74. package/dist/memory_writer.d.ts.map +1 -0
  75. package/dist/memory_writer.js +171 -0
  76. package/dist/metrics.d.ts +84 -0
  77. package/dist/metrics.d.ts.map +1 -0
  78. package/dist/metrics.js +205 -0
  79. package/dist/models.d.ts +1458 -0
  80. package/dist/models.d.ts.map +1 -0
  81. package/dist/models.js +1726 -0
  82. package/dist/node_logger.d.ts +43 -0
  83. package/dist/node_logger.d.ts.map +1 -0
  84. package/dist/node_logger.js +158 -0
  85. package/dist/owner_callback.d.ts +16 -0
  86. package/dist/owner_callback.d.ts.map +1 -0
  87. package/dist/owner_callback.js +40 -0
  88. package/dist/progress.d.ts +57 -0
  89. package/dist/progress.d.ts.map +1 -0
  90. package/dist/progress.js +140 -0
  91. package/dist/runtime.d.ts +131 -0
  92. package/dist/runtime.d.ts.map +1 -0
  93. package/dist/runtime.js +351 -0
  94. package/dist/secure_llm_proxy.d.ts +115 -0
  95. package/dist/secure_llm_proxy.d.ts.map +1 -0
  96. package/dist/secure_llm_proxy.js +922 -0
  97. package/dist/secure_wrapper.d.ts +332 -0
  98. package/dist/secure_wrapper.d.ts.map +1 -0
  99. package/dist/secure_wrapper.js +1249 -0
  100. package/dist/server/aer.d.ts +61 -0
  101. package/dist/server/aer.d.ts.map +1 -0
  102. package/dist/server/aer.js +1124 -0
  103. package/dist/server/auth.d.ts +56 -0
  104. package/dist/server/auth.d.ts.map +1 -0
  105. package/dist/server/auth.js +132 -0
  106. package/dist/server/base.d.ts +104 -0
  107. package/dist/server/base.d.ts.map +1 -0
  108. package/dist/server/base.js +150 -0
  109. package/dist/server/callInterrupt.d.ts +49 -0
  110. package/dist/server/callInterrupt.d.ts.map +1 -0
  111. package/dist/server/callInterrupt.js +68 -0
  112. package/dist/server/callback_delivery.d.ts +14 -0
  113. package/dist/server/callback_delivery.d.ts.map +1 -0
  114. package/dist/server/callback_delivery.js +141 -0
  115. package/dist/server/chunk_types.d.ts +50 -0
  116. package/dist/server/chunk_types.d.ts.map +1 -0
  117. package/dist/server/chunk_types.js +62 -0
  118. package/dist/server/cors.d.ts +52 -0
  119. package/dist/server/cors.d.ts.map +1 -0
  120. package/dist/server/cors.js +107 -0
  121. package/dist/server/drain.d.ts +169 -0
  122. package/dist/server/drain.d.ts.map +1 -0
  123. package/dist/server/drain.js +455 -0
  124. package/dist/server/function.d.ts +77 -0
  125. package/dist/server/function.d.ts.map +1 -0
  126. package/dist/server/function.js +337 -0
  127. package/dist/server/http_retry.d.ts +37 -0
  128. package/dist/server/http_retry.d.ts.map +1 -0
  129. package/dist/server/http_retry.js +157 -0
  130. package/dist/server/index.d.ts +7 -0
  131. package/dist/server/index.d.ts.map +1 -0
  132. package/dist/server/index.js +5 -0
  133. package/dist/server/metadata.d.ts +50 -0
  134. package/dist/server/metadata.d.ts.map +1 -0
  135. package/dist/server/metadata.js +193 -0
  136. package/dist/server/oe_url.d.ts +36 -0
  137. package/dist/server/oe_url.d.ts.map +1 -0
  138. package/dist/server/oe_url.js +50 -0
  139. package/dist/server/owner_url.d.ts +35 -0
  140. package/dist/server/owner_url.d.ts.map +1 -0
  141. package/dist/server/owner_url.js +146 -0
  142. package/dist/server/query.d.ts +42 -0
  143. package/dist/server/query.d.ts.map +1 -0
  144. package/dist/server/query.js +28 -0
  145. package/dist/server/tool.d.ts +138 -0
  146. package/dist/server/tool.d.ts.map +1 -0
  147. package/dist/server/tool.js +1017 -0
  148. package/dist/span_names.d.ts +21 -0
  149. package/dist/span_names.d.ts.map +1 -0
  150. package/dist/span_names.js +31 -0
  151. package/dist/structured_logging/constants.d.ts +17 -0
  152. package/dist/structured_logging/constants.d.ts.map +1 -0
  153. package/dist/structured_logging/constants.js +71 -0
  154. package/dist/structured_logging/env.d.ts +18 -0
  155. package/dist/structured_logging/env.d.ts.map +1 -0
  156. package/dist/structured_logging/env.js +39 -0
  157. package/dist/structured_logging/install.d.ts +56 -0
  158. package/dist/structured_logging/install.d.ts.map +1 -0
  159. package/dist/structured_logging/install.js +107 -0
  160. package/dist/structured_logging/layout.d.ts +9 -0
  161. package/dist/structured_logging/layout.d.ts.map +1 -0
  162. package/dist/structured_logging/layout.js +144 -0
  163. package/dist/structured_logging/serialize.d.ts +27 -0
  164. package/dist/structured_logging/serialize.d.ts.map +1 -0
  165. package/dist/structured_logging/serialize.js +61 -0
  166. package/dist/structured_logging/stdio_capture.d.ts +59 -0
  167. package/dist/structured_logging/stdio_capture.d.ts.map +1 -0
  168. package/dist/structured_logging/stdio_capture.js +164 -0
  169. package/dist/structured_logging/uncaught.d.ts +14 -0
  170. package/dist/structured_logging/uncaught.d.ts.map +1 -0
  171. package/dist/structured_logging/uncaught.js +58 -0
  172. package/dist/structured_logging.d.ts +48 -0
  173. package/dist/structured_logging.d.ts.map +1 -0
  174. package/dist/structured_logging.js +47 -0
  175. package/dist/tls_client.d.ts +61 -0
  176. package/dist/tls_client.d.ts.map +1 -0
  177. package/dist/tls_client.js +298 -0
  178. package/dist/tool_api_error.d.ts +62 -0
  179. package/dist/tool_api_error.d.ts.map +1 -0
  180. package/dist/tool_api_error.js +399 -0
  181. package/dist/tool_memory_ownership.d.ts +10 -0
  182. package/dist/tool_memory_ownership.d.ts.map +1 -0
  183. package/dist/tool_memory_ownership.js +36 -0
  184. package/dist/toolpod_handlers.d.ts +126 -0
  185. package/dist/toolpod_handlers.d.ts.map +1 -0
  186. package/dist/toolpod_handlers.js +1016 -0
  187. package/dist/tracing/exporters.d.ts +51 -0
  188. package/dist/tracing/exporters.d.ts.map +1 -0
  189. package/dist/tracing/exporters.js +327 -0
  190. package/dist/tracing/index.d.ts +3 -0
  191. package/dist/tracing/index.d.ts.map +1 -0
  192. package/dist/tracing/index.js +2 -0
  193. package/dist/tracing/setup.d.ts +76 -0
  194. package/dist/tracing/setup.d.ts.map +1 -0
  195. package/dist/tracing/setup.js +436 -0
  196. package/dist/utils.d.ts +204 -0
  197. package/dist/utils.d.ts.map +1 -0
  198. package/dist/utils.js +867 -0
  199. package/dist/workflow/activity.d.ts +71 -0
  200. package/dist/workflow/activity.d.ts.map +1 -0
  201. package/dist/workflow/activity.js +357 -0
  202. package/dist/workflow/attempt.d.ts +12 -0
  203. package/dist/workflow/attempt.d.ts.map +1 -0
  204. package/dist/workflow/attempt.js +96 -0
  205. package/dist/workflow/client.d.ts +46 -0
  206. package/dist/workflow/client.d.ts.map +1 -0
  207. package/dist/workflow/client.js +299 -0
  208. package/dist/workflow/context.d.ts +37 -0
  209. package/dist/workflow/context.d.ts.map +1 -0
  210. package/dist/workflow/context.js +350 -0
  211. package/dist/workflow/heartbeat.d.ts +15 -0
  212. package/dist/workflow/heartbeat.d.ts.map +1 -0
  213. package/dist/workflow/heartbeat.js +78 -0
  214. package/dist/workflow/index.d.ts +14 -0
  215. package/dist/workflow/index.d.ts.map +1 -0
  216. package/dist/workflow/index.js +10 -0
  217. package/dist/workflow/memory.d.ts +17 -0
  218. package/dist/workflow/memory.d.ts.map +1 -0
  219. package/dist/workflow/memory.js +184 -0
  220. package/package.json +73 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,55 @@
1
+ # Changelog
2
+
3
+ All notable changes to this package will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ### Changed
11
+ - Workflow child operation paths gained the Python parity surface for framework
12
+ adapters that dispatch dynamic children outside the graph topology:
13
+ `preallocateChildOperationOrdinals` assigns ordinals to a complete same-step
14
+ sibling batch up front, and `childOperationBoundaryScope` runs a callback with
15
+ one appended child boundary (composing with any active operation-path
16
+ resolver). A pending-batch holder on the attempt context backs the
17
+ adapter's two-phase model-step/tool-step stamping.
18
+
19
+ ### Fixed
20
+ - Uncaught exceptions and unhandled rejections in agent code now emit a
21
+ filterable `level=ERROR` record. Ordinary stderr writes with no
22
+ associated exception stay `WARNING`. The record is written even when the agent
23
+ installed its own crash handler first, and recovering from a crash no longer
24
+ makes a later graceful shutdown report failure.
25
+ - **Log shape change:** for uncaught exceptions the stack now arrives on the
26
+ ERROR record's `fields.exc_traceback` plus Node's raw output, instead of
27
+ per-line `WARNING` records. Unhandled rejections are unchanged.
28
+ - An unset or unrecognized `RUNNER_MODE` no longer drops the crash record from
29
+ `/agent-logs`; it falls back to `aer`.
30
+ - Launcher installs logging before importing `AGENT_ENTRYPOINT` and emits
31
+ `ERROR` (with traceback metadata) for import and entrypoint failures, so
32
+ workspace logs no longer show those crashes as `INFO`.
33
+
34
+ ### Changed
35
+ - **Behavioral change (fail closed):** Managed runtimes that require project-
36
+ scoped storage now require `APP_ID` when resolving checkpoint workspace
37
+ scope. A missing `APP_ID` throws instead of trusting the wire workspace or
38
+ using a bare session key. Intentionally unscoped local runtimes retain the
39
+ wire fallback and bare-key behavior.
40
+ - **Behavioral change (fail closed):** `withMetadataEnv` and `withMetadataEnvGen`
41
+ (`src/server/metadata.ts`) now throw — before touching `process.env` — when a
42
+ region overlaps a concurrent secret-bearing region: either another region
43
+ already has secrets applied, or this region carries secrets while any region
44
+ is active. Previously overlap was silent and could swap one request's secrets
45
+ into another's. In-repo call sites (`/execute`,
46
+ `/invoke_llm`, `/invoke_llm/stream`) are serialized by the ToolServer's
47
+ per-instance execute gate and are unaffected; a downstream consumer calling
48
+ these directly, or a second in-process call site, must be prepared to handle
49
+ the error per request. Note `withMetadataEnvGen` holds its region open for
50
+ the whole iteration.
51
+ - A region entered while another region is active now performs a *delete-only*
52
+ restore: keys it added are removed, but overwritten values are no longer
53
+ reverted, since its snapshot is tainted with the other region's
54
+ request-scoped state. Regions entered on a quiet environment (the serialized
55
+ production flow) keep the full snapshot restore.
package/LICENSE.md 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 MongoDB, Inc.
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/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # @mongodb-js/agent-engine-runner-shared
2
+
3
+ [![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE.md)
4
+
5
+ The TypeScript runner runtime for Atlas Agent Engine. It provides the platform
6
+ protocol, secure tool and LLM wrappers, request-scoped runtime context, and
7
+ server adapters used by the TypeScript LangGraph SDK.
8
+
9
+ This package is an open-source runtime integration library. Running an agent
10
+ through the managed service requires Atlas Agent Engine services such as the
11
+ Orchestration Engine and Agent Execution Runtime; those services are not
12
+ distributed with this package.
13
+ > This is an internal core package; agents don't install it directly. Install a
14
+ > framework SDK (`@mongodb-js/agent-engine-sdk-langgraph`), which depends on it.
15
+
16
+ ## Development
17
+
18
+ Run commands from the TypeScript workspace root:
19
+
20
+ ```bash
21
+ npm ci
22
+ npm run build --workspace=@mongodb-js/agent-engine-runner-shared
23
+ npm run test --workspace=@mongodb-js/agent-engine-runner-shared
24
+ ```
25
+
26
+ See the workspace [open-source distribution notes](../../OPEN_SOURCE.md) for
27
+ the package boundary and dependency policy.
28
+
29
+ Copyright 2026 MongoDB, Inc. Licensed under the Apache License, Version 2.0.
@@ -0,0 +1,167 @@
1
+ /**
2
+ * Structured runtime helpers for reading `agent.yaml`.
3
+ *
4
+ * Lookup order is intentionally small and explicit:
5
+ * 1. `configPath` argument: exact `agent.yaml` path, or a directory that
6
+ * contains it
7
+ * 2. `AGENTIC_AGENT_CONFIG_PATH`: exact in-container file path baked into
8
+ * runtime images
9
+ * 3. `AGENTIC_AGENT_WORKDIR`: agent working directory used by generated
10
+ * local dev stacks
11
+ * 4. current working directory: supports tests and ad-hoc SDK usage
12
+ */
13
+ import { z } from "zod";
14
+ /**
15
+ * Runtime feature flags from `agent.yaml`.
16
+ *
17
+ * Keep field names in parity with Python `AgentFeatureConfig` and the CLI
18
+ * allowlist. Add a flag by adding a field here; `FeatureName` and runtime
19
+ * feature access derive from it. `null` means "omitted", letting the runtime
20
+ * fall back to legacy environment variables.
21
+ */
22
+ export declare const AgentFeatureConfigSchema: z.ZodObject<{
23
+ memory: z.ZodDefault<z.ZodNullable<z.ZodBoolean>>;
24
+ guardrails: z.ZodDefault<z.ZodNullable<z.ZodBoolean>>;
25
+ playground: z.ZodDefault<z.ZodNullable<z.ZodBoolean>>;
26
+ deep_agent: z.ZodDefault<z.ZodNullable<z.ZodBoolean>>;
27
+ use_custom_parser: z.ZodDefault<z.ZodNullable<z.ZodBoolean>>;
28
+ durable_workflow: z.ZodDefault<z.ZodNullable<z.ZodBoolean>>;
29
+ }, z.core.$strip>;
30
+ export type AgentFeatureConfig = z.infer<typeof AgentFeatureConfigSchema>;
31
+ /** Derived from `AgentFeatureConfigSchema` — do not maintain a parallel union. */
32
+ export type FeatureName = keyof AgentFeatureConfig;
33
+ /**
34
+ * Return only the flags explicitly present in `agent.yaml` (omit unset /
35
+ * `null` fields). Mirrors Python's `AgentFeatureConfig.explicit()` — used by
36
+ * the AER's capability advertise to send OE only the flags the author
37
+ * actually set, before SDK-injected defaults (e.g. `owner_callback_fallback`)
38
+ * are layered on top.
39
+ */
40
+ export declare function explicitFeatures(features: AgentFeatureConfig): Record<string, boolean>;
41
+ export declare const SecretsConfigSchema: z.ZodObject<{
42
+ disable_restriction: z.ZodDefault<z.ZodBoolean>;
43
+ aer: z.ZodDefault<z.ZodArray<z.ZodString>>;
44
+ tools: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
45
+ }, z.core.$strip>;
46
+ export type SecretsConfig = z.infer<typeof SecretsConfigSchema>;
47
+ /**
48
+ * Input shape callers may construct: every key is omittable, since Zod defaults
49
+ * fill them in. The parsed {@link SecretsConfig} has them all present.
50
+ */
51
+ export type SecretsConfigInput = z.input<typeof SecretsConfigSchema>;
52
+ export declare const RuntimeMCPAuthConfigSchema: z.ZodObject<{
53
+ type: z.ZodDefault<z.ZodEnum<{
54
+ none: "none";
55
+ bearer_env: "bearer_env";
56
+ oauth: "oauth";
57
+ client_credentials: "client_credentials";
58
+ }>>;
59
+ token_env: z.ZodDefault<z.ZodNullable<z.ZodString>>;
60
+ redirect_uri: z.ZodDefault<z.ZodNullable<z.ZodString>>;
61
+ client_name: z.ZodDefault<z.ZodNullable<z.ZodString>>;
62
+ scope: z.ZodDefault<z.ZodNullable<z.ZodString>>;
63
+ token_url: z.ZodDefault<z.ZodNullable<z.ZodString>>;
64
+ client_id_env: z.ZodDefault<z.ZodNullable<z.ZodString>>;
65
+ client_secret_env: z.ZodDefault<z.ZodNullable<z.ZodString>>;
66
+ }, z.core.$strip>;
67
+ export type RuntimeMCPAuthConfig = z.infer<typeof RuntimeMCPAuthConfigSchema>;
68
+ export declare const RuntimeMCPServerConfigSchema: z.ZodObject<{
69
+ transport: z.ZodDefault<z.ZodLiteral<"streamable_http">>;
70
+ url: z.ZodString;
71
+ headers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
72
+ auth: z.ZodDefault<z.ZodObject<{
73
+ type: z.ZodDefault<z.ZodEnum<{
74
+ none: "none";
75
+ bearer_env: "bearer_env";
76
+ oauth: "oauth";
77
+ client_credentials: "client_credentials";
78
+ }>>;
79
+ token_env: z.ZodDefault<z.ZodNullable<z.ZodString>>;
80
+ redirect_uri: z.ZodDefault<z.ZodNullable<z.ZodString>>;
81
+ client_name: z.ZodDefault<z.ZodNullable<z.ZodString>>;
82
+ scope: z.ZodDefault<z.ZodNullable<z.ZodString>>;
83
+ token_url: z.ZodDefault<z.ZodNullable<z.ZodString>>;
84
+ client_id_env: z.ZodDefault<z.ZodNullable<z.ZodString>>;
85
+ client_secret_env: z.ZodDefault<z.ZodNullable<z.ZodString>>;
86
+ }, z.core.$strip>>;
87
+ allowed_tools: z.ZodDefault<z.ZodNullable<z.ZodArray<z.ZodString>>>;
88
+ timeout_seconds: z.ZodDefault<z.ZodNumber>;
89
+ }, z.core.$strip>;
90
+ export type RuntimeMCPServerConfig = z.infer<typeof RuntimeMCPServerConfigSchema>;
91
+ export declare const RuntimeMCPConfigSchema: z.ZodObject<{
92
+ servers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
93
+ transport: z.ZodDefault<z.ZodLiteral<"streamable_http">>;
94
+ url: z.ZodString;
95
+ headers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
96
+ auth: z.ZodDefault<z.ZodObject<{
97
+ type: z.ZodDefault<z.ZodEnum<{
98
+ none: "none";
99
+ bearer_env: "bearer_env";
100
+ oauth: "oauth";
101
+ client_credentials: "client_credentials";
102
+ }>>;
103
+ token_env: z.ZodDefault<z.ZodNullable<z.ZodString>>;
104
+ redirect_uri: z.ZodDefault<z.ZodNullable<z.ZodString>>;
105
+ client_name: z.ZodDefault<z.ZodNullable<z.ZodString>>;
106
+ scope: z.ZodDefault<z.ZodNullable<z.ZodString>>;
107
+ token_url: z.ZodDefault<z.ZodNullable<z.ZodString>>;
108
+ client_id_env: z.ZodDefault<z.ZodNullable<z.ZodString>>;
109
+ client_secret_env: z.ZodDefault<z.ZodNullable<z.ZodString>>;
110
+ }, z.core.$strip>>;
111
+ allowed_tools: z.ZodDefault<z.ZodNullable<z.ZodArray<z.ZodString>>>;
112
+ timeout_seconds: z.ZodDefault<z.ZodNumber>;
113
+ }, z.core.$strip>>>;
114
+ }, z.core.$strip>;
115
+ export type RuntimeMCPConfig = z.infer<typeof RuntimeMCPConfigSchema>;
116
+ /**
117
+ * Validated runtime view of `agent.yaml`.
118
+ *
119
+ * Class-based because Python uses computed `@property` accessors and helper
120
+ * methods (`feature_enabled`, `configured_feature`). Properties are exposed as
121
+ * TS getters under camelCase names; Python field names on
122
+ * `AgentFeatureConfig` are preserved verbatim so wire/log parity is
123
+ * maintained.
124
+ */
125
+ export declare class RuntimeAgentConfig {
126
+ readonly path: string | null;
127
+ readonly entrypoint: string | null;
128
+ /** Runtime language from agent.yaml; omitted means unset at advertise time. */
129
+ readonly language: string | null;
130
+ /** Application framework from agent.yaml; omitted means unset at advertise time. */
131
+ readonly framework: string | null;
132
+ readonly features: AgentFeatureConfig;
133
+ readonly requiredSecrets: SecretsConfig;
134
+ readonly mcp: RuntimeMCPConfig;
135
+ constructor(init?: {
136
+ path?: string | null;
137
+ entrypoint?: string | null;
138
+ language?: string | null;
139
+ framework?: string | null;
140
+ features?: AgentFeatureConfig;
141
+ requiredSecrets?: SecretsConfigInput;
142
+ mcp?: RuntimeMCPConfig;
143
+ });
144
+ /** Return a feature flag value, falling back to `defaultValue` when omitted. */
145
+ featureEnabled(name: FeatureName, defaultValue?: boolean): boolean;
146
+ /** Return the explicit feature value from `agent.yaml`, if it exists. */
147
+ configuredFeature(name: FeatureName): boolean | null;
148
+ }
149
+ /**
150
+ * Load and validate `agent.yaml` for runtime use.
151
+ *
152
+ * Missing files are treated as an empty config so unit tests and ad-hoc
153
+ * SDK usage can still construct `App`/`TenantRuntime` outside generated
154
+ * runtime environments. When a file exists, the runtime validates the
155
+ * fields it owns directly (entrypoint/features) while passing the
156
+ * application-owned `config` block through as raw data.
157
+ *
158
+ * `envVars` is the substitution mapping used to resolve `${VAR}` references
159
+ * at allowlisted YAML paths (currently `mcp.servers.*.url`). Pass the
160
+ * tenant-owned subset of the process environment — via `tenantEnvVars()` —
161
+ * never raw `process.env`, so tenant `agent.yaml` cannot dereference platform
162
+ * secrets. When `envVars` is `undefined` and a `${...}` reference is present
163
+ * at an allowlisted path, the loader throws so the misconfiguration is
164
+ * visible instead of falling through to `new URL()` with the literal string.
165
+ */
166
+ export declare function loadRuntimeAgentConfig(configPath?: string, envVars?: Record<string, string>): RuntimeAgentConfig;
167
+ //# sourceMappingURL=agent_config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent_config.d.ts","sourceRoot":"","sources":["../src/agent_config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAexB;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB;;;;;;;iBAuC3B,CAAC;AACX,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E,kFAAkF;AAClF,MAAM,MAAM,WAAW,GAAG,MAAM,kBAAkB,CAAC;AAEnD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,kBAAkB,GAC3B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAMzB;AASD,eAAO,MAAM,mBAAmB;;;;iBAOtB,CAAC;AACX,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAsDrE,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;iBA6EnC,CAAC;AACL,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE9E,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;iBA4CrC,CAAC;AACL,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAC1C,OAAO,4BAA4B,CACpC,CAAC;AAQF,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;iBAe/B,CAAC;AACL,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AA+ItE;;;;;;;;GAQG;AACH,qBAAa,kBAAkB;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,+EAA+E;IAC/E,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,oFAAoF;IACpF,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAC;IACtC,QAAQ,CAAC,eAAe,EAAE,aAAa,CAAC;IACxC,QAAQ,CAAC,GAAG,EAAE,gBAAgB,CAAC;gBAG7B,IAAI,GAAE;QACJ,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAC3B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACzB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAC1B,QAAQ,CAAC,EAAE,kBAAkB,CAAC;QAE9B,eAAe,CAAC,EAAE,kBAAkB,CAAC;QACrC,GAAG,CAAC,EAAE,gBAAgB,CAAC;KACnB;IAaR,gFAAgF;IAChF,cAAc,CAAC,IAAI,EAAE,WAAW,EAAE,YAAY,UAAQ,GAAG,OAAO;IAMhE,yEAAyE;IACzE,iBAAiB,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,GAAG,IAAI;CAMrD;AA+CD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,CAAC,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,kBAAkB,CAiEpB"}