rayito 0.3.0__tar.gz

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 (113) hide show
  1. rayito-0.3.0/LICENSE +202 -0
  2. rayito-0.3.0/NOTICE +13 -0
  3. rayito-0.3.0/PKG-INFO +428 -0
  4. rayito-0.3.0/README.md +396 -0
  5. rayito-0.3.0/pyproject.toml +119 -0
  6. rayito-0.3.0/src/rayito/__init__.py +214 -0
  7. rayito-0.3.0/src/rayito/_aws.py +588 -0
  8. rayito-0.3.0/src/rayito/_aws_sanitize.py +129 -0
  9. rayito-0.3.0/src/rayito/_charts.py +339 -0
  10. rayito-0.3.0/src/rayito/_code_base.py +367 -0
  11. rayito-0.3.0/src/rayito/_filesystem_base.py +623 -0
  12. rayito-0.3.0/src/rayito/_git_base.py +698 -0
  13. rayito-0.3.0/src/rayito/_lifecycle_base.py +479 -0
  14. rayito-0.3.0/src/rayito/_limits.py +123 -0
  15. rayito-0.3.0/src/rayito/_listing_base.py +460 -0
  16. rayito-0.3.0/src/rayito/_metrics_base.py +120 -0
  17. rayito-0.3.0/src/rayito/_models.py +1298 -0
  18. rayito-0.3.0/src/rayito/_network_base.py +376 -0
  19. rayito-0.3.0/src/rayito/_payload.py +148 -0
  20. rayito-0.3.0/src/rayito/_persistence_base.py +432 -0
  21. rayito-0.3.0/src/rayito/_pool_backends.py +171 -0
  22. rayito-0.3.0/src/rayito/_pool_base.py +599 -0
  23. rayito-0.3.0/src/rayito/_process_base.py +524 -0
  24. rayito-0.3.0/src/rayito/_pty_base.py +149 -0
  25. rayito-0.3.0/src/rayito/_s3.py +251 -0
  26. rayito-0.3.0/src/rayito/_sandbox_base.py +732 -0
  27. rayito-0.3.0/src/rayito/_transfer_base.py +783 -0
  28. rayito-0.3.0/src/rayito/_transport.py +516 -0
  29. rayito-0.3.0/src/rayito/_version.py +6 -0
  30. rayito-0.3.0/src/rayito/cli/__init__.py +7 -0
  31. rayito-0.3.0/src/rayito/cli/__main__.py +41 -0
  32. rayito-0.3.0/src/rayito/cli/_artifact.py +179 -0
  33. rayito-0.3.0/src/rayito/cli/_checks.py +732 -0
  34. rayito-0.3.0/src/rayito/cli/_compat.py +106 -0
  35. rayito-0.3.0/src/rayito/cli/_console.py +111 -0
  36. rayito-0.3.0/src/rayito/cli/_logs.py +158 -0
  37. rayito-0.3.0/src/rayito/cli/_prune.py +384 -0
  38. rayito-0.3.0/src/rayito/cli/_publish.py +497 -0
  39. rayito-0.3.0/src/rayito/cli/_session.py +163 -0
  40. rayito-0.3.0/src/rayito/cli/_terminal.py +301 -0
  41. rayito-0.3.0/src/rayito/cli/_tokens.py +73 -0
  42. rayito-0.3.0/src/rayito/cli/app.py +98 -0
  43. rayito-0.3.0/src/rayito/cli/doctor.py +166 -0
  44. rayito-0.3.0/src/rayito/cli/image.py +268 -0
  45. rayito-0.3.0/src/rayito/cli/sandbox.py +583 -0
  46. rayito-0.3.0/src/rayito/e2b/__init__.py +208 -0
  47. rayito-0.3.0/src/rayito/e2b/_async.py +1121 -0
  48. rayito-0.3.0/src/rayito/e2b/_client.py +81 -0
  49. rayito-0.3.0/src/rayito/e2b/_compat.py +666 -0
  50. rayito-0.3.0/src/rayito/e2b/_connection.py +365 -0
  51. rayito-0.3.0/src/rayito/e2b/_models.py +156 -0
  52. rayito-0.3.0/src/rayito/e2b/_sync.py +1396 -0
  53. rayito-0.3.0/src/rayito/e2b/_types.py +29 -0
  54. rayito-0.3.0/src/rayito/e2b/_unimplemented.py +169 -0
  55. rayito-0.3.0/src/rayito/e2b/exceptions.py +80 -0
  56. rayito-0.3.0/src/rayito/exceptions.py +244 -0
  57. rayito-0.3.0/src/rayito/mcp/__init__.py +21 -0
  58. rayito-0.3.0/src/rayito/mcp/__main__.py +8 -0
  59. rayito-0.3.0/src/rayito/mcp/_cli.py +170 -0
  60. rayito-0.3.0/src/rayito/mcp/_lease.py +134 -0
  61. rayito-0.3.0/src/rayito/mcp/_results.py +221 -0
  62. rayito-0.3.0/src/rayito/mcp/_server.py +351 -0
  63. rayito-0.3.0/src/rayito/mcp/_settings.py +127 -0
  64. rayito-0.3.0/src/rayito/py.typed +0 -0
  65. rayito-0.3.0/src/rayito/sandbox_async/__init__.py +3 -0
  66. rayito-0.3.0/src/rayito/sandbox_async/code.py +248 -0
  67. rayito-0.3.0/src/rayito/sandbox_async/commands.py +434 -0
  68. rayito-0.3.0/src/rayito/sandbox_async/filesystem.py +611 -0
  69. rayito-0.3.0/src/rayito/sandbox_async/git.py +554 -0
  70. rayito-0.3.0/src/rayito/sandbox_async/lifecycle.py +140 -0
  71. rayito-0.3.0/src/rayito/sandbox_async/listing.py +144 -0
  72. rayito-0.3.0/src/rayito/sandbox_async/main.py +1981 -0
  73. rayito-0.3.0/src/rayito/sandbox_async/persistence.py +136 -0
  74. rayito-0.3.0/src/rayito/sandbox_async/pool.py +704 -0
  75. rayito-0.3.0/src/rayito/sandbox_async/pty.py +183 -0
  76. rayito-0.3.0/src/rayito/sandbox_async/transfer.py +610 -0
  77. rayito-0.3.0/src/rayito/sandbox_sync/__init__.py +3 -0
  78. rayito-0.3.0/src/rayito/sandbox_sync/code.py +282 -0
  79. rayito-0.3.0/src/rayito/sandbox_sync/commands.py +483 -0
  80. rayito-0.3.0/src/rayito/sandbox_sync/filesystem.py +668 -0
  81. rayito-0.3.0/src/rayito/sandbox_sync/git.py +553 -0
  82. rayito-0.3.0/src/rayito/sandbox_sync/lifecycle.py +143 -0
  83. rayito-0.3.0/src/rayito/sandbox_sync/listing.py +143 -0
  84. rayito-0.3.0/src/rayito/sandbox_sync/main.py +2308 -0
  85. rayito-0.3.0/src/rayito/sandbox_sync/persistence.py +139 -0
  86. rayito-0.3.0/src/rayito/sandbox_sync/pool.py +749 -0
  87. rayito-0.3.0/src/rayito/sandbox_sync/pty.py +214 -0
  88. rayito-0.3.0/src/rayito/sandbox_sync/transfer.py +590 -0
  89. rayito-0.3.0/src/rayito/v1/__init__.py +4 -0
  90. rayito-0.3.0/src/rayito/v1/code_pb2.py +83 -0
  91. rayito-0.3.0/src/rayito/v1/code_pb2.pyi +193 -0
  92. rayito-0.3.0/src/rayito/v1/code_pb2_grpc.py +308 -0
  93. rayito-0.3.0/src/rayito/v1/common_pb2.py +48 -0
  94. rayito-0.3.0/src/rayito/v1/common_pb2.pyi +70 -0
  95. rayito-0.3.0/src/rayito/v1/common_pb2_grpc.py +4 -0
  96. rayito-0.3.0/src/rayito/v1/filesystem_pb2.py +137 -0
  97. rayito-0.3.0/src/rayito/v1/filesystem_pb2.pyi +465 -0
  98. rayito-0.3.0/src/rayito/v1/filesystem_pb2_grpc.py +710 -0
  99. rayito-0.3.0/src/rayito/v1/health_pb2.py +54 -0
  100. rayito-0.3.0/src/rayito/v1/health_pb2.pyi +96 -0
  101. rayito-0.3.0/src/rayito/v1/health_pb2_grpc.py +176 -0
  102. rayito-0.3.0/src/rayito/v1/lifecycle_pb2.py +46 -0
  103. rayito-0.3.0/src/rayito/v1/lifecycle_pb2.pyi +63 -0
  104. rayito-0.3.0/src/rayito/v1/lifecycle_pb2_grpc.py +92 -0
  105. rayito-0.3.0/src/rayito/v1/network_pb2.py +48 -0
  106. rayito-0.3.0/src/rayito/v1/network_pb2.pyi +63 -0
  107. rayito-0.3.0/src/rayito/v1/network_pb2_grpc.py +136 -0
  108. rayito-0.3.0/src/rayito/v1/process_pb2.py +75 -0
  109. rayito-0.3.0/src/rayito/v1/process_pb2.pyi +157 -0
  110. rayito-0.3.0/src/rayito/v1/process_pb2_grpc.py +303 -0
  111. rayito-0.3.0/src/rayito/v1/pty_pb2.py +60 -0
  112. rayito-0.3.0/src/rayito/v1/pty_pb2.pyi +96 -0
  113. rayito-0.3.0/src/rayito/v1/pty_pb2_grpc.py +267 -0
rayito-0.3.0/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.
rayito-0.3.0/NOTICE ADDED
@@ -0,0 +1,13 @@
1
+ Rayito
2
+ Copyright 2026 Rayito contributors
3
+
4
+ This product includes software developed by third parties:
5
+
6
+ - e2b_charts 1.0.0 (MIT License), Copyright (c) 2025 FOUNDRYLABS, INC.
7
+ Vendored at kernel-sidecar/src/rayito_kernel_sidecar/_vendor/e2b_charts
8
+ with its LICENSE file alongside; see VENDORED.md there for the upstream
9
+ source, the sdist checksum and the single import-path change.
10
+ - Git argument builders, porcelain parsers and failure snippets in
11
+ `clients/python/src/rayito/_git_base.py` and
12
+ `clients/typescript/src/sandbox/git-args.ts` are adapted from the E2B SDK
13
+ (github.com/e2b-dev/E2B, Apache License 2.0).
rayito-0.3.0/PKG-INFO ADDED
@@ -0,0 +1,428 @@
1
+ Metadata-Version: 2.4
2
+ Name: rayito
3
+ Version: 0.3.0
4
+ Summary: Sandboxes de ejecución para agentes de IA sobre AWS Lambda MicroVMs, en tu propia cuenta.
5
+ Keywords: sandbox,e2b,aws,microvm,firecracker,agents,code-interpreter
6
+ License-Expression: Apache-2.0
7
+ License-File: LICENSE
8
+ License-File: NOTICE
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3 :: Only
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Framework :: AsyncIO
17
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
+ Classifier: Typing :: Typed
19
+ Requires-Dist: grpcio>=1.84,<2
20
+ Requires-Dist: protobuf>=7.36.1,<8
21
+ Requires-Dist: boto3>=1.43.82,<2
22
+ Requires-Dist: typer>=0.15,<1 ; extra == 'cli'
23
+ Requires-Dist: mcp>=2.2,<3 ; extra == 'mcp'
24
+ Requires-Python: >=3.11
25
+ Project-URL: Changelog, https://github.com/alejandro-cedeno-10/rayito/blob/main/clients/python/CHANGELOG.md
26
+ Project-URL: Documentation, https://github.com/alejandro-cedeno-10/rayito/tree/main/docs/site/docs
27
+ Project-URL: Homepage, https://github.com/alejandro-cedeno-10/rayito
28
+ Project-URL: Repository, https://github.com/alejandro-cedeno-10/rayito
29
+ Provides-Extra: cli
30
+ Provides-Extra: mcp
31
+ Description-Content-Type: text/markdown
32
+
33
+ # rayito (SDK Python)
34
+
35
+ Cliente Python de Rayito: sandboxes de ejecución para agentes de IA sobre AWS
36
+ Lambda MicroVMs, dentro de tu propia cuenta. La ergonomía del SDK de E2B sin
37
+ que el código de tus clientes salga de tu cuenta y sin clúster que operar.
38
+
39
+ ```python
40
+ from rayito import Sandbox
41
+
42
+ with Sandbox.create(template="rayito-base", timeout=900) as sbx:
43
+ print(sbx.run_code("x = 40; x + 2").text) # "42"
44
+ ```
45
+
46
+ Documentación: `docs/site` (quickstart, conceptos, referencia de API,
47
+ seguridad, límites, compatibilidad con E2B y modelo de costes; `make docs`
48
+ la construye). Cambios por versión: `CHANGELOG.md`.
49
+
50
+ ## Novedades de 0.3.0 (M9)
51
+
52
+ Paridad con E2B 2.x; exige una imagen publicada con el `rayd` de M9 y está
53
+ aceptada contra AWS real (2026-09-24). Cada bloque enlaza su página de
54
+ `docs/site/docs/`; qué imagen necesita cada cosa, en `images.md`.
55
+
56
+ ```python
57
+ import requests
58
+ from rayito import ALL_TRAFFIC, AsyncSandbox, S3Staging, Sandbox
59
+
60
+ # Plazo del servidor (lifecycle.md): rayd lo impone aunque tu proceso muera
61
+ sbx = Sandbox.create(timeout=600, max_lifetime=7200, on_timeout="kill")
62
+ sbx.set_timeout(1800) # exacto, hasta max_lifetime
63
+ sbx.connect(timeout=900) # sólo alarga
64
+
65
+ # Historial de métricas y listado (observability.md)
66
+ samples = sbx.get_metrics_history(max_points=60)
67
+ pages = Sandbox.paginate(limit=20, order="desc")
68
+ first, cursor = pages.next_items(), pages.next_token
69
+
70
+ # Git (git.md)
71
+ sbx.git.clone("https://github.com/octo/demo.git", path="/home/user/demo", depth=1)
72
+ print(sbx.git.status("/home/user/demo").current_branch)
73
+ sbx.kill()
74
+
75
+ # Transferencias por S3 (files.md): URLs firmadas con tus credenciales
76
+ with Sandbox.create(transfer=S3Staging("amzn-s3-demo-bucket")) as sbx:
77
+ ticket = sbx.files.upload_url("/home/user/in.csv", expires_in=900)
78
+ requests.put(ticket, data=b"a,b\n1,2\n", headers=ticket.headers).raise_for_status()
79
+ ticket.wait()
80
+ link = sbx.files.download_url("/home/user/in.csv")
81
+ sbx.files.write("/home/user/log.txt", "texto", gzip=True, metadata={"origen": "ci"})
82
+
83
+ # JavaScript y TypeScript con Deno (kernels.md), sólo rayito-base-poly
84
+ with Sandbox.create("rayito-base-poly") as sbx:
85
+ print(sbx.run_code("const x: number = 40 + 2; x", language="typescript").text)
86
+
87
+ # Red saliente de E2B (network.md), sólo rayito-base-caps
88
+ with Sandbox.create(
89
+ "rayito-base-caps", network={"deny_out": [ALL_TRAFFIC], "allow_out": ["api.example.com"]}
90
+ ) as sbx:
91
+ sbx.update_network({"deny_out": [ALL_TRAFFIC]})
92
+
93
+
94
+ # Todo lo anterior también en asyncio
95
+ async def main() -> None:
96
+ async with await AsyncSandbox.create(timeout=600, max_lifetime=3600) as sbx:
97
+ await sbx.set_timeout(1200)
98
+ print(len(await sbx.get_metrics_history()))
99
+ ```
100
+
101
+ ```bash
102
+ # CLI (cli.md): create/connect/exec/metrics; el token nunca por argv
103
+ rayito sandbox create rayito-base --detach --token-file ~/.rayito/demo.token
104
+ rayito sandbox exec microvm-<id> --token-file ~/.rayito/demo.token -- python3 -c 'print(42)'
105
+ ```
106
+
107
+ Si vienes de E2B, `from rayito.e2b import Sandbox` (shim 2.x, "Shim de
108
+ E2B" más abajo, `e2b-compat.md` y `e2b-parity.md`). Cambios que rompen:
109
+ `CHANGELOG.md` ("Changed (shim)").
110
+
111
+ ## Instalación
112
+
113
+ ```bash
114
+ pip install rayito # o: uv add rayito
115
+ ```
116
+
117
+ Python ≥ 3.11; dependencias de runtime `grpcio`, `protobuf` y `boto3`.
118
+
119
+ ## Credenciales
120
+
121
+ El SDK usa las credenciales de AWS de la sesión de `boto3` (perfil, variables
122
+ de entorno o rol de la máquina); no hay API key.
123
+
124
+ ```bash
125
+ export AWS_PROFILE=<perfil> AWS_REGION=us-east-1
126
+ export RAYITO_TEMPLATE=rayito-base # nombre o ARN de la imagen
127
+ ```
128
+
129
+ `RAYITO_TEMPLATE` evita pasar `template=` en cada `create()`. Cada sandbox
130
+ arranca desde una versión de la imagen `rayito-base` (construida desde
131
+ `image/Dockerfile`, publicada con `make image-publish`). El SDK 0.3 necesita
132
+ una imagen publicada con el agente 0.3 (M9): sobre una anterior, las
133
+ funciones de M9 lanzan `UnimplementedError`; `rayito doctor` lo comprueba.
134
+
135
+ ## CLI
136
+
137
+ El extra `rayito[cli]` instala el comando `rayito` (`docs/site/docs/cli.md`):
138
+
139
+ ```bash
140
+ pip install "rayito[cli]"
141
+ rayito doctor --template rayito-base # diez comprobaciones de la cuenta; --launch prueba un sandbox
142
+ rayito sandbox list # MicroVMs vivos; también info, kill, logs
143
+ rayito image publish --artifact image/rayito-image.zip --base-image-version 1 --bucket <bucket>
144
+ ```
145
+
146
+ ## Crear y destruir
147
+
148
+ ```python
149
+ from rayito import IdlePolicy, Sandbox
150
+
151
+ sbx = Sandbox.create(
152
+ timeout=1800, # vida máxima (running + suspended), tope 8 h
153
+ idle=IdlePolicy(max_idle_seconds=600), # auto-suspensión; None la desactiva
154
+ envs={"APP_ENV": "dev"},
155
+ execution_role_arn=None, # sin rol no hay credenciales dentro
156
+ )
157
+ print(sbx.sandbox_id, sbx.access_token) # guárdalos para connect()
158
+ sbx.kill() # terminate-microvm (o usa `with`)
159
+
160
+ again = Sandbox.connect(sandbox_id, access_token=token) # desde otro proceso
161
+ ```
162
+
163
+ Plazo del servidor (M9, ADR-011, exige una imagen M9): con `max_lifetime` u
164
+ `on_timeout`, `timeout` es un plazo lógico que `rayd` hace cumplir aunque tu
165
+ proceso muera, y `max_lifetime` (≤ 28 800 s, running + suspendido) el tope fijo
166
+ de la plataforma.
167
+
168
+ ```python
169
+ sbx = Sandbox.create(timeout=600, max_lifetime=7200, on_timeout="kill")
170
+ sbx.set_timeout(1800) # SetTimeout EXACT: alarga o acorta, hasta max_lifetime
171
+ print(sbx.get_info().expires_at) # el plazo lógico
172
+ Sandbox.connect(sbx.sandbox_id, access_token=sbx.access_token, timeout=900) # sólo alarga
173
+ ```
174
+
175
+ Con `on_timeout="pause"` (necesita `idle`) el sandbox se suspende al vencer
176
+ en vez de terminar. Contra una imagen anterior a M9 pedir un ciclo de vida es
177
+ `LifecycleUnsupportedException` y el VM se termina.
178
+
179
+ ## Comandos
180
+
181
+ ```python
182
+ from rayito import CommandExitException, Sandbox
183
+
184
+ with Sandbox.create() as sbx:
185
+ result = sbx.commands.run("echo hola") # foreground
186
+ print(result.stdout, result.exit_code) # "hola\n" 0
187
+
188
+ sbx.commands.run("ls /", on_stdout=lambda line: print(line, end=""))
189
+
190
+ server = sbx.commands.run("python3 -m http.server 3000", background=True, timeout=None)
191
+ print(server.pid, [p.pid for p in sbx.commands.list()])
192
+ server.kill()
193
+
194
+ try:
195
+ sbx.commands.run("exit 3")
196
+ except CommandExitException as error: # exit != 0 es excepción
197
+ print(error.exit_code, error.stderr)
198
+ ```
199
+
200
+ ## Ficheros
201
+
202
+ ```python
203
+ from rayito import Sandbox, WriteEntry
204
+
205
+ with Sandbox.create() as sbx:
206
+ info = sbx.files.write("/home/user/data.csv", "a,b\n1,2\n")
207
+ print(info.size, sbx.files.read("/home/user/data.csv"))
208
+ raw = sbx.files.read("/home/user/data.csv", format="bytes")
209
+
210
+ sbx.files.write_files(
211
+ [WriteEntry("/home/user/a.txt", "a"), WriteEntry("/home/user/b.txt", b"b")]
212
+ )
213
+ print([entry.name for entry in sbx.files.list("/home/user")])
214
+
215
+ with sbx.files.watch_dir("/home/user", on_event=print) as watch:
216
+ sbx.commands.run("touch /home/user/new.txt")
217
+ print(watch.get_new_events())
218
+ ```
219
+
220
+ URLs de S3 y ficheros grandes (M9, ADR-010): el SDK firma con **tus**
221
+ credenciales y `rayd` mueve los bytes; hace falta un bucket de transferencias
222
+ (`S3Staging` o `RAYITO_TRANSFER_BUCKET`). Detalle, IAM y bucket en
223
+ `docs/site/docs/files.md`.
224
+
225
+ ```python
226
+ import requests
227
+ from rayito import S3Staging, Sandbox
228
+
229
+ with Sandbox.create(transfer=S3Staging("amzn-s3-demo-bucket")) as sbx:
230
+ ticket = sbx.files.upload_url("/home/user/in.csv", expires_in=900)
231
+ requests.put(ticket, data=open("in.csv", "rb"), headers=ticket.headers)
232
+ ticket.wait() # o deja que la barrera espere
233
+ link = sbx.files.download_url("/home/user/in.csv") # una foto del fichero
234
+ sbx.files.write("/home/user/big.bin", open("big.bin", "rb")) # > 8 MiB: por S3
235
+ sbx.files.write("/home/user/log.txt", "texto", gzip=True, metadata={"origen": "ci"})
236
+ ```
237
+
238
+ ## run_code
239
+
240
+ ```python
241
+ with Sandbox.create() as sbx:
242
+ sbx.run_code("x = 42")
243
+ print(sbx.run_code("x").text) # "42": el kernel tiene estado
244
+
245
+ plot = sbx.run_code("import matplotlib.pyplot as plt; plt.plot([1, 2, 3]); plt.show()")
246
+ print(plot.results[0].formats()) # ["png", "chart"]
247
+ png_base64 = plot.results[0].png
248
+
249
+ failed = sbx.run_code("1/0")
250
+ print(failed.error.name) # "ZeroDivisionError", nunca excepción
251
+
252
+ ctx = sbx.create_code_context(cwd="/tmp")
253
+ print(sbx.run_code("x", context=ctx).error.name) # "NameError": otro kernel
254
+
255
+ # Kernel bash (variante de imagen rayito-base-poly): arranca en la primera celda
256
+ print("".join(sbx.run_code("echo hi", language="bash").logs.stdout)) # "hi\n"
257
+ ```
258
+
259
+ `language` acepta `python`, `bash`, `javascript` (alias `js`) y
260
+ `typescript` (alias `ts`); los tres últimos viven en `rayito-base-poly`
261
+ (JavaScript y TypeScript con el kernel de Deno, M9). En `rayito-base`
262
+ cualquier kernel distinto de Python es `InvalidArgumentException` con
263
+ `grpc_code` `UNIMPLEMENTED` nombrando `rayito-base-poly`
264
+ (`docs/site/docs/kernels.md`).
265
+
266
+ ## PTY
267
+
268
+ ```python
269
+ from rayito import PtySize, Sandbox
270
+
271
+ with Sandbox.create() as sbx:
272
+ pty = sbx.pty.create(size=PtySize(cols=120, rows=40), on_data=print, timeout=None)
273
+ pty.send_input("echo hola\n")
274
+ for _, _, data in pty: # (None, None, bytes) por chunk
275
+ if b"hola\r\n" in data:
276
+ break
277
+ pty.resize(PtySize(cols=80, rows=24))
278
+ pty.kill()
279
+ ```
280
+
281
+ ## pause / resume
282
+
283
+ ```python
284
+ with Sandbox.create() as sbx:
285
+ sbx.run_code("x = 42")
286
+ sbx.pause() # suspend-microvm: todo sigue vivo al otro lado
287
+ sbx.resume() # resume-microvm + Health con la generación nueva
288
+ print(sbx.run_code("x").text) # "42": el kernel conservó su estado
289
+ print(sbx.get_health().resume_generation) # 1
290
+ ```
291
+
292
+ Los handles, watches y `run_code` que estaban abiertos se reenganchan solos la
293
+ próxima vez que se leen; los unarios cortados se reintentan una vez;
294
+ `reconnect_timeout` (60 s) acota cuánto espera el SDK al agente una vez que el
295
+ MicroVM vuelve a `RUNNING`. Leer un handle en background nunca despierta un
296
+ sandbox suspendido.
297
+
298
+ ## get_host
299
+
300
+ ```python
301
+ import httpx
302
+
303
+ with Sandbox.create() as sbx:
304
+ sbx.commands.run("python3 -m http.server 3000", background=True, timeout=None)
305
+ host = sbx.get_host(3000) # un str: f"https://{host}" funciona
306
+ response = httpx.get(f"https://{host}/", headers=host.headers) # cabeceras del proxy de AWS
307
+ ```
308
+
309
+ ## Metadatos
310
+
311
+ ```python
312
+ sbx = Sandbox.create(metadata={"owner": "ana", "run": "42"})
313
+ print(sbx.metadata) # {"owner": "ana", "run": "42"}
314
+ print(sbx.get_info().metadata)
315
+ print(Sandbox.get_info(sbx.sandbox_id).metadata) # desde otro proceso: un JWE + un Health
316
+
317
+ for item in Sandbox.list(metadata={"run": "42"}):
318
+ print(item.sandbox_id, item.metadata)
319
+ ```
320
+
321
+ `metadata` viaja en el `runHookPayload` (4096 caracteres junto a `envs`),
322
+ es inmutable y **no es secreto** (cualquier principal que pueda acuñar un
323
+ JWE para el sandbox lo lee por `Health`). `Sandbox.list(metadata=...)` filtra
324
+ en cliente y es **O(n)**: por cada sandbox `RUNNING` hace `get-microvm` +
325
+ `create-microvm-auth-token` + un `Health` (≈ 0,5-1 s por sandbox) y cada sonda
326
+ cuenta como tráfico para su política de idle; nunca sondea un sandbox
327
+ suspendido (`states` sólo admite `RUNNING`). Filtra por `template` antes si
328
+ tienes muchos.
329
+
330
+ Listado reanudable e historial de métricas (M9):
331
+
332
+ ```python
333
+ from datetime import datetime, timedelta, timezone
334
+
335
+ pages = Sandbox.paginate(limit=20, order="desc")
336
+ first = pages.next_items()
337
+ more = Sandbox.paginate(next_token=pages.next_token).next_items() if pages.has_next else []
338
+
339
+ with Sandbox.create() as sbx:
340
+ since = datetime.now(timezone.utc) - timedelta(minutes=10)
341
+ for sample in sbx.get_metrics_history(start=since, max_points=60): # una muestra cada 5 s
342
+ print(sample.timestamp, sample.cpu_used_pct, sample.mem_used_bytes)
343
+ ```
344
+
345
+ `order` se calcula en cliente (recorre todas las páginas antes del primer
346
+ item); el historial tiene un hueco mientras el sandbox está suspendido.
347
+
348
+ ## Shim de E2B
349
+
350
+ ```python
351
+ # antes
352
+ from e2b_code_interpreter import Sandbox
353
+
354
+ # después
355
+ from rayito.e2b import Sandbox
356
+
357
+ with Sandbox.create(timeout=300, metadata={"run": "42"}) as sbx:
358
+ print(sbx.run_code("1 + 1").text)
359
+ print(sbx.commands.run("echo hi").stdout)
360
+ sbx.set_timeout(600) # SetTimeout: rayd mueve el plazo (tope max_lifetime, 3600 s por defecto)
361
+ ```
362
+
363
+ `rayito.e2b` re-exporta los nombres del SDK de E2B **2.x** (`Sandbox`,
364
+ `AsyncSandbox`, `E2B`, `ConnectionConfig`, `Execution`, `CommandHandle`,
365
+ `SandboxInfo`, `SandboxQuery`, `SandboxPaginator`, `PtySize(rows, cols)`,
366
+ `Git`, las excepciones...), sigue los valores por defecto de E2B (`timeout=300`
367
+ como plazo lógico con `on_timeout='kill'`, sin auto-pausa, endpoint público y
368
+ salida a internet) y **exige una imagen M9**. Mapea `set_timeout`,
369
+ `connect(timeout)`, `lifecycle`, `beta_create(auto_pause=True)`,
370
+ `upload_url`/`download_url`, `get_metrics(start, end)`, `list(next_token=)`,
371
+ `allow_internet_access=False` y `network` (en `rayito-base-caps`),
372
+ `update_network`, `git` y `run_code(language="typescript")`; ignora con
373
+ `RayitoCompatWarning` `api_key`, `domain`, `debug` y `secure=False`; y lanza
374
+ `UnimplementedError` (un `NotImplementedError`, nunca `SandboxException`)
375
+ para lo que Lambda MicroVMs no puede hacer: `fork`, snapshots,
376
+ `pause(keep_memory=False)`, `network.rules`, MCP, `iam`, volúmenes, secretos,
377
+ templates y kernels R/Java. El nativo queda en `sbx.native`. Tabla completa:
378
+ `docs/site/docs/e2b-compat.md`.
379
+
380
+ ## AsyncSandbox
381
+
382
+ ```python
383
+ import asyncio
384
+ from rayito import AsyncSandbox
385
+
386
+
387
+ async def main() -> None:
388
+ async with await AsyncSandbox.create(metadata={"run": "42"}) as sbx:
389
+ print((await sbx.run_code("1 + 1")).text)
390
+ print((await sbx.commands.run("echo hola")).stdout)
391
+ await sbx.files.write("/home/user/a.txt", "a")
392
+ print(await AsyncSandbox.list(metadata={"run": "42"}))
393
+
394
+
395
+ asyncio.run(main())
396
+ ```
397
+
398
+ La misma superficie que `Sandbox` (incluido `rayito.e2b.AsyncSandbox`) sobre
399
+ `grpc.aio`; las llamadas al plano de control van por `asyncio.to_thread`.
400
+
401
+ ## Límites y costes (medidos)
402
+
403
+ | Concepto | Valor |
404
+ |---|---|
405
+ | Vida máxima de un sandbox | 28 800 s (8 h) running + suspended, no se puede extender |
406
+ | `runHookPayload` (`envs` + `metadata`) | 4096 caracteres |
407
+ | Conexiones concurrentes por MicroVM (1 vCPU) | 8; el SDK usa ≤ 2 canales |
408
+ | Cómputo a 2 GB / 1 vCPU | $0.126/h |
409
+ | Ciclo suspend + resume a 2 GB | ≈ $0.011 (≈ 5 min de cómputo) |
410
+ | Storage por versión de imagen | ≈ $0.037/semana (mínimo una semana) |
411
+ | Arranque en frío hasta `agent_ready` / `pause()` | 2.36 s / ≈ 1.4 s |
412
+ | Escritura / lectura de ficheros a 2 GB | 0.65 MB/s / 6.71 MB/s |
413
+ | `list(metadata=)` | ≈ 0.5-1 s por sandbox `RUNNING` |
414
+
415
+ Fuentes: `AWS_API_NOTES.md` §11-§12, §16 y `MILESTONES.md`; detalle en
416
+ `docs/site/docs/limits.md` y `docs/site/docs/cost.md`.
417
+
418
+ ## Desarrollo
419
+
420
+ ```bash
421
+ cd clients/python
422
+ uv sync
423
+ uv run pytest tests/unit
424
+ uv run ruff check . && uv run ruff format --check .
425
+ uv run mypy src tests
426
+ uv build && python ../../scripts/check_wheel.py dist/*.whl && uvx twine==7.0.0 check dist/*
427
+ RAYITO_E2E=1 RAYITO_TEMPLATE=<arn-o-nombre> uv run pytest tests/e2e -m e2e -v -s
428
+ ```