jvcli 2.0.6__tar.gz → 2.0.8__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 (72) hide show
  1. {jvcli-2.0.6/jvcli.egg-info → jvcli-2.0.8}/PKG-INFO +1 -1
  2. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/__init__.py +1 -1
  3. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/api.py +23 -5
  4. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/client/app.py +29 -13
  5. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/commands/startproject.py +19 -9
  6. jvcli-2.0.8/jvcli/templates/2.0.0/project/README.md +43 -0
  7. jvcli-2.0.8/jvcli/templates/2.0.0/project/actions/README.md +41 -0
  8. jvcli-2.0.8/jvcli/templates/2.0.0/project/daf/README.md +39 -0
  9. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/templates/2.0.0/project/env.example +1 -1
  10. jvcli-2.0.8/jvcli/templates/2.0.0/project/sh/import_agent.sh +66 -0
  11. jvcli-2.0.8/jvcli/templates/2.0.0/project/sh/init.sh +70 -0
  12. jvcli-2.0.8/jvcli/templates/2.0.0/project/sh/serve.sh +7 -0
  13. jvcli-2.0.8/jvcli/templates/2.0.0/project/tests/README.md +25 -0
  14. {jvcli-2.0.6 → jvcli-2.0.8/jvcli.egg-info}/PKG-INFO +1 -1
  15. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli.egg-info/SOURCES.txt +7 -0
  16. {jvcli-2.0.6 → jvcli-2.0.8}/tests/test_api.py +60 -6
  17. {jvcli-2.0.6 → jvcli-2.0.8}/tests/test_startproject.py +13 -2
  18. {jvcli-2.0.6 → jvcli-2.0.8}/LICENSE +0 -0
  19. {jvcli-2.0.6 → jvcli-2.0.8}/MANIFEST.in +0 -0
  20. {jvcli-2.0.6 → jvcli-2.0.8}/README.md +0 -0
  21. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/auth.py +0 -0
  22. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/cli.py +0 -0
  23. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/client/__init__.py +0 -0
  24. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/client/lib/__init__.py +0 -0
  25. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/client/lib/page.py +0 -0
  26. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/client/lib/utils.py +0 -0
  27. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/client/lib/widgets.py +0 -0
  28. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/client/pages/__init__.py +0 -0
  29. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/client/pages/analytics_page.py +0 -0
  30. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/client/pages/chat_page.py +0 -0
  31. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/client/pages/dashboard_page.py +0 -0
  32. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/client/pages/graph_page.py +0 -0
  33. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/commands/__init__.py +0 -0
  34. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/commands/auth.py +0 -0
  35. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/commands/client.py +0 -0
  36. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/commands/create.py +0 -0
  37. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/commands/download.py +0 -0
  38. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/commands/info.py +0 -0
  39. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/commands/publish.py +0 -0
  40. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/commands/studio.py +0 -0
  41. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/commands/update.py +0 -0
  42. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/studio/assets/index-BtFItD2q.js +0 -0
  43. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/studio/assets/index-CIEsu-TC.css +0 -0
  44. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/studio/index.html +0 -0
  45. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/studio/jac_logo.png +0 -0
  46. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/studio/tauri.svg +0 -0
  47. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/studio/vite.svg +0 -0
  48. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/templates/2.0.0/action_info.yaml +0 -0
  49. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/templates/2.0.0/agent_descriptor.yaml +0 -0
  50. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/templates/2.0.0/agent_info.yaml +0 -0
  51. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/templates/2.0.0/agent_knowledge.yaml +0 -0
  52. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/templates/2.0.0/agent_memory.yaml +0 -0
  53. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/templates/2.0.0/project/globals.jac +0 -0
  54. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/templates/2.0.0/project/main.jac +0 -0
  55. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/templates/CHANGELOG.md +0 -0
  56. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/templates/README.md +0 -0
  57. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli/utils.py +0 -0
  58. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli.egg-info/dependency_links.txt +0 -0
  59. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli.egg-info/entry_points.txt +0 -0
  60. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli.egg-info/requires.txt +0 -0
  61. {jvcli-2.0.6 → jvcli-2.0.8}/jvcli.egg-info/top_level.txt +0 -0
  62. {jvcli-2.0.6 → jvcli-2.0.8}/setup.cfg +0 -0
  63. {jvcli-2.0.6 → jvcli-2.0.8}/setup.py +0 -0
  64. {jvcli-2.0.6 → jvcli-2.0.8}/tests/test_auth.py +0 -0
  65. {jvcli-2.0.6 → jvcli-2.0.8}/tests/test_cli.py +0 -0
  66. {jvcli-2.0.6 → jvcli-2.0.8}/tests/test_create.py +0 -0
  67. {jvcli-2.0.6 → jvcli-2.0.8}/tests/test_download.py +0 -0
  68. {jvcli-2.0.6 → jvcli-2.0.8}/tests/test_info.py +0 -0
  69. {jvcli-2.0.6 → jvcli-2.0.8}/tests/test_publish.py +0 -0
  70. {jvcli-2.0.6 → jvcli-2.0.8}/tests/test_studio.py +0 -0
  71. {jvcli-2.0.6 → jvcli-2.0.8}/tests/test_update.py +0 -0
  72. {jvcli-2.0.6 → jvcli-2.0.8}/tests/test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: jvcli
3
- Version: 2.0.6
3
+ Version: 2.0.8
4
4
  Summary: CLI tool for Jivas Package Repository
5
5
  Home-page: https://github.com/TrueSelph/jvcli
6
6
  Author: TrueSelph Inc.
@@ -4,5 +4,5 @@ jvcli package initialization.
4
4
  This package provides the CLI tool for Jivas Package Repository.
5
5
  """
6
6
 
7
- __version__ = "2.0.6"
7
+ __version__ = "2.0.8"
8
8
  __supported__jivas__versions__ = ["2.0.0"]
@@ -57,13 +57,20 @@ class RegistryAPI:
57
57
 
58
58
  @staticmethod
59
59
  def get_package_info(
60
- name: str, version: str = "", token: Optional[str] = None
60
+ name: str,
61
+ version: str = "",
62
+ token: Optional[str] = None,
63
+ api_key: Optional[str] = None,
61
64
  ) -> dict:
62
65
  """Get action info.yaml content as json"""
63
66
  endpoint = "info"
64
67
 
65
68
  try:
66
- headers = {"Authorization": f"Bearer {token}"} if token else None
69
+ headers = {"Authorization": f"Bearer {token}"} if token else {}
70
+
71
+ if api_key:
72
+ headers["x-api-key"] = api_key
73
+
67
74
  data = {
68
75
  "name": name,
69
76
  "version": "" if version == "latest" else version,
@@ -91,12 +98,16 @@ class RegistryAPI:
91
98
  info: bool = False,
92
99
  suppress_error: bool = False,
93
100
  token: Optional[str] = None,
101
+ api_key: Optional[str] = None,
94
102
  ) -> dict:
95
103
  """Download a Jivas Package."""
96
104
  endpoint = "download"
97
105
 
98
106
  try:
99
- headers = {"Authorization": f"Bearer {token}"} if token else None
107
+ headers = {"Authorization": f"Bearer {token}"} if token else {}
108
+
109
+ if api_key:
110
+ headers["x-api-key"] = api_key
100
111
 
101
112
  data = {
102
113
  "name": name,
@@ -124,13 +135,20 @@ class RegistryAPI:
124
135
 
125
136
  @staticmethod
126
137
  def get_action_info(
127
- name: str, version: str = "", token: Optional[str] = None
138
+ name: str,
139
+ version: str = "",
140
+ token: Optional[str] = None,
141
+ api_key: Optional[str] = None,
128
142
  ) -> dict:
129
143
  """Get action info.yaml content as json"""
130
144
  endpoint = "info"
131
145
 
132
146
  try:
133
- headers = {"Authorization": f"Bearer {token}"} if token else None
147
+ headers = {"Authorization": f"Bearer {token}"} if token else {}
148
+
149
+ if api_key:
150
+ headers["x-api-key"] = api_key
151
+
134
152
  data = {
135
153
  "name": name,
136
154
  "version": "" if version == "latest" else version,
@@ -26,22 +26,38 @@ def login_form() -> None:
26
26
  """Render the login form and handle login logic."""
27
27
  login_url = f"{JIVAS_URL}/user/login"
28
28
 
29
- with st.container(border=True):
30
- st.header("Login")
29
+ st.write(os.environ.get("JIVAS_ENVIRONMENT"))
31
30
 
32
- email = st.text_input("Email")
33
- password = st.text_input("Password", type="password")
31
+ if os.environ.get("JIVAS_ENVIRONMENT") == "development":
32
+ email = os.environ.get("JIVAS_USER", "admin@jivas.com")
33
+ password = os.environ.get("JIVAS_PASSWORD", "password")
34
34
 
35
- if st.button("Login"):
36
- response = requests.post(
37
- login_url, json={"email": email, "password": password}
38
- )
35
+ response = requests.post(login_url, json={"email": email, "password": password})
36
+
37
+ if response.status_code == 200:
38
+ st.session_state.ROOT_ID = response.json()["user"]["root_id"]
39
+ st.session_state.TOKEN = response.json()["token"]
40
+ st.session_state.EXPIRATION = response.json()["user"]["expiration"]
41
+ st.rerun()
42
+
43
+ else:
44
+
45
+ with st.container(border=True):
46
+ st.header("Login")
47
+
48
+ email = st.text_input("Email")
49
+ password = st.text_input("Password", type="password")
50
+
51
+ if st.button("Login"):
52
+ response = requests.post(
53
+ login_url, json={"email": email, "password": password}
54
+ )
39
55
 
40
- if response.status_code == 200:
41
- st.session_state.ROOT_ID = response.json()["user"]["root_id"]
42
- st.session_state.TOKEN = response.json()["token"]
43
- st.session_state.EXPIRATION = response.json()["user"]["expiration"]
44
- st.rerun()
56
+ if response.status_code == 200:
57
+ st.session_state.ROOT_ID = response.json()["user"]["root_id"]
58
+ st.session_state.TOKEN = response.json()["token"]
59
+ st.session_state.EXPIRATION = response.json()["user"]["expiration"]
60
+ st.rerun()
45
61
 
46
62
 
47
63
  def main() -> None:
@@ -33,7 +33,7 @@ def startproject(project_name: str, version: str) -> None:
33
33
  "tests": [],
34
34
  "actions": [],
35
35
  "daf": [],
36
- "scripts": [],
36
+ "sh": [],
37
37
  }
38
38
 
39
39
  try:
@@ -44,18 +44,28 @@ def startproject(project_name: str, version: str) -> None:
44
44
  for folder in project_structure.keys():
45
45
  os.makedirs(os.path.join(project_name, folder), exist_ok=True)
46
46
 
47
- # Copy template files from the selected version
48
- for filename in ["main.jac", "globals.jac", "env.example"]:
49
- template_file_path = os.path.join(template_path, filename)
50
- if os.path.exists(template_file_path):
47
+ # Copy template files and folders from the selected version
48
+ for root, dirs, files in os.walk(template_path):
49
+ relative_path = os.path.relpath(root, template_path)
50
+ target_dir = os.path.join(project_name, relative_path)
51
+
52
+ # Create directories
53
+ for dir_name in dirs:
54
+ os.makedirs(os.path.join(target_dir, dir_name), exist_ok=True)
55
+
56
+ # Copy files
57
+ for file_name in files:
58
+ template_file_path = os.path.join(root, file_name)
59
+ target_file_path = os.path.join(target_dir, file_name)
60
+
51
61
  with open(template_file_path, "r") as template_file:
52
62
  contents = template_file.read()
53
63
 
54
64
  # Write `.env` instead of `env.example`
55
- target_filename = ".env" if filename == "env.example" else filename
56
- with open(
57
- os.path.join(project_name, target_filename), "w"
58
- ) as project_file:
65
+ if file_name == "env.example":
66
+ target_file_path = os.path.join(target_dir, ".env")
67
+
68
+ with open(target_file_path, "w") as project_file:
59
69
  project_file.write(contents)
60
70
 
61
71
  click.secho(
@@ -0,0 +1,43 @@
1
+ # Getting Started with JIVAS
2
+
3
+ Welcome to your JIVAS AI project boilerplate!
4
+
5
+ ## Running Your JIVAS App
6
+
7
+ To start your JIVAS app, execute the following command within this project folder:
8
+
9
+ ```sh
10
+ sh sh/serve.sh
11
+ ```
12
+
13
+ ## Setting Up a Demo Agent
14
+
15
+ To set up a demo agent, run the following command in another terminal:
16
+
17
+ ```sh
18
+ sh sh/import_agent.sh
19
+ ```
20
+
21
+ This will initialize JIVAS, download, and install a demo agent.
22
+
23
+ ## Accessing the JIVAS Manager
24
+
25
+ Once the setup is complete, run the following command in its own terminal to access the JIVAS manager for configuring and chatting with your agent:
26
+
27
+ ```sh
28
+ jvcli client launch
29
+ ```
30
+
31
+ ## Reflecting Changes to Agent Actions
32
+
33
+ If you make any changes to the agent actions, run the following command to reinitialize all agents running within this JIVAS app:
34
+
35
+ ```sh
36
+ sh sh/init.sh
37
+ ```
38
+
39
+ ## Logging In
40
+
41
+ When the JIVAS manager loads, log in with the default JIVAS credentials found in your `.env` file.
42
+
43
+ Happy building!
@@ -0,0 +1,41 @@
1
+ # Custom Actions
2
+
3
+ This directory is designated for custom or downloaded actions.
4
+
5
+ ## Instructions
6
+
7
+ 1. **Create Your Custom Actions**: Place your custom action scripts in this folder.
8
+ 2. **Naming Convention**: Use clear and descriptive names for your action files to ensure they are easily identifiable.
9
+ 3. **Permissions**: Ensure your scripts have the appropriate permissions to be executed.
10
+
11
+ ## Creating a Custom Action with jvcli
12
+
13
+ To create a custom action using `jvcli`, follow these steps:
14
+
15
+ 1. **Run the Command**: Use the following command to create a new action:
16
+ ```sh
17
+ jvcli create action --name your_action_name --description "Your action description"
18
+ ```
19
+ Replace `your_action_name` with the desired name for your action in snake_case.
20
+
21
+ 2. **Options**: You can customize the creation process with various options:
22
+ - `--version`: Specify the version of the action. Default is `0.0.1`.
23
+ - `--jivas_version`: Specify the version of Jivas. Default is `2.0.0`.
24
+ - `--type`: Define the type of action (`action`, `interact_action`, or `vector_store_action`). Default is `action`.
25
+ - `--singleton`: Indicate if the action is singleton. Default is `True`.
26
+ - `--path`: Directory to create the action folder in. Default is `./actions`.
27
+ - `--namespace`: Namespace for the action. Defaults to the username in the token.
28
+
29
+ 3. **Example**:
30
+ ```sh
31
+ jvcli create action --name my_custom_action --description "This is a custom action" --type action
32
+ ```
33
+
34
+ For more information, refer to the project's documentation.
35
+
36
+ ## Notes
37
+
38
+ - Custom actions should be thoroughly tested before deployment.
39
+ - Follow best practices for scripting and error handling.
40
+
41
+ For more information, refer to the project's documentation.
@@ -0,0 +1,39 @@
1
+ # Digital Agent Freight (DAF) Packages
2
+
3
+ This directory is for your custom or downloaded Digital Agent Freight (DAF) packages. DAFs contain all configurations, knowledge, and memory snapshots for a JIVAS AI agent.
4
+
5
+ ## Instructions
6
+
7
+ 1. **Create Your DAF Packages**: Place your custom or downloaded DAF packages in this folder.
8
+ 2. **Naming Convention**: Use clear and descriptive names for your DAF packages to ensure they are easily identifiable.
9
+ 3. **Permissions**: Ensure your packages have the appropriate permissions to be accessed and executed.
10
+
11
+ ## Creating a Starter DAF Package with jvcli
12
+
13
+ To create a new DAF package using `jvcli`, follow these steps:
14
+
15
+ 1. **Run the Command**: Use the following command to create a new DAF package:
16
+ ```sh
17
+ jvcli create agent --name your_agent_name --description "Your agent description"
18
+ ```
19
+ Replace `your_agent_name` with the desired name for your agent in snake_case.
20
+
21
+ 2. **Options**: You can customize the creation process with various options:
22
+ - `--version`: Specify the version of the agent. Default is `0.0.1`.
23
+ - `--jivas_version`: Specify the version of Jivas. Default is `2.0.0`.
24
+ - `--path`: Directory to create the agent folder in. Default is `./dafs`.
25
+ - `--namespace`: Namespace for the agent. Defaults to the username in the token.
26
+
27
+ 3. **Example**:
28
+ ```sh
29
+ jvcli create agent --name my_agent --description "My custom JIVAS AI agent"
30
+ ```
31
+
32
+ For more information, refer to the project's documentation.
33
+
34
+ ## Notes
35
+
36
+ - DAF packages should be thoroughly tested before deployment.
37
+ - Follow best practices for configuration and error handling.
38
+
39
+ For more information, refer to the project's documentation.
@@ -3,7 +3,7 @@ JIVAS_PASSWORD=password
3
3
  JIVAS_PORT=8000
4
4
  JIVAS_BASE_URL=http://localhost:8000
5
5
  JIVAS_STUDIO_URL=http://localhost:8989
6
- JIVAS_FILES_URL=http://localhost:8000/files
6
+ JIVAS_FILES_URL=http://localhost:9000/files
7
7
  JIVAS_DESCRIPTOR_ROOT_PATH=".jvdata"
8
8
  JIVAS_ACTIONS_ROOT_PATH="actions"
9
9
  JIVAS_DAF_ROOT_PATH="daf"
@@ -0,0 +1,66 @@
1
+ #!/bin/bash
2
+ # Script to create jivas user, login, and initialize jivas graph
3
+
4
+ function initialize() {
5
+
6
+ if lsof -i :$JIVAS_PORT >/dev/null; then
7
+ # Try to login first
8
+ JIVAS_TOKEN=$(curl --silent --show-error --no-progress-meter \
9
+ --request POST \
10
+ --header 'Content-Type: application/json' \
11
+ --header 'Accept: application/json' \
12
+ --data '{"password": "'"$JIVAS_PASSWORD"'","email": "'"$JIVAS_USER"'"}' \
13
+ "http://localhost:$JIVAS_PORT/user/login" | grep -o '"token":"[^"]*' | sed 's/"token":"//')
14
+
15
+ echo $JIVAS_TOKEN
16
+
17
+ # Check if login was successful
18
+ if [ -z "$JIVAS_TOKEN" ] || [ "$JIVAS_TOKEN" == "null" ]; then
19
+ echo "Login failed. Registering user..."
20
+
21
+ # Register user if login failed
22
+ curl --silent --show-error --no-progress-meter \
23
+ --request POST \
24
+ --header 'Content-Type: application/json' \
25
+ --header 'Accept: application/json' \
26
+ --data '{
27
+ "password": "'"$JIVAS_PASSWORD"'",
28
+ "email": "'"$JIVAS_USER"'"
29
+ }' \
30
+ "http://localhost:$JIVAS_PORT/user/register"
31
+
32
+ # Attempt to login again after registration
33
+ JIVAS_TOKEN=$(curl --silent --show-error --no-progress-meter \
34
+ --request POST \
35
+ --header 'Content-Type: application/json' \
36
+ --header 'Accept: application/json' \
37
+ --data '{"password": "'"$JIVAS_PASSWORD"'","email": "'"$JIVAS_USER"'"}' \
38
+ "http://localhost:$JIVAS_PORT/user/login" | grep -oP '(?<="token":")[^"]*')
39
+ fi
40
+
41
+ # Print token
42
+ echo "Jivas token: $JIVAS_TOKEN"
43
+
44
+ echo -e "\n\nImporting demo agent...\n"
45
+ # Import the agent
46
+ AGENT_ID=$(curl --silent --show-error --no-progress-meter \
47
+ --request POST \
48
+ --header 'Content-Type: application/json' \
49
+ --header 'Accept: application/json' \
50
+ --header "Authorization: Bearer $JIVAS_TOKEN" \
51
+ --data '{"daf_name": "jivas/eldon_ai"}' \
52
+ "http://localhost:$JIVAS_PORT/walker/import_agent" | grep -o '"id":"[^"]*' | sed 's/"id":"//')
53
+
54
+ echo "$AGENT_ID\n"
55
+ else
56
+ echo "Server is not running on port $JIVAS_PORT. Waiting..."
57
+ fi
58
+
59
+ exit
60
+ }
61
+
62
+ # Main loop to check if a process is running on port $JIVAS_PORT
63
+ while true; do
64
+ initialize
65
+ sleep 2 # Wait for 2 seconds before checking again
66
+ done
@@ -0,0 +1,70 @@
1
+ #!/bin/bash
2
+ # Script to create jivas user, login, and initialize jivas graph
3
+
4
+ function initialize() {
5
+
6
+ if lsof -i :$JIVAS_PORT >/dev/null; then
7
+
8
+ # Try to login first
9
+ JIVAS_TOKEN=$(curl --silent --show-error --no-progress-meter \
10
+ --request POST \
11
+ --header 'Content-Type: application/json' \
12
+ --header 'Accept: application/json' \
13
+ --data '{"password": "'"$JIVAS_PASSWORD"'","email": "'"$JIVAS_USER"'"}' \
14
+ "http://localhost:$JIVAS_PORT/user/login" | grep -o '"token":"[^"]*' | sed 's/"token":"//')
15
+
16
+ echo $JIVAS_TOKEN
17
+
18
+ # Check if login was successful
19
+ if [ -z "$JIVAS_TOKEN" ] || [ "$JIVAS_TOKEN" == "null" ]; then
20
+ echo "Login failed. Registering user..."
21
+
22
+ # Register user if login failed
23
+ curl --silent --show-error --no-progress-meter \
24
+ --request POST \
25
+ --header 'Content-Type: application/json' \
26
+ --header 'Accept: application/json' \
27
+ --data '{
28
+ "password": "'"$JIVAS_PASSWORD"'",
29
+ "email": "'"$JIVAS_USER"'"
30
+ }' \
31
+ "http://localhost:$JIVAS_PORT/user/register"
32
+
33
+ # Attempt to login again after registration
34
+ JIVAS_TOKEN=$(curl --silent --show-error --no-progress-meter \
35
+ --request POST \
36
+ --header 'Content-Type: application/json' \
37
+ --header 'Accept: application/json' \
38
+ --data '{"password": "'"$JIVAS_PASSWORD"'","email": "'"$JIVAS_USER"'"}' \
39
+ "http://localhost:$JIVAS_PORT/user/login" | grep -o '"token":"[^"]*' | sed 's/"token":"//')
40
+ fi
41
+
42
+
43
+ # Print token
44
+ echo "Jivas token: $JIVAS_TOKEN"
45
+
46
+ echo "Initializing jivas graph..."
47
+
48
+ # Initialize agents
49
+ curl --silent --show-error --no-progress-meter \
50
+ --request POST \
51
+ -H 'accept: application/json' \
52
+ -H 'Content-Type: application/json' \
53
+ -H "Authorization: Bearer $JIVAS_TOKEN" \
54
+ --data '{}' \
55
+ "http://localhost:$JIVAS_PORT/walker/init_agents"
56
+
57
+ exit
58
+
59
+ else
60
+ echo "Server is not running on port $JIVAS_PORT. Waiting..."
61
+ fi
62
+
63
+ exit
64
+ }
65
+
66
+ # Main loop to check if a process is running on port $JIVAS_PORT
67
+ while true; do
68
+ initialize
69
+ sleep 2 # Wait for 2 seconds before checking again
70
+ done
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ # Script to serve jivas app
3
+
4
+ # Export env vars
5
+ set -o allexport; source .env; set +o allexport
6
+ # serve jivas app
7
+ jac jvserve main.jac
@@ -0,0 +1,25 @@
1
+ # Test Cases
2
+
3
+ This directory is designated for custom test cases.
4
+
5
+ ## Instructions
6
+
7
+ 1. **Create Your Test Cases**: Place your test case scripts in this folder.
8
+ 2. **Naming Convention**: Use clear and descriptive names for your test files to ensure they are easily identifiable.
9
+
10
+ ## Writing Test Cases
11
+
12
+ To write effective test cases, follow these guidelines:
13
+
14
+ 1. **Define the Purpose**: Clearly state what the test case is verifying.
15
+ 2. **Setup**: Prepare the necessary environment and inputs for the test.
16
+ 3. **Execution**: Describe the steps to execute the test.
17
+ 4. **Validation**: Specify the expected outcomes and how to validate them.
18
+ 5. **Teardown**: Clean up any resources or state after the test completes.
19
+
20
+ ## Notes
21
+
22
+ - Test cases should be thoroughly reviewed and tested before deployment.
23
+ - Follow best practices for scripting and error handling.
24
+
25
+ For more information, refer to the project's documentation.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: jvcli
3
- Version: 2.0.6
3
+ Version: 2.0.8
4
4
  Summary: CLI tool for Jivas Package Repository
5
5
  Home-page: https://github.com/TrueSelph/jvcli
6
6
  Author: TrueSelph Inc.
@@ -47,9 +47,16 @@ jvcli/templates/2.0.0/agent_descriptor.yaml
47
47
  jvcli/templates/2.0.0/agent_info.yaml
48
48
  jvcli/templates/2.0.0/agent_knowledge.yaml
49
49
  jvcli/templates/2.0.0/agent_memory.yaml
50
+ jvcli/templates/2.0.0/project/README.md
50
51
  jvcli/templates/2.0.0/project/env.example
51
52
  jvcli/templates/2.0.0/project/globals.jac
52
53
  jvcli/templates/2.0.0/project/main.jac
54
+ jvcli/templates/2.0.0/project/actions/README.md
55
+ jvcli/templates/2.0.0/project/daf/README.md
56
+ jvcli/templates/2.0.0/project/sh/import_agent.sh
57
+ jvcli/templates/2.0.0/project/sh/init.sh
58
+ jvcli/templates/2.0.0/project/sh/serve.sh
59
+ jvcli/templates/2.0.0/project/tests/README.md
53
60
  tests/test_api.py
54
61
  tests/test_auth.py
55
62
  tests/test_cli.py
@@ -197,7 +197,7 @@ class TestRegistryAPI:
197
197
  mock_requests.assert_called_once_with(
198
198
  RegistryAPI.url + "info",
199
199
  params={"name": "test-pkg", "version": "1.0.0"},
200
- headers=None,
200
+ headers={},
201
201
  )
202
202
  mock_secho.assert_called_once_with(
203
203
  "Error retrieving action: Network error", fg="red"
@@ -246,7 +246,7 @@ class TestRegistryAPI:
246
246
  mock_requests.assert_called_once_with(
247
247
  RegistryAPI.url + "download",
248
248
  params={"name": "test-package", "info": "false", "version": "1.0.0"},
249
- headers=None,
249
+ headers={},
250
250
  )
251
251
  mock_secho.assert_called_once_with(
252
252
  "Error downloading package: Network error", fg="red"
@@ -272,7 +272,7 @@ class TestRegistryAPI:
272
272
  mock_requests.assert_called_once_with(
273
273
  f"{RegistryAPI.url}info",
274
274
  params={"name": "test-action", "version": ""},
275
- headers=None,
275
+ headers={},
276
276
  )
277
277
  assert result == {"name": "test-action", "description": "Test action"}
278
278
 
@@ -291,7 +291,7 @@ class TestRegistryAPI:
291
291
  mock_requests.assert_called_once_with(
292
292
  f"{RegistryAPI.url}info",
293
293
  params={"name": "test-action", "version": ""},
294
- headers=None,
294
+ headers={},
295
295
  )
296
296
  mock_secho.assert_called_once_with(
297
297
  "Error retrieving action: Network error", fg="red"
@@ -316,7 +316,7 @@ class TestRegistryAPI:
316
316
  mock_requests.assert_called_once_with(
317
317
  f"{RegistryAPI.url}info",
318
318
  params={"name": "test-action", "version": ""},
319
- headers=None,
319
+ headers={},
320
320
  )
321
321
  mock_secho.assert_called_once_with(
322
322
  "Error retrieving action: Not Found", fg="red"
@@ -742,7 +742,7 @@ class TestRegistryAPI:
742
742
  mock_get.assert_called_once_with(
743
743
  RegistryAPI.url + "download",
744
744
  params={"name": test_name, "info": "false", "version": test_version},
745
- headers=None,
745
+ headers={},
746
746
  )
747
747
  assert result == {}
748
748
 
@@ -947,3 +947,57 @@ class TestRegistryAPI:
947
947
 
948
948
  # Assert
949
949
  assert result == {}
950
+
951
+ def test_package_download_with_api_key(self, mocker: MockerFixture) -> None:
952
+ """Test downloading package with API key."""
953
+ # Arrange
954
+ mock_response = mocker.Mock()
955
+ mock_response.status_code = 200
956
+ mock_response.json.return_value = {"package": "content"}
957
+
958
+ mock_get = mocker.patch("requests.get", return_value=mock_response)
959
+
960
+ test_name = "test-action"
961
+ test_api_key = "test-api-key" # pragma: allowlist secret
962
+
963
+ # Act
964
+ result = RegistryAPI.download_package(name=test_name, api_key=test_api_key)
965
+
966
+ # Assert
967
+ mock_get.assert_called_once_with(
968
+ f"{RegistryAPI.url}download",
969
+ params={"name": test_name, "info": "false", "version": ""},
970
+ headers={"x-api-key": test_api_key},
971
+ )
972
+ assert result == {"package": "content"}
973
+
974
+ def test_package_info_with_api_key(self, mocker: MockerFixture) -> None:
975
+ """Test getting package info with API key."""
976
+ # Arrange
977
+ mock_response = mocker.Mock()
978
+ mock_response.status_code = 200
979
+ mock_response.json.return_value = {
980
+ "name": "test-action",
981
+ "version": "1.0.0",
982
+ "description": "Test action",
983
+ }
984
+
985
+ mock_get = mocker.patch("requests.get", return_value=mock_response)
986
+
987
+ test_name = "test-action"
988
+ test_api_key = "test-api-key" # pragma: allowlist secret
989
+
990
+ # Act
991
+ result = RegistryAPI.get_package_info(name=test_name, api_key=test_api_key)
992
+
993
+ # Assert
994
+ mock_get.assert_called_once_with(
995
+ f"{RegistryAPI.url}info",
996
+ params={"name": test_name, "version": ""},
997
+ headers={"x-api-key": test_api_key},
998
+ )
999
+ assert result == {
1000
+ "name": "test-action",
1001
+ "version": "1.0.0",
1002
+ "description": "Test action",
1003
+ }
@@ -34,14 +34,25 @@ class TestStartProjectCommand:
34
34
  mock_makedirs.assert_any_call("test_project", exist_ok=True)
35
35
 
36
36
  # Verify subdirectories creation
37
- expected_dirs = ["tests", "actions", "daf", "scripts"]
37
+ expected_dirs = ["tests", "actions", "daf", "sh"]
38
38
  for dir_name in expected_dirs:
39
39
  mock_makedirs.assert_any_call(
40
40
  os.path.join("test_project", dir_name), exist_ok=True
41
41
  )
42
42
 
43
43
  # Verify template files creation
44
- expected_files = ["main.jac", "globals.jac", ".env"]
44
+ expected_files = [
45
+ "main.jac",
46
+ "globals.jac",
47
+ ".env",
48
+ "README.md",
49
+ "actions/README.md",
50
+ "daf/README.md",
51
+ "sh/init.sh",
52
+ "sh/import_agent.sh",
53
+ "sh/serve.sh",
54
+ "tests/README.md",
55
+ ]
45
56
  mock_calls = mock_open.mock_calls
46
57
  written_files = [
47
58
  call.args[0] for call in mock_calls if "test_project" in str(call)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes