nightona 0.191.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 (67) hide show
  1. nightona-0.191.0/LICENSE +190 -0
  2. nightona-0.191.0/PKG-INFO +214 -0
  3. nightona-0.191.0/README.md +170 -0
  4. nightona-0.191.0/pyproject.toml +56 -0
  5. nightona-0.191.0/src/nightona/__init__.py +242 -0
  6. nightona-0.191.0/src/nightona/_async/__init__.py +2 -0
  7. nightona-0.191.0/src/nightona/_async/code_interpreter.py +302 -0
  8. nightona-0.191.0/src/nightona/_async/computer_use.py +930 -0
  9. nightona-0.191.0/src/nightona/_async/filesystem.py +1240 -0
  10. nightona-0.191.0/src/nightona/_async/git.py +391 -0
  11. nightona-0.191.0/src/nightona/_async/lsp_server.py +256 -0
  12. nightona-0.191.0/src/nightona/_async/nightona.py +819 -0
  13. nightona-0.191.0/src/nightona/_async/object_storage.py +190 -0
  14. nightona-0.191.0/src/nightona/_async/process.py +781 -0
  15. nightona-0.191.0/src/nightona/_async/sandbox.py +904 -0
  16. nightona-0.191.0/src/nightona/_async/snapshot.py +262 -0
  17. nightona-0.191.0/src/nightona/_async/volume.py +94 -0
  18. nightona-0.191.0/src/nightona/_sync/__init__.py +2 -0
  19. nightona-0.191.0/src/nightona/_sync/code_interpreter.py +271 -0
  20. nightona-0.191.0/src/nightona/_sync/computer_use.py +929 -0
  21. nightona-0.191.0/src/nightona/_sync/filesystem.py +1063 -0
  22. nightona-0.191.0/src/nightona/_sync/git.py +389 -0
  23. nightona-0.191.0/src/nightona/_sync/lsp_server.py +256 -0
  24. nightona-0.191.0/src/nightona/_sync/nightona.py +704 -0
  25. nightona-0.191.0/src/nightona/_sync/object_storage.py +184 -0
  26. nightona-0.191.0/src/nightona/_sync/process.py +778 -0
  27. nightona-0.191.0/src/nightona/_sync/sandbox.py +919 -0
  28. nightona-0.191.0/src/nightona/_sync/snapshot.py +262 -0
  29. nightona-0.191.0/src/nightona/_sync/volume.py +94 -0
  30. nightona-0.191.0/src/nightona/_utils/__init__.py +2 -0
  31. nightona-0.191.0/src/nightona/_utils/deprecation.py +95 -0
  32. nightona-0.191.0/src/nightona/_utils/docs_ignore.py +11 -0
  33. nightona-0.191.0/src/nightona/_utils/enum.py +27 -0
  34. nightona-0.191.0/src/nightona/_utils/env.py +47 -0
  35. nightona-0.191.0/src/nightona/_utils/environment.py +23 -0
  36. nightona-0.191.0/src/nightona/_utils/errors.py +298 -0
  37. nightona-0.191.0/src/nightona/_utils/otel_decorator.py +331 -0
  38. nightona-0.191.0/src/nightona/_utils/stream.py +368 -0
  39. nightona-0.191.0/src/nightona/_utils/timeout.py +484 -0
  40. nightona-0.191.0/src/nightona/_utils/types.py +16 -0
  41. nightona-0.191.0/src/nightona/common/__init__.py +2 -0
  42. nightona-0.191.0/src/nightona/common/charts.py +118 -0
  43. nightona-0.191.0/src/nightona/common/code_interpreter.py +44 -0
  44. nightona-0.191.0/src/nightona/common/computer_use.py +44 -0
  45. nightona-0.191.0/src/nightona/common/errors.py +187 -0
  46. nightona-0.191.0/src/nightona/common/file_transfer.py +69 -0
  47. nightona-0.191.0/src/nightona/common/filesystem.py +177 -0
  48. nightona-0.191.0/src/nightona/common/git.py +13 -0
  49. nightona-0.191.0/src/nightona/common/image.py +700 -0
  50. nightona-0.191.0/src/nightona/common/lsp_server.py +45 -0
  51. nightona-0.191.0/src/nightona/common/nightona.py +202 -0
  52. nightona-0.191.0/src/nightona/common/process.py +140 -0
  53. nightona-0.191.0/src/nightona/common/protocols.py +14 -0
  54. nightona-0.191.0/src/nightona/common/pty.py +65 -0
  55. nightona-0.191.0/src/nightona/common/sandbox.py +99 -0
  56. nightona-0.191.0/src/nightona/common/snapshot.py +84 -0
  57. nightona-0.191.0/src/nightona/common/volume.py +39 -0
  58. nightona-0.191.0/src/nightona/handle/async_pty_handle.py +323 -0
  59. nightona-0.191.0/src/nightona/handle/pty_handle.py +341 -0
  60. nightona-0.191.0/src/nightona/internal/__init__.py +2 -0
  61. nightona-0.191.0/src/nightona/internal/api_client_proxy.py +22 -0
  62. nightona-0.191.0/src/nightona/internal/http_client.py +99 -0
  63. nightona-0.191.0/src/nightona/internal/pool_tracker.py +44 -0
  64. nightona-0.191.0/src/nightona/internal/shared_session.py +262 -0
  65. nightona-0.191.0/src/nightona/internal/toolbox_api_client_proxy.py +114 -0
  66. nightona-0.191.0/src/nightona/internal/urllib3_retry.py +53 -0
  67. nightona-0.191.0/src/nightona/py.typed +0 -0
@@ -0,0 +1,190 @@
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
+ Copyright 2025 Daytona
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
@@ -0,0 +1,214 @@
1
+ Metadata-Version: 2.3
2
+ Name: nightona
3
+ Version: 0.191.0
4
+ Summary: Python SDK for Nightona
5
+ License: Apache-2.0
6
+ Keywords: nightona,sdk
7
+ Author: Daytona Platforms Inc.
8
+ Author-email: support@daytona.io
9
+ Maintainer: Nightona contributors
10
+ Maintainer-email: amaraaamka0404@gmail.com
11
+ Requires-Python: >=3.9,<4.0
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: 3.14
21
+ Requires-Dist: Deprecated (>=1.2.18,<2.0.0)
22
+ Requires-Dist: aiofiles (>=24.1.0,<25.2.0)
23
+ Requires-Dist: aiohttp (>=3.10.0,<4.0.0)
24
+ Requires-Dist: httpx (>=0.28.0,<0.29.0)
25
+ Requires-Dist: httpx-ws (>=0.7.0,<1.0.0)
26
+ Requires-Dist: nightona-api-client (==0.191.0)
27
+ Requires-Dist: nightona-api-client-async (==0.191.0)
28
+ Requires-Dist: nightona-toolbox-api-client (==0.191.0)
29
+ Requires-Dist: nightona-toolbox-api-client-async (==0.191.0)
30
+ Requires-Dist: obstore (>=0.8.0,<0.12.0)
31
+ Requires-Dist: opentelemetry-api (>=1.27.0,<2.0.0)
32
+ Requires-Dist: opentelemetry-exporter-otlp-proto-http (>=1.27.0,<2.0.0)
33
+ Requires-Dist: opentelemetry-instrumentation-aiohttp-client (>=0.59b0)
34
+ Requires-Dist: opentelemetry-sdk (>=1.27.0,<2.0.0)
35
+ Requires-Dist: pydantic (>=2.4.2,<3.0.0)
36
+ Requires-Dist: python-dotenv (>=1.0.0,<2.0.0)
37
+ Requires-Dist: python-multipart (>=0.0.15,<0.1.0)
38
+ Requires-Dist: toml (>=0.10.0,<0.11.0)
39
+ Requires-Dist: typing-extensions (>=4.0.0) ; python_version < "3.10"
40
+ Requires-Dist: urllib3 (>=2.1.0,<3.0.0)
41
+ Requires-Dist: wsproto (>=1.2.0,<2.0.0)
42
+ Description-Content-Type: text/markdown
43
+
44
+ # Nightona Python SDK
45
+
46
+ The official Python SDK for [Nightona](https://daytona.io), a secure and elastic infrastructure for running AI-generated code. Nightona provides full composable computers — [sandboxes](https://www.daytona.io/docs/en/sandboxes/) — that you can manage programmatically using the Nightona SDK.
47
+
48
+ The SDK provides an interface for sandbox management, file system operations, Git operations, language server protocol support, process and code execution, and computer use. For more information, see the [documentation](https://www.daytona.io/docs/en/python-sdk/).
49
+
50
+ ## Installation
51
+
52
+ Install the package using **pip**:
53
+
54
+ ```bash
55
+ pip install nightona
56
+ ```
57
+
58
+ ## Get API key
59
+
60
+ Generate an API key from the [Nightona Dashboard ↗](https://app.daytona.io/dashboard/keys) to authenticate SDK requests and access Nightona services. For more information, see the [API keys](https://www.daytona.io/docs/en/api-keys/) documentation.
61
+
62
+ ## Configuration
63
+
64
+ Configure the SDK using [environment variables](https://www.daytona.io/docs/en/configuration/#environment-variables) or by passing a [configuration object](https://www.daytona.io/docs/en/configuration/#configuration-in-code):
65
+
66
+ - `NIGHTONA_API_KEY`: Your Nightona [API key](https://www.daytona.io/docs/en/api-keys/)
67
+ - `NIGHTONA_API_URL`: The Nightona [API URL](https://www.daytona.io/docs/en/tools/api/)
68
+ - `NIGHTONA_TARGET`: Your target [region](https://www.daytona.io/docs/en/regions/) environment (e.g. `us`, `eu`)
69
+
70
+ ```python
71
+ from nightona import Nightona, NightonaConfig
72
+
73
+ # Initialize with environment variables
74
+ nightona = Nightona()
75
+
76
+ # Initialize with configuration object
77
+ config = NightonaConfig(
78
+ api_key="YOUR_API_KEY",
79
+ api_url="YOUR_API_URL",
80
+ target="us"
81
+ )
82
+ ```
83
+
84
+ ## Create a sandbox
85
+
86
+ Create a sandbox to run your code securely in an isolated environment.
87
+
88
+ ```python
89
+ from nightona import Nightona, NightonaConfig
90
+
91
+ config = NightonaConfig(api_key="YOUR_API_KEY")
92
+ nightona = Nightona(config)
93
+ sandbox = nightona.create()
94
+ response = sandbox.process.code_run('print("Hello World")')
95
+ ```
96
+
97
+ ## Examples and guides
98
+
99
+ Nightona provides [examples](https://www.daytona.io/docs/en/getting-started/#examples) and [guides](https://www.daytona.io/docs/en/guides/) for common sandbox operations, best practices, and a wide range of topics, from basic usage to advanced topics, showcasing various types of integrations between Nightona and other tools.
100
+
101
+ ### Create a sandbox with custom resources
102
+
103
+ Create a sandbox with [custom resources](https://www.daytona.io/docs/en/sandboxes/#resources) (CPU, memory, disk).
104
+
105
+ ```python
106
+ from nightona import Nightona, CreateSandboxFromImageParams, Image, Resources
107
+
108
+ nightona = Nightona()
109
+ sandbox = nightona.create(
110
+ CreateSandboxFromImageParams(
111
+ image=Image.debian_slim("3.12"),
112
+ resources=Resources(cpu=2, memory=4, disk=8)
113
+ )
114
+ )
115
+ ```
116
+
117
+ ### Create an ephemeral sandbox
118
+
119
+ Create an [ephemeral sandbox](https://www.daytona.io/docs/en/sandboxes/#ephemeral-sandboxes) that is automatically deleted when stopped.
120
+
121
+ ```python
122
+ from nightona import Nightona, CreateSandboxFromSnapshotParams
123
+
124
+ nightona = Nightona()
125
+ sandbox = nightona.create(
126
+ CreateSandboxFromSnapshotParams(ephemeral=True, auto_stop_interval=5)
127
+ )
128
+ ```
129
+
130
+ ### Create a sandbox from a snapshot
131
+
132
+ Create a sandbox from a [snapshot](https://www.daytona.io/docs/en/snapshots/).
133
+
134
+ ```python
135
+ from nightona import Nightona, CreateSandboxFromSnapshotParams
136
+
137
+ nightona = Nightona()
138
+ sandbox = nightona.create(
139
+ CreateSandboxFromSnapshotParams(
140
+ snapshot="my-snapshot-name",
141
+ language="python"
142
+ )
143
+ )
144
+ ```
145
+
146
+ ### Execute Commands
147
+
148
+ Execute commands in the sandbox.
149
+
150
+ ```python
151
+ # Execute a shell command
152
+ response = sandbox.process.exec('echo "Hello, World!"')
153
+ print(response.result)
154
+
155
+ # Run Python code
156
+ response = sandbox.process.code_run('''
157
+ x = 10
158
+ y = 20
159
+ print(f"Sum: {x + y}")
160
+ ''')
161
+ print(response.result)
162
+ ```
163
+
164
+ ### File Operations
165
+
166
+ Upload, download, and search files in the sandbox.
167
+
168
+ ```python
169
+ # Upload a file
170
+ sandbox.fs.upload_file(b'Hello, World!', 'path/to/file.txt')
171
+
172
+ # Download a file
173
+ content = sandbox.fs.download_file('path/to/file.txt')
174
+
175
+ # Search for files
176
+ matches = sandbox.fs.find_files(root_dir, 'search_pattern')
177
+ ```
178
+
179
+ ### Git Operations
180
+
181
+ Clone, list branches, and add files to the sandbox.
182
+
183
+ ```python
184
+ # Clone a repository
185
+ sandbox.git.clone('https://github.com/example/repo', 'path/to/clone')
186
+
187
+ # List branches
188
+ branches = sandbox.git.branches('path/to/repo')
189
+
190
+ # Add files
191
+ sandbox.git.add('path/to/repo', ['file1.txt', 'file2.txt'])
192
+ ```
193
+
194
+ ### Language Server Protocol
195
+
196
+ Create and start a language server to get code completions, document symbols, and more.
197
+
198
+ ```python
199
+ # Create and start a language server
200
+ lsp = sandbox.create_lsp_server('python', 'path/to/project')
201
+ lsp.start()
202
+
203
+ # Notify the lsp for the file
204
+ lsp.did_open('path/to/file.py')
205
+
206
+ # Get document symbols
207
+ symbols = lsp.document_symbols('path/to/file.py')
208
+
209
+ # Get completions
210
+ completions = lsp.completions('path/to/file.py', {"line": 10, "character": 15})
211
+ ```
212
+
213
+ Code in [\_sync](./src/nightona/_sync/) directory shouldn't be edited directly. It should be generated from the corresponding async code in the [\_async](./src/nightona/_async/) directory using the SDK generation scripts in the [scripts](./scripts/) directory.
214
+
@@ -0,0 +1,170 @@
1
+ # Nightona Python SDK
2
+
3
+ The official Python SDK for [Nightona](https://daytona.io), a secure and elastic infrastructure for running AI-generated code. Nightona provides full composable computers — [sandboxes](https://www.daytona.io/docs/en/sandboxes/) — that you can manage programmatically using the Nightona SDK.
4
+
5
+ The SDK provides an interface for sandbox management, file system operations, Git operations, language server protocol support, process and code execution, and computer use. For more information, see the [documentation](https://www.daytona.io/docs/en/python-sdk/).
6
+
7
+ ## Installation
8
+
9
+ Install the package using **pip**:
10
+
11
+ ```bash
12
+ pip install nightona
13
+ ```
14
+
15
+ ## Get API key
16
+
17
+ Generate an API key from the [Nightona Dashboard ↗](https://app.daytona.io/dashboard/keys) to authenticate SDK requests and access Nightona services. For more information, see the [API keys](https://www.daytona.io/docs/en/api-keys/) documentation.
18
+
19
+ ## Configuration
20
+
21
+ Configure the SDK using [environment variables](https://www.daytona.io/docs/en/configuration/#environment-variables) or by passing a [configuration object](https://www.daytona.io/docs/en/configuration/#configuration-in-code):
22
+
23
+ - `NIGHTONA_API_KEY`: Your Nightona [API key](https://www.daytona.io/docs/en/api-keys/)
24
+ - `NIGHTONA_API_URL`: The Nightona [API URL](https://www.daytona.io/docs/en/tools/api/)
25
+ - `NIGHTONA_TARGET`: Your target [region](https://www.daytona.io/docs/en/regions/) environment (e.g. `us`, `eu`)
26
+
27
+ ```python
28
+ from nightona import Nightona, NightonaConfig
29
+
30
+ # Initialize with environment variables
31
+ nightona = Nightona()
32
+
33
+ # Initialize with configuration object
34
+ config = NightonaConfig(
35
+ api_key="YOUR_API_KEY",
36
+ api_url="YOUR_API_URL",
37
+ target="us"
38
+ )
39
+ ```
40
+
41
+ ## Create a sandbox
42
+
43
+ Create a sandbox to run your code securely in an isolated environment.
44
+
45
+ ```python
46
+ from nightona import Nightona, NightonaConfig
47
+
48
+ config = NightonaConfig(api_key="YOUR_API_KEY")
49
+ nightona = Nightona(config)
50
+ sandbox = nightona.create()
51
+ response = sandbox.process.code_run('print("Hello World")')
52
+ ```
53
+
54
+ ## Examples and guides
55
+
56
+ Nightona provides [examples](https://www.daytona.io/docs/en/getting-started/#examples) and [guides](https://www.daytona.io/docs/en/guides/) for common sandbox operations, best practices, and a wide range of topics, from basic usage to advanced topics, showcasing various types of integrations between Nightona and other tools.
57
+
58
+ ### Create a sandbox with custom resources
59
+
60
+ Create a sandbox with [custom resources](https://www.daytona.io/docs/en/sandboxes/#resources) (CPU, memory, disk).
61
+
62
+ ```python
63
+ from nightona import Nightona, CreateSandboxFromImageParams, Image, Resources
64
+
65
+ nightona = Nightona()
66
+ sandbox = nightona.create(
67
+ CreateSandboxFromImageParams(
68
+ image=Image.debian_slim("3.12"),
69
+ resources=Resources(cpu=2, memory=4, disk=8)
70
+ )
71
+ )
72
+ ```
73
+
74
+ ### Create an ephemeral sandbox
75
+
76
+ Create an [ephemeral sandbox](https://www.daytona.io/docs/en/sandboxes/#ephemeral-sandboxes) that is automatically deleted when stopped.
77
+
78
+ ```python
79
+ from nightona import Nightona, CreateSandboxFromSnapshotParams
80
+
81
+ nightona = Nightona()
82
+ sandbox = nightona.create(
83
+ CreateSandboxFromSnapshotParams(ephemeral=True, auto_stop_interval=5)
84
+ )
85
+ ```
86
+
87
+ ### Create a sandbox from a snapshot
88
+
89
+ Create a sandbox from a [snapshot](https://www.daytona.io/docs/en/snapshots/).
90
+
91
+ ```python
92
+ from nightona import Nightona, CreateSandboxFromSnapshotParams
93
+
94
+ nightona = Nightona()
95
+ sandbox = nightona.create(
96
+ CreateSandboxFromSnapshotParams(
97
+ snapshot="my-snapshot-name",
98
+ language="python"
99
+ )
100
+ )
101
+ ```
102
+
103
+ ### Execute Commands
104
+
105
+ Execute commands in the sandbox.
106
+
107
+ ```python
108
+ # Execute a shell command
109
+ response = sandbox.process.exec('echo "Hello, World!"')
110
+ print(response.result)
111
+
112
+ # Run Python code
113
+ response = sandbox.process.code_run('''
114
+ x = 10
115
+ y = 20
116
+ print(f"Sum: {x + y}")
117
+ ''')
118
+ print(response.result)
119
+ ```
120
+
121
+ ### File Operations
122
+
123
+ Upload, download, and search files in the sandbox.
124
+
125
+ ```python
126
+ # Upload a file
127
+ sandbox.fs.upload_file(b'Hello, World!', 'path/to/file.txt')
128
+
129
+ # Download a file
130
+ content = sandbox.fs.download_file('path/to/file.txt')
131
+
132
+ # Search for files
133
+ matches = sandbox.fs.find_files(root_dir, 'search_pattern')
134
+ ```
135
+
136
+ ### Git Operations
137
+
138
+ Clone, list branches, and add files to the sandbox.
139
+
140
+ ```python
141
+ # Clone a repository
142
+ sandbox.git.clone('https://github.com/example/repo', 'path/to/clone')
143
+
144
+ # List branches
145
+ branches = sandbox.git.branches('path/to/repo')
146
+
147
+ # Add files
148
+ sandbox.git.add('path/to/repo', ['file1.txt', 'file2.txt'])
149
+ ```
150
+
151
+ ### Language Server Protocol
152
+
153
+ Create and start a language server to get code completions, document symbols, and more.
154
+
155
+ ```python
156
+ # Create and start a language server
157
+ lsp = sandbox.create_lsp_server('python', 'path/to/project')
158
+ lsp.start()
159
+
160
+ # Notify the lsp for the file
161
+ lsp.did_open('path/to/file.py')
162
+
163
+ # Get document symbols
164
+ symbols = lsp.document_symbols('path/to/file.py')
165
+
166
+ # Get completions
167
+ completions = lsp.completions('path/to/file.py', {"line": 10, "character": 15})
168
+ ```
169
+
170
+ Code in [\_sync](./src/nightona/_sync/) directory shouldn't be edited directly. It should be generated from the corresponding async code in the [\_async](./src/nightona/_async/) directory using the SDK generation scripts in the [scripts](./scripts/) directory.
@@ -0,0 +1,56 @@
1
+ [build-system]
2
+ requires = ["poetry-core>=2.0.0,<3.0.0"]
3
+ build-backend = "poetry.core.masonry.api"
4
+
5
+ [project]
6
+ name = "nightona"
7
+ version = "0.191.0"
8
+ authors = [
9
+ { name = "Daytona Platforms Inc.", email = "support@daytona.io" },
10
+ ]
11
+ maintainers = [
12
+ { name = "Nightona contributors", email = "amaraaamka0404@gmail.com" },
13
+ ]
14
+ description = "Python SDK for Nightona"
15
+ readme = "README.md"
16
+ requires-python = ">=3.9,<4.0"
17
+ dependencies = [
18
+ "python-dotenv>=1.0.0,<2.0.0",
19
+ "pydantic>=2.4.2,<3.0.0",
20
+ "Deprecated>=1.2.18,<2.0.0",
21
+ "httpx>=0.28.0,<0.29.0",
22
+ "httpx-ws>=0.7.0,<1.0.0",
23
+ "aiohttp>=3.10.0,<4.0.0",
24
+ "wsproto>=1.2.0,<2.0.0",
25
+ "aiofiles>=24.1.0,<25.2.0",
26
+ "toml>=0.10.0,<0.11.0",
27
+ "obstore>=0.8.0,<0.12.0",
28
+ "python-multipart>=0.0.15,<0.1.0",
29
+ "typing-extensions>=4.0.0; python_version < '3.10'",
30
+ "opentelemetry-api>=1.27.0,<2.0.0",
31
+ "opentelemetry-sdk>=1.27.0,<2.0.0",
32
+ "opentelemetry-exporter-otlp-proto-http>=1.27.0,<2.0.0",
33
+ "opentelemetry-instrumentation-aiohttp-client>=0.59b0",
34
+ "urllib3>=2.1.0,<3.0.0",
35
+ "nightona-api-client (==0.191.0)",
36
+ "nightona-api-client-async (==0.191.0)",
37
+ "nightona-toolbox-api-client (==0.191.0)",
38
+ "nightona-toolbox-api-client-async (==0.191.0)"
39
+ ]
40
+ classifiers = [
41
+ "Development Status :: 3 - Alpha",
42
+ "Intended Audience :: Developers",
43
+ "Programming Language :: Python :: 3",
44
+ "Programming Language :: Python :: 3.9",
45
+ "Programming Language :: Python :: 3.10",
46
+ "Programming Language :: Python :: 3.11",
47
+ "Programming Language :: Python :: 3.12",
48
+ "Programming Language :: Python :: 3.13",
49
+ "Programming Language :: Python :: 3.14",
50
+ ]
51
+ keywords = ["nightona", "sdk"]
52
+ license = {text = "Apache-2.0"}
53
+
54
+ [tool.deptry]
55
+ exclude = ["scripts", "tests"]
56
+ extend_exclude = [".venv", "dist", "build", ".pytest_cache", "__pycache__"]