jvcli 2.0.18__py3-none-any.whl → 2.0.20__py3-none-any.whl

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.
@@ -2,42 +2,535 @@
2
2
 
3
3
  Welcome to your JIVAS AI project boilerplate!
4
4
 
5
- ## Running Your JIVAS App
5
+ ## Command Reference
6
6
 
7
- To start your JIVAS app, execute the following command within this project folder:
7
+ This section provides a comprehensive guide to all available JVCLI commands, their options, and examples of their usage.
8
+
9
+ ### Authentication Commands
10
+
11
+ Authentication commands help you create and manage your Jivas Package Repository account.
12
+
13
+ #### `jvcli signup`
14
+
15
+ Create a new account on the Jivas Package Repository. This command will prompt you for your username, email, and password if not provided as options.
16
+
17
+ ```sh
18
+ # Interactive signup with prompts
19
+ jvcli signup
20
+
21
+ # Providing all parameters directly
22
+ jvcli signup --username myusername --email user@example.com --password mypassword
23
+ ```
24
+
25
+ Options:
26
+ - `--username`: Your desired username for the JPR account
27
+ - `--email`: Your email address
28
+ - `--password`: Your password (will be hidden during input)
29
+
30
+ After successful signup, your authentication token will be automatically saved to your local configuration.
31
+
32
+ #### `jvcli login`
33
+
34
+ Log in to your existing Jivas Package Repository account. This command authenticates you and saves the authentication token locally for future commands.
35
+
36
+ ```sh
37
+ # Interactive login with prompts
38
+ jvcli login
39
+
40
+ # Providing credentials directly
41
+ jvcli login --username user@example.com --password mypassword
42
+ ```
43
+
44
+ Options:
45
+ - `--username`: Your email address or username
46
+ - `--password`: Your password (will be hidden during input)
47
+
48
+ Upon successful login, your token will be saved locally and you'll see a confirmation message.
49
+
50
+ #### `jvcli logout`
51
+
52
+ Log out from the Jivas Package Repository by removing your local authentication token.
53
+
54
+ ```sh
55
+ jvcli logout
56
+ ```
57
+
58
+ This command doesn't require any options and will clear all local authentication data.
59
+
60
+ ### Project Management Commands
61
+
62
+ These commands help you manage your Jivas projects, from initial setup to maintenance.
63
+
64
+ #### `jvcli startproject`
65
+
66
+ Create a new Jivas project with all necessary scaffolding and folder structure. This command sets up a complete project template with all required files.
67
+
68
+ ```sh
69
+ # Create a new project with default settings
70
+ jvcli startproject my_project
71
+
72
+ # Create a project with a specific Jivas version
73
+ jvcli startproject my_project --version 2.0.0
74
+
75
+ # Create a project without generating an environment file
76
+ jvcli startproject my_project --no-env
77
+ ```
78
+
79
+ Options:
80
+ - `--version`: Specify the Jivas project version to use for scaffolding (default: latest supported version)
81
+ - `--no-env`: Skip generating the .env file with default configurations
82
+
83
+ This command creates a directory structure with:
84
+ - Actions directory for custom actions
85
+ - DAF directory for agent packages
86
+ - Main JAC file for your JIVAS application
87
+ - Configuration files and shell scripts for easy management
88
+
89
+ #### `jvcli clean`
90
+
91
+ Clean the Jac files in the current directory and subdirectories by removing compiled artifacts and temporary files.
92
+
93
+ ```sh
94
+ # Clean the current directory
95
+ jvcli clean
96
+ ```
97
+
98
+ This command executes `jac clean` under the hood and ensures your project is in a clean state before rebuilding or deploying.
99
+
100
+ ### Create Commands
101
+
102
+ Create commands help you generate new resources like actions, agents, and namespaces with the proper structure and configuration.
103
+
104
+ #### `jvcli create action`
105
+
106
+ Create a new action with its folder structure, configuration files, and code templates. Actions are modular components that can be used by agents to perform specific tasks.
107
+
108
+ ```sh
109
+ # Create a basic action with interactive prompts
110
+ jvcli create action
111
+
112
+ # Create an action with a specific name
113
+ jvcli create action --name custom_action
114
+
115
+ # Create a fully customized action
116
+ jvcli create action \
117
+ --name custom_action \
118
+ --version 1.0.0 \
119
+ --description "A custom action for processing data" \
120
+ --type interact_action \
121
+ --jivas_version 2.0.0 \
122
+ --singleton true \
123
+ --path ./my_actions \
124
+ --namespace my-namespace
125
+ ```
126
+
127
+ Options:
128
+ - `--name`: Name of the action (must be snake_case) - will be prompted if not provided
129
+ - `--version`: Version of the action (default: 0.0.1)
130
+ - `--jivas_version`: Version of Jivas to target (default: latest supported)
131
+ - `--description`: Detailed description of the action's purpose
132
+ - `--type`: Type of action - can be one of:
133
+ - `action`: Standard action (default)
134
+ - `interact_action`: Action that can interact with users
135
+ - `vector_store_action`: Action for vector database operations
136
+ - `--singleton`: Whether the action should be singleton (default: true)
137
+ - `--path`: Directory to create the action folder in (default: ./actions)
138
+ - `--namespace`: Namespace for the action (defaults to your username from token)
139
+
140
+ The command creates:
141
+ - Action directory structure
142
+ - info.yaml configuration file
143
+ - JAC files with code templates
144
+ - Streamlit app files for the action's UI
145
+ - README and CHANGELOG files
146
+
147
+ #### `jvcli create agent`
148
+
149
+ Create a new agent (DAF package) with all necessary configuration files. Agents are the main building blocks of JIVAS applications.
150
+
151
+ ```sh
152
+ # Create a basic agent with interactive prompts
153
+ jvcli create agent
154
+
155
+ # Create an agent with a specific name
156
+ jvcli create agent --name custom_agent
157
+
158
+ # Create a fully customized agent
159
+ jvcli create agent \
160
+ --name custom_agent \
161
+ --version 1.0.0 \
162
+ --description "A custom JIVAS agent for customer support" \
163
+ --jivas_version 2.0.0 \
164
+ --path ./my_agents \
165
+ --namespace my-namespace
166
+ ```
167
+
168
+ Options:
169
+ - `--name`: Name of the agent (must be snake_case) - will be prompted if not provided
170
+ - `--version`: Version of the agent (default: 0.0.1)
171
+ - `--jivas_version`: Version of Jivas to target (default: latest supported)
172
+ - `--description`: Detailed description of the agent's purpose (default: "A jivas agent autocreated by the jvcli")
173
+ - `--path`: Directory to create the agent in (default: ./daf)
174
+ - `--namespace`: Namespace for the agent (defaults to your username from token)
175
+
176
+ The command creates:
177
+ - Agent directory structure
178
+ - info.yaml package configuration
179
+ - descriptor.yaml defining agent behavior
180
+ - knowledge.yaml for agent knowledge base
181
+ - memory.yaml for agent memory storage
182
+ - README and CHANGELOG files
183
+
184
+ #### `jvcli create namespace`
185
+
186
+ Create a new namespace through the API to organize your packages. Namespaces help you group related packages and manage permissions.
187
+
188
+ ```sh
189
+ # Create a namespace with interactive prompt
190
+ jvcli create namespace
191
+
192
+ # Create a namespace with a specific name
193
+ jvcli create namespace --name my-namespace
194
+ ```
195
+
196
+ Options:
197
+ - `--name`: Name of the namespace (must be lowercase with only letters, numbers, and hyphens)
198
+
199
+ This command requires you to be authenticated with the JPR. After creating the namespace, it will be added to your account's permissions.
200
+
201
+ ### Publish Commands
202
+
203
+ Publish commands allow you to package and publish your actions and agents to the Jivas Package Repository.
204
+
205
+ #### `jvcli publish action`
206
+
207
+ Package and publish an action to the Jivas Package Repository. This makes your action available for others to download and use.
208
+
209
+ ```sh
210
+ # Publish an action
211
+ jvcli publish action --path ./actions/my_action
212
+
213
+ # Publish with specific visibility
214
+ jvcli publish action --path ./actions/my_action --visibility private
215
+
216
+ # Generate package without publishing
217
+ jvcli publish action --path ./actions/my_action --package-only --output ./packages
218
+
219
+ # Publish a pre-packaged tarball with explicit namespace
220
+ jvcli publish action --path ./packages/my_action.tar.gz --namespace my-namespace
221
+ ```
222
+
223
+ Options:
224
+ - `--path`: Path to the directory containing the action to publish (or path to a tarball)
225
+ - `--visibility`: Visibility of the published action (`public` or `private`, default: `public`)
226
+ - `--package-only`: Only generate the package without publishing to JPR
227
+ - `--output`, `-o`: Output path for the generated package (used with `--package-only`)
228
+ - `--namespace`: Namespace of the package (required when `--path` is a tarball)
229
+
230
+ The command will validate your action's structure, create a tarball package, and upload it to the JPR unless `--package-only` is specified.
231
+
232
+ #### `jvcli publish agent`
233
+
234
+ Package and publish an agent (DAF) to the Jivas Package Repository. This makes your agent available for others to download and use.
235
+
236
+ ```sh
237
+ # Publish an agent
238
+ jvcli publish agent --path ./daf/my_agent
239
+
240
+ # Publish with specific visibility
241
+ jvcli publish agent --path ./daf/my_agent --visibility private
242
+
243
+ # Generate package without publishing
244
+ jvcli publish agent --path ./daf/my_agent --package-only --output ./packages
245
+
246
+ # Publish a pre-packaged tarball with explicit namespace
247
+ jvcli publish agent --path ./packages/my_agent.tar.gz --namespace my-namespace
248
+ ```
249
+
250
+ Options:
251
+ - `--path`: Path to the directory containing the agent to publish (or path to a tarball)
252
+ - `--visibility`: Visibility of the published agent (`public` or `private`, default: `public`)
253
+ - `--package-only`: Only generate the package without publishing to JPR
254
+ - `--output`, `-o`: Output path for the generated package (used with `--package-only`)
255
+ - `--namespace`: Namespace of the package (required when `--path` is a tarball)
256
+
257
+ The command will validate your agent's structure, create a tarball package, and upload it to the JPR unless `--package-only` is specified.
258
+
259
+ ### Download Commands
260
+
261
+ Download commands let you retrieve actions and agents from the Jivas Package Repository.
262
+
263
+ #### `jvcli download action`
264
+
265
+ Download a JIVAS action package from the repository to your local environment.
266
+
267
+ ```sh
268
+ # Download the latest version of an action
269
+ jvcli download action my_namespace/custom_action
270
+
271
+ # Download a specific version
272
+ jvcli download action my_namespace/custom_action 1.0.0
273
+
274
+ # Download to a custom directory
275
+ jvcli download action my_namespace/custom_action --path ./my_custom_actions
276
+
277
+ # Download a specific version to a custom directory
278
+ jvcli download action my_namespace/custom_action 1.0.0 --path ./my_custom_actions
279
+ ```
280
+
281
+ Arguments:
282
+ - `name`: Name of the action to download (including namespace)
283
+ - `version`: Version of the action (optional, default: latest)
284
+
285
+ Options:
286
+ - `--path`: Directory to download the action to (optional, default: ./actions)
287
+
288
+ The downloaded action will be extracted to a directory named after the action in the specified path.
289
+
290
+ #### `jvcli download agent`
291
+
292
+ Download a JIVAS agent package (DAF) from the repository to your local environment.
293
+
294
+ ```sh
295
+ # Download the latest version of an agent
296
+ jvcli download agent my_namespace/custom_agent
297
+
298
+ # Download a specific version
299
+ jvcli download agent my_namespace/custom_agent 1.0.0
300
+
301
+ # Download to a custom directory
302
+ jvcli download agent my_namespace/custom_agent --path ./my_custom_agents
303
+
304
+ # Download a specific version to a custom directory
305
+ jvcli download agent my_namespace/custom_agent 1.0.0 --path ./my_custom_agents
306
+ ```
307
+
308
+ Arguments:
309
+ - `name`: Name of the agent to download (including namespace)
310
+ - `version`: Version of the agent (optional, default: latest)
311
+
312
+ Options:
313
+ - `--path`: Directory to download the agent to (optional, default: ./daf)
314
+
315
+ The downloaded agent will be extracted to a directory named after the agent in the specified path.
316
+
317
+ ### Info Commands
318
+
319
+ Info commands provide detailed information about packages in the Jivas Package Repository.
320
+
321
+ #### `jvcli info action`
322
+
323
+ Get detailed information about an action package in the repository. This includes metadata, dependencies, and configuration details.
324
+
325
+ ```sh
326
+ # Get info for the latest version of an action
327
+ jvcli info action my_namespace/custom_action
328
+
329
+ # Get info for a specific version
330
+ jvcli info action my_namespace/custom_action 1.0.0
331
+ ```
332
+
333
+ Arguments:
334
+ - `name`: Name of the action (including namespace)
335
+ - `version`: Version of the action (optional, default: latest)
336
+
337
+ The output displays the complete package information in YAML format, including:
338
+ - Package metadata (name, version, author)
339
+ - Description and title
340
+ - Dependencies and compatibility information
341
+ - Configuration details
342
+
343
+ #### `jvcli info agent`
344
+
345
+ Get detailed information about an agent package in the repository. This includes metadata, dependencies, and configuration details.
346
+
347
+ ```sh
348
+ # Get info for the latest version of an agent
349
+ jvcli info agent my_namespace/custom_agent
350
+
351
+ # Get info for a specific version
352
+ jvcli info agent my_namespace/custom_agent 1.0.0
353
+ ```
354
+
355
+ Arguments:
356
+ - `name`: Name of the agent (including namespace)
357
+ - `version`: Version of the agent (optional, default: latest)
358
+
359
+ The output displays the complete package information in YAML format, including:
360
+ - Package metadata (name, version, author)
361
+ - Description and title
362
+ - Dependencies and compatibility information
363
+ - Configuration details
364
+
365
+ ### Update Commands
366
+
367
+ Update commands allow you to modify existing resources like namespaces.
368
+
369
+ #### `jvcli update namespace`
370
+
371
+ Perform update operations on a specified namespace, such as inviting users or transferring ownership.
372
+
373
+ ```sh
374
+ # Invite a user to a namespace
375
+ jvcli update namespace my-namespace --invite user@example.com
376
+
377
+ # Transfer ownership of a namespace
378
+ jvcli update namespace my-namespace --transfer newowner@example.com
379
+ ```
380
+
381
+ Arguments:
382
+ - `namespace`: Name of the namespace to update
383
+
384
+ Options:
385
+ - `--invite`: Email address of a user to invite to the namespace
386
+ - `--transfer`: Email address of a user to transfer namespace ownership to
387
+
388
+ Note: The `--invite` and `--transfer` options are mutually exclusive - you can only use one at a time.
389
+
390
+ ### Server Commands
391
+
392
+ Server commands help you manage the Jivas Server, including launching, authentication, and agent management.
393
+
394
+ #### `jvcli server launch`
395
+
396
+ Launch the Jivas Server by running a specified JAC file. This starts the server for local development and testing.
397
+
398
+ ```sh
399
+ # Launch the server with the default main.jac file
400
+ jvcli server launch
401
+
402
+ # Launch the server with a custom JAC file
403
+ jvcli server launch --jac-file custom.jac
404
+ ```
405
+
406
+ Options:
407
+ - `--jac-file`: Path to the JAC file to run (default: main.jac in the current directory)
408
+
409
+ This command starts the Jivas Server, which will listen for connections on the default port (usually 8000).
410
+
411
+ #### `jvcli server login`
412
+
413
+ Log in to a running Jivas Server and get an authentication token. This token can be used for subsequent API calls.
414
+
415
+ ```sh
416
+ # Interactive login with prompts
417
+ jvcli server login
418
+
419
+ # Providing credentials directly
420
+ jvcli server login --email admin@example.com --password mypassword
421
+ ```
422
+
423
+ Options:
424
+ - `--email`: Email address for Jivas login (defaults to JIVAS_USER env var if set)
425
+ - `--password`: Password for Jivas login (defaults to JIVAS_PASSWORD env var if set)
426
+
427
+ Upon successful login, the token will be printed and stored in the JIVAS_TOKEN environment variable.
428
+
429
+ #### `jvcli server createadmin`
430
+
431
+ Create a system administrator account on a running Jivas Server. This is useful for initial setup.
8
432
 
9
433
  ```sh
10
- sh sh/serve.sh
434
+ # Interactive createadmin with prompts
435
+ jvcli server createadmin
436
+
437
+ # Providing credentials directly
438
+ jvcli server createadmin --email admin@example.com --password mypassword
11
439
  ```
12
440
 
13
- ## Setting Up a Demo Agent
441
+ Options:
442
+ - `--email`: Email address for the system admin (defaults to JIVAS_USER env var if set)
443
+ - `--password`: Password for the system admin (defaults to JIVAS_PASSWORD env var if set)
444
+
445
+ This command behaves differently based on your database configuration:
446
+ - With MongoDB configured: Uses the `jac create_system_admin` command
447
+ - Without MongoDB: Uses the server's API signup endpoint
448
+
449
+ #### `jvcli server initagents`
14
450
 
15
- To set up a demo agent, run the following command in another terminal:
451
+ Initialize agents in the Jivas system. This command reloads all agents and their actions, useful after making changes.
16
452
 
17
453
  ```sh
18
- sh sh/importagent.sh jivas/demo_ai
454
+ jvcli server initagents
19
455
  ```
20
456
 
21
- This will initialize JIVAS, download, and install a demo agent. If you wish to install any other agent, replace 'jivas/demo_ai' with the package name of your agent's DAF.
457
+ This command:
458
+ 1. Checks if the server is running
459
+ 2. Logs in to the server
460
+ 3. Cleans JAC files before reinitializing
461
+ 4. Sends a request to the server to reinitialize all agents
22
462
 
23
- ## Accessing the JIVAS Manager
463
+ #### `jvcli server importagent`
24
464
 
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:
465
+ Import an agent from a DAF package into a running Jivas server. This allows you to add new agents to your system.
26
466
 
27
467
  ```sh
28
- sh sh/startclient.sh
468
+ # Import the latest version of an agent
469
+ jvcli server importagent my_namespace/custom_agent
470
+
471
+ # Import a specific version
472
+ jvcli server importagent my_namespace/custom_agent 1.0.0
29
473
  ```
30
474
 
31
- ## Reflecting Changes to Agent Actions
475
+ Arguments:
476
+ - `agent_name`: Name of the agent to import (including namespace)
477
+ - `version`: Version of the agent (optional, default: latest)
478
+
479
+ This command:
480
+ 1. Checks if the server is running
481
+ 2. Logs in to the server
482
+ 3. Sends a request to import the specified agent
483
+ 4. Displays the agent ID upon successful import
484
+
485
+ ### Studio Commands
32
486
 
33
- If you make any changes to the agent actions, run the following command to reinitialize all agents running within this JIVAS app:
487
+ Studio commands help you manage the Jivas Studio, a web-based development environment for Jivas.
488
+
489
+ #### `jvcli studio launch`
490
+
491
+ Launch the Jivas Studio on a specified port. Jivas Studio provides a visual interface for building and managing agents.
34
492
 
35
493
  ```sh
36
- sh sh/initagents.sh
494
+ # Launch with default settings
495
+ jvcli studio launch
496
+
497
+ # Launch on a custom port
498
+ jvcli studio launch --port 9000
499
+
500
+ # Launch with authentication required
501
+ jvcli studio launch --require-auth
37
502
  ```
38
503
 
39
- ## Logging In
504
+ Options:
505
+ - `--port`: Port for the studio to launch on (default: 8989)
506
+ - `--require-auth`: Require authentication for studio API access (default: false)
507
+
508
+ When launched, the Studio will be accessible via a web browser at `http://localhost:<port>`.
509
+
510
+ ### Client Commands
511
+
512
+ Client commands help you manage the Jivas Client, which provides a user interface for interacting with agents.
513
+
514
+ #### `jvcli client launch`
515
+
516
+ Launch the Jivas Client, which provides a web interface for configuring and chatting with agents.
517
+
518
+ ```sh
519
+ # Launch with default settings
520
+ jvcli client launch
521
+
522
+ # Launch on a custom port
523
+ jvcli client launch --port 9001
524
+
525
+ # Launch with custom server URLs
526
+ jvcli client launch \
527
+ --jivas_url http://my-server:8000 \
528
+ --studio_url http://my-studio:8989
529
+ ```
40
530
 
41
- When the JIVAS manager loads, log in with the default JIVAS credentials found in your `.env` file.
531
+ Options:
532
+ - `--port`: Port for the client to launch on (default: 8501)
533
+ - `--jivas_url`: URL for the Jivas API (default: http://localhost:8000 or JIVAS_BASE_URL env var)
534
+ - `--studio_url`: URL for the Jivas Studio (default: http://localhost:8989 or JIVAS_STUDIO_URL env var)
42
535
 
43
- Happy building!
536
+ When launched, the Client will be accessible via a web browser at `http://localhost:<port>`.
@@ -28,7 +28,8 @@ JIVAS_WEBHOOK_SECRET_KEY="ABCDEFGHIJK"
28
28
  TOKEN_SECRET=s3cr3t
29
29
 
30
30
  # MongoDB Config
31
- # DATABASE_HOST=mongodb://localhost:27017/?replicaSet=my-rs
31
+ # DATABASE_HOST=mongodb://localhost:27017/?replicaSet=my-rs # If running MongoDB exposed on localhost, replace with the actual host and replaceSet name
32
+ # DATABASE_HOST=mongodb://mongodb:27017/?replicaSet=my-rs # If running MongoDB in a container named mongodb, replace with the actual host and replaceSet name
32
33
 
33
34
  # Typesense Config
34
35
  # TYPESENSE_HOST=localhost
@@ -38,5 +39,5 @@ TOKEN_SECRET=s3cr3t
38
39
  # TYPESENSE_CONNECTION_TIMEOUT_SECONDS=2
39
40
 
40
41
  # WPP Config
41
- # WPP_API_URL="http://localhost:21465"
42
- # WPP_MASTER_KEY="wpp_secret"
42
+ # WPP_API_URL="http://localhost:21465/api"
43
+ # WPP_SECRET_KEY="THISISMYSECURETOKEN"
jvcli/utils.py CHANGED
@@ -5,6 +5,7 @@ import re
5
5
  import tarfile
6
6
 
7
7
  import click
8
+ import requests
8
9
  import yaml
9
10
  from packaging.specifiers import InvalidSpecifier, SpecifierSet
10
11
  from packaging.version import InvalidVersion, Version
@@ -202,3 +203,28 @@ def compress_package_to_tgz(source_path: str, output_filename: str) -> str:
202
203
  arcname = os.path.relpath(file_path, start=source_path)
203
204
  tar.add(file_path, arcname=arcname)
204
205
  return output_filename
206
+
207
+
208
+ def load_env_if_present() -> None:
209
+ """Load environment variables from .env file if present."""
210
+ env_path = os.path.join(os.getcwd(), ".env")
211
+ if os.path.exists(env_path):
212
+ try:
213
+ import dotenv
214
+
215
+ dotenv.load_dotenv(env_path)
216
+ except ImportError:
217
+ click.echo(
218
+ "dotenv package not installed. Environment variables will not be loaded from .env file."
219
+ )
220
+
221
+
222
+ def is_server_running() -> bool:
223
+ """Check if the server is running by sending a request to the API."""
224
+ try:
225
+ base_url = os.environ.get("JIVAS_BASE_URL", "http://localhost:8000")
226
+ healthz_url = f"{base_url}/healthz"
227
+ response = requests.get(healthz_url)
228
+ return response.status_code == 200
229
+ except requests.ConnectionError:
230
+ return False