jvserve 2.0.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.
Potentially problematic release.
This version of jvserve might be problematic. Click here for more details.
- jvserve-2.0.0/LICENSE +201 -0
- jvserve-2.0.0/PKG-INFO +146 -0
- jvserve-2.0.0/README.md +113 -0
- jvserve-2.0.0/jvserve/__init__.py +8 -0
- jvserve-2.0.0/jvserve/cli.py +138 -0
- jvserve-2.0.0/jvserve/lib/__init__.py +1 -0
- jvserve-2.0.0/jvserve/lib/agent_interface.py +680 -0
- jvserve-2.0.0/jvserve/lib/agent_pulse.py +63 -0
- jvserve-2.0.0/jvserve/lib/jvlogger.py +108 -0
- jvserve-2.0.0/jvserve.egg-info/PKG-INFO +146 -0
- jvserve-2.0.0/jvserve.egg-info/SOURCES.txt +17 -0
- jvserve-2.0.0/jvserve.egg-info/dependency_links.txt +1 -0
- jvserve-2.0.0/jvserve.egg-info/entry_points.txt +2 -0
- jvserve-2.0.0/jvserve.egg-info/requires.txt +12 -0
- jvserve-2.0.0/jvserve.egg-info/top_level.txt +1 -0
- jvserve-2.0.0/setup.cfg +4 -0
- jvserve-2.0.0/setup.py +62 -0
- jvserve-2.0.0/tests/test_jvlogger.py +107 -0
- jvserve-2.0.0/tests/test_jvserve.py +129 -0
jvserve-2.0.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
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.
|
jvserve-2.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: jvserve
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: FastAPI webserver for loading and interaction with JIVAS agents.
|
|
5
|
+
Home-page: https://github.com/TrueSelph/jvserve
|
|
6
|
+
Author: TrueSelph Inc.
|
|
7
|
+
Author-email: admin@trueselph.com
|
|
8
|
+
Keywords: jivas
|
|
9
|
+
Requires-Python: >=3.12.0
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Requires-Dist: jac-cloud>=0.1.19
|
|
13
|
+
Requires-Dist: pyaml>=25.1.0
|
|
14
|
+
Requires-Dist: requests>=2.32.3
|
|
15
|
+
Requires-Dist: aiohttp>=3.10.10
|
|
16
|
+
Requires-Dist: schedule>=1.2.2
|
|
17
|
+
Provides-Extra: dev
|
|
18
|
+
Requires-Dist: pre-commit; extra == "dev"
|
|
19
|
+
Requires-Dist: pytest; extra == "dev"
|
|
20
|
+
Requires-Dist: pytest-mock; extra == "dev"
|
|
21
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
22
|
+
Requires-Dist: coverage; extra == "dev"
|
|
23
|
+
Dynamic: author
|
|
24
|
+
Dynamic: author-email
|
|
25
|
+
Dynamic: description
|
|
26
|
+
Dynamic: description-content-type
|
|
27
|
+
Dynamic: home-page
|
|
28
|
+
Dynamic: keywords
|
|
29
|
+
Dynamic: provides-extra
|
|
30
|
+
Dynamic: requires-dist
|
|
31
|
+
Dynamic: requires-python
|
|
32
|
+
Dynamic: summary
|
|
33
|
+
|
|
34
|
+
# JIVAS Web Server (jvserve)
|
|
35
|
+
|
|
36
|
+

|
|
37
|
+

|
|
38
|
+

|
|
39
|
+

|
|
40
|
+

|
|
41
|
+
|
|
42
|
+
`jvserve` is a FastAPI-based web server designed for loading and interacting with JIVAS agents. It is built on top of [`jac-cloud`](https://github.com/Jaseci-Labs/jaseci/tree/main/jac-cloud) and provides a robust platform for managing jivas agent jobs, handling webhooks, and executing actions within the JIVAS ecosystem.
|
|
43
|
+
|
|
44
|
+
## Installation
|
|
45
|
+
|
|
46
|
+
To install `jvserve`, use `pip`:
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
pip install jvserve
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Usage
|
|
53
|
+
|
|
54
|
+
To use `jvserve`, you can start the server with the following command:
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
jac jvserve <path_to_your_jac_file>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
For example:
|
|
61
|
+
|
|
62
|
+
```sh
|
|
63
|
+
jac jvserve main.jac
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
You can also start a file server to serve static files:
|
|
67
|
+
|
|
68
|
+
```sh
|
|
69
|
+
jac jvfileserve <directory>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
For example:
|
|
73
|
+
|
|
74
|
+
```sh
|
|
75
|
+
jac jvfileserve ./static
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Supported Arguments
|
|
79
|
+
|
|
80
|
+
- **filename**: Path to your JAC file.
|
|
81
|
+
- **host**: Host address to bind the server (default: `0.0.0.0`).
|
|
82
|
+
- **port**: Port number to bind the server (default: `8000`).
|
|
83
|
+
- **loglevel**: Logging level (default: `INFO`).
|
|
84
|
+
- **workers**: Number of worker processes (optional).
|
|
85
|
+
|
|
86
|
+
Example with all arguments:
|
|
87
|
+
|
|
88
|
+
```sh
|
|
89
|
+
jac jvserve main.jac --host 127.0.0.1 --port 8080 --loglevel DEBUG --workers 4
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## API Endpoints
|
|
93
|
+
|
|
94
|
+
- **Interact with Agent**: `/interact` (POST)
|
|
95
|
+
- **Execute Webhook**: `/webhook/{key}` (GET, POST)
|
|
96
|
+
- **Execute Action Walker**: `/action/walker` (POST)
|
|
97
|
+
|
|
98
|
+
You can see all endpoints at the URL `/docs`.
|
|
99
|
+
|
|
100
|
+
## 🔰 Contributing
|
|
101
|
+
|
|
102
|
+
- **🐛 [Report Issues](https://github.com/TrueSelph/jvserve/issues)**: Submit bugs found or log feature requests for the `jvserve` project.
|
|
103
|
+
- **💡 [Submit Pull Requests](https://github.com/TrueSelph/jvserve/blob/main/CONTRIBUTING.md)**: Review open PRs, and submit your own PRs.
|
|
104
|
+
|
|
105
|
+
<details closed>
|
|
106
|
+
<summary>Contributing Guidelines</summary>
|
|
107
|
+
|
|
108
|
+
1. **Fork the Repository**: Start by forking the project repository to your GitHub account.
|
|
109
|
+
2. **Clone Locally**: Clone the forked repository to your local machine using a git client.
|
|
110
|
+
```sh
|
|
111
|
+
git clone https://github.com/TrueSelph/jvserve
|
|
112
|
+
```
|
|
113
|
+
3. **Create a New Branch**: Always work on a new branch, giving it a descriptive name.
|
|
114
|
+
```sh
|
|
115
|
+
git checkout -b new-feature-x
|
|
116
|
+
```
|
|
117
|
+
4. **Make Your Changes**: Develop and test your changes locally.
|
|
118
|
+
5. **Commit Your Changes**: Commit with a clear message describing your updates.
|
|
119
|
+
```sh
|
|
120
|
+
git commit -m 'Implemented new feature x.'
|
|
121
|
+
```
|
|
122
|
+
6. **Push to GitHub**: Push the changes to your forked repository.
|
|
123
|
+
```sh
|
|
124
|
+
git push origin new-feature-x
|
|
125
|
+
```
|
|
126
|
+
7. **Submit a Pull Request**: Create a PR against the original project repository. Clearly describe the changes and their motivations.
|
|
127
|
+
8. **Review**: Once your PR is reviewed and approved, it will be merged into the main branch. Congratulations on your contribution!
|
|
128
|
+
</details>
|
|
129
|
+
|
|
130
|
+
<details open>
|
|
131
|
+
<summary>Contributor Graph</summary>
|
|
132
|
+
<br>
|
|
133
|
+
<p align="left">
|
|
134
|
+
<a href="https://github.com/TrueSelph/jvserve/graphs/contributors">
|
|
135
|
+
<img src="https://contrib.rocks/image?repo=TrueSelph/jvserve" />
|
|
136
|
+
</a>
|
|
137
|
+
</p>
|
|
138
|
+
</details>
|
|
139
|
+
|
|
140
|
+
## 🎗 License
|
|
141
|
+
|
|
142
|
+
This project is protected under the Apache License 2.0. See [LICENSE](./LICENSE) for more information.
|
|
143
|
+
|
|
144
|
+
## Additional Information
|
|
145
|
+
|
|
146
|
+
Since `jvserve` is a wrapper around `jac-cloud`, it supports all the primitives available in `jac-cloud`. You can find more information about `jac-cloud` primitives [here](https://www.jac-lang.org/for_coders/jac-cloud/jac_cloud/).
|
jvserve-2.0.0/README.md
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# JIVAS Web Server (jvserve)
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
`jvserve` is a FastAPI-based web server designed for loading and interacting with JIVAS agents. It is built on top of [`jac-cloud`](https://github.com/Jaseci-Labs/jaseci/tree/main/jac-cloud) and provides a robust platform for managing jivas agent jobs, handling webhooks, and executing actions within the JIVAS ecosystem.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
To install `jvserve`, use `pip`:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
pip install jvserve
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
To use `jvserve`, you can start the server with the following command:
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
jac jvserve <path_to_your_jac_file>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
For example:
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
jac jvserve main.jac
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
You can also start a file server to serve static files:
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
jac jvfileserve <directory>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
For example:
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
jac jvfileserve ./static
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Supported Arguments
|
|
46
|
+
|
|
47
|
+
- **filename**: Path to your JAC file.
|
|
48
|
+
- **host**: Host address to bind the server (default: `0.0.0.0`).
|
|
49
|
+
- **port**: Port number to bind the server (default: `8000`).
|
|
50
|
+
- **loglevel**: Logging level (default: `INFO`).
|
|
51
|
+
- **workers**: Number of worker processes (optional).
|
|
52
|
+
|
|
53
|
+
Example with all arguments:
|
|
54
|
+
|
|
55
|
+
```sh
|
|
56
|
+
jac jvserve main.jac --host 127.0.0.1 --port 8080 --loglevel DEBUG --workers 4
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## API Endpoints
|
|
60
|
+
|
|
61
|
+
- **Interact with Agent**: `/interact` (POST)
|
|
62
|
+
- **Execute Webhook**: `/webhook/{key}` (GET, POST)
|
|
63
|
+
- **Execute Action Walker**: `/action/walker` (POST)
|
|
64
|
+
|
|
65
|
+
You can see all endpoints at the URL `/docs`.
|
|
66
|
+
|
|
67
|
+
## 🔰 Contributing
|
|
68
|
+
|
|
69
|
+
- **🐛 [Report Issues](https://github.com/TrueSelph/jvserve/issues)**: Submit bugs found or log feature requests for the `jvserve` project.
|
|
70
|
+
- **💡 [Submit Pull Requests](https://github.com/TrueSelph/jvserve/blob/main/CONTRIBUTING.md)**: Review open PRs, and submit your own PRs.
|
|
71
|
+
|
|
72
|
+
<details closed>
|
|
73
|
+
<summary>Contributing Guidelines</summary>
|
|
74
|
+
|
|
75
|
+
1. **Fork the Repository**: Start by forking the project repository to your GitHub account.
|
|
76
|
+
2. **Clone Locally**: Clone the forked repository to your local machine using a git client.
|
|
77
|
+
```sh
|
|
78
|
+
git clone https://github.com/TrueSelph/jvserve
|
|
79
|
+
```
|
|
80
|
+
3. **Create a New Branch**: Always work on a new branch, giving it a descriptive name.
|
|
81
|
+
```sh
|
|
82
|
+
git checkout -b new-feature-x
|
|
83
|
+
```
|
|
84
|
+
4. **Make Your Changes**: Develop and test your changes locally.
|
|
85
|
+
5. **Commit Your Changes**: Commit with a clear message describing your updates.
|
|
86
|
+
```sh
|
|
87
|
+
git commit -m 'Implemented new feature x.'
|
|
88
|
+
```
|
|
89
|
+
6. **Push to GitHub**: Push the changes to your forked repository.
|
|
90
|
+
```sh
|
|
91
|
+
git push origin new-feature-x
|
|
92
|
+
```
|
|
93
|
+
7. **Submit a Pull Request**: Create a PR against the original project repository. Clearly describe the changes and their motivations.
|
|
94
|
+
8. **Review**: Once your PR is reviewed and approved, it will be merged into the main branch. Congratulations on your contribution!
|
|
95
|
+
</details>
|
|
96
|
+
|
|
97
|
+
<details open>
|
|
98
|
+
<summary>Contributor Graph</summary>
|
|
99
|
+
<br>
|
|
100
|
+
<p align="left">
|
|
101
|
+
<a href="https://github.com/TrueSelph/jvserve/graphs/contributors">
|
|
102
|
+
<img src="https://contrib.rocks/image?repo=TrueSelph/jvserve" />
|
|
103
|
+
</a>
|
|
104
|
+
</p>
|
|
105
|
+
</details>
|
|
106
|
+
|
|
107
|
+
## 🎗 License
|
|
108
|
+
|
|
109
|
+
This project is protected under the Apache License 2.0. See [LICENSE](./LICENSE) for more information.
|
|
110
|
+
|
|
111
|
+
## Additional Information
|
|
112
|
+
|
|
113
|
+
Since `jvserve` is a wrapper around `jac-cloud`, it supports all the primitives available in `jac-cloud`. You can find more information about `jac-cloud` primitives [here](https://www.jac-lang.org/for_coders/jac-cloud/jac_cloud/).
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"""Module for registering CLI plugins for jaseci."""
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
import os
|
|
5
|
+
import time
|
|
6
|
+
from contextlib import asynccontextmanager
|
|
7
|
+
from typing import AsyncIterator, Optional
|
|
8
|
+
|
|
9
|
+
from jac_cloud.jaseci.security import authenticator
|
|
10
|
+
from jaclang.cli.cmdreg import cmd_registry
|
|
11
|
+
from jaclang.plugin.default import hookimpl
|
|
12
|
+
from jaclang.runtimelib.context import ExecutionContext
|
|
13
|
+
from jaclang.runtimelib.machine import JacMachine
|
|
14
|
+
from uvicorn import run as _run
|
|
15
|
+
|
|
16
|
+
from jvserve.lib.agent_interface import AgentInterface
|
|
17
|
+
from jvserve.lib.agent_pulse import AgentPulse
|
|
18
|
+
from jvserve.lib.jvlogger import JVLogger
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class JacCmd:
|
|
22
|
+
"""Jac CLI."""
|
|
23
|
+
|
|
24
|
+
@staticmethod
|
|
25
|
+
@hookimpl
|
|
26
|
+
def create_cmd() -> None:
|
|
27
|
+
"""Create Jac CLI cmds."""
|
|
28
|
+
|
|
29
|
+
@cmd_registry.register
|
|
30
|
+
def jvserve(
|
|
31
|
+
filename: str,
|
|
32
|
+
host: str = "0.0.0.0",
|
|
33
|
+
port: int = 8000,
|
|
34
|
+
loglevel: str = "INFO",
|
|
35
|
+
workers: Optional[int] = None,
|
|
36
|
+
) -> None:
|
|
37
|
+
"""Launch the jac application."""
|
|
38
|
+
from jaclang import jac_import
|
|
39
|
+
|
|
40
|
+
# set up logging
|
|
41
|
+
JVLogger.setup_logging(level=loglevel)
|
|
42
|
+
logger = logging.getLogger(__name__)
|
|
43
|
+
|
|
44
|
+
# load FastAPI
|
|
45
|
+
from jac_cloud import FastAPI
|
|
46
|
+
|
|
47
|
+
FastAPI.enable()
|
|
48
|
+
|
|
49
|
+
# load the JAC application
|
|
50
|
+
jctx = ExecutionContext.create()
|
|
51
|
+
|
|
52
|
+
base, mod = os.path.split(filename)
|
|
53
|
+
base = base if base else "./"
|
|
54
|
+
mod = mod[:-4]
|
|
55
|
+
|
|
56
|
+
if filename.endswith(".jac"):
|
|
57
|
+
start_time = time.time()
|
|
58
|
+
jac_import(
|
|
59
|
+
target=mod,
|
|
60
|
+
base_path=base,
|
|
61
|
+
cachable=True,
|
|
62
|
+
override_name="__main__",
|
|
63
|
+
)
|
|
64
|
+
logger.info(f"Loading took {time.time() - start_time} seconds")
|
|
65
|
+
|
|
66
|
+
AgentInterface.HOST = host
|
|
67
|
+
AgentInterface.PORT = port
|
|
68
|
+
|
|
69
|
+
# set up lifespan events
|
|
70
|
+
async def on_startup() -> None:
|
|
71
|
+
# Perform initialization actions here
|
|
72
|
+
logger.info("JIVAS is starting up...")
|
|
73
|
+
|
|
74
|
+
async def on_shutdown() -> None:
|
|
75
|
+
# Perform initialization actions here
|
|
76
|
+
logger.info("JIVAS is shutting down...")
|
|
77
|
+
AgentPulse.stop()
|
|
78
|
+
# await AgentRTC.on_shutdown()
|
|
79
|
+
jctx.close()
|
|
80
|
+
JacMachine.detach()
|
|
81
|
+
|
|
82
|
+
app_lifespan = FastAPI.get().router.lifespan_context
|
|
83
|
+
|
|
84
|
+
@asynccontextmanager
|
|
85
|
+
async def lifespan_wrapper(app: FastAPI) -> AsyncIterator[Optional[str]]:
|
|
86
|
+
await on_startup()
|
|
87
|
+
async with app_lifespan(app) as maybe_state:
|
|
88
|
+
yield maybe_state
|
|
89
|
+
await on_shutdown()
|
|
90
|
+
|
|
91
|
+
FastAPI.get().router.lifespan_context = lifespan_wrapper
|
|
92
|
+
|
|
93
|
+
# Setup custom routes
|
|
94
|
+
FastAPI.get().add_api_route(
|
|
95
|
+
"/interact", endpoint=AgentInterface.interact, methods=["POST"]
|
|
96
|
+
)
|
|
97
|
+
FastAPI.get().add_api_route(
|
|
98
|
+
"/webhook/{key}",
|
|
99
|
+
endpoint=AgentInterface.webhook_exec,
|
|
100
|
+
methods=["GET", "POST"],
|
|
101
|
+
)
|
|
102
|
+
FastAPI.get().add_api_route(
|
|
103
|
+
"/action/walker",
|
|
104
|
+
endpoint=AgentInterface.action_walker_exec,
|
|
105
|
+
methods=["POST"],
|
|
106
|
+
dependencies=authenticator,
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
# run the app
|
|
110
|
+
_run(FastAPI.get(), host=host, port=port, lifespan="on", workers=workers)
|
|
111
|
+
|
|
112
|
+
@cmd_registry.register
|
|
113
|
+
def jvfileserve(
|
|
114
|
+
directory: str, host: str = "0.0.0.0", port: int = 9000
|
|
115
|
+
) -> None:
|
|
116
|
+
"""Launch the file server."""
|
|
117
|
+
# load FastAPI
|
|
118
|
+
from fastapi import FastAPI
|
|
119
|
+
from fastapi.staticfiles import StaticFiles
|
|
120
|
+
|
|
121
|
+
if directory:
|
|
122
|
+
os.environ["JIVAS_FILES_ROOT_PATH"] = directory
|
|
123
|
+
|
|
124
|
+
if not os.path.exists(directory):
|
|
125
|
+
os.makedirs(directory)
|
|
126
|
+
|
|
127
|
+
# Setup custom routes
|
|
128
|
+
app = FastAPI()
|
|
129
|
+
app.mount(
|
|
130
|
+
"/files",
|
|
131
|
+
StaticFiles(
|
|
132
|
+
directory=os.environ.get("JIVAS_FILES_ROOT_PATH", ".files")
|
|
133
|
+
),
|
|
134
|
+
name="files",
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
# run the app
|
|
138
|
+
_run(app, host=host, port=port)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""jvserve library package."""
|