meshagent-cli 0.0.37__py3-none-any.whl → 0.0.38__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.

Potentially problematic release.


This version of meshagent-cli might be problematic. Click here for more details.

meshagent/cli/services.py CHANGED
@@ -6,13 +6,24 @@ from rich import print
6
6
  from typing import Annotated, List, Optional, Dict
7
7
  from aiohttp import ClientResponseError
8
8
  from datetime import datetime, timezone
9
- from pydantic_yaml import parse_yaml_raw_as, to_yaml_str
10
9
  from pydantic import PositiveInt
11
10
  import pydantic
12
11
  from typing import Literal
13
12
  from meshagent.cli import async_typer
14
- from meshagent.cli.helper import get_client, print_json_table, resolve_project_id, resolve_api_key
15
- from meshagent.api import ParticipantToken, RoomClient, WebSocketClientProtocol, websocket_protocol, websocket_room_url, meshagent_base_url
13
+ from meshagent.cli.helper import (
14
+ get_client,
15
+ print_json_table,
16
+ resolve_project_id,
17
+ resolve_api_key,
18
+ )
19
+ from meshagent.api import (
20
+ ParticipantToken,
21
+ RoomClient,
22
+ WebSocketClientProtocol,
23
+ websocket_room_url,
24
+ meshagent_base_url,
25
+ )
26
+
16
27
  # Pydantic basemodels
17
28
  from meshagent.api.accounts_client import Service, Port, Services
18
29
 
@@ -57,7 +68,9 @@ def _parse_port_spec(spec: str) -> PortSpec:
57
68
  kv: Dict[str, str] = {}
58
69
  for t in tokens:
59
70
  if "=" not in t:
60
- raise typer.BadParameter(f"expected num=PORT_NUMBER type=meshagent.callable|mcp.sse liveness=OPTIONAL_PATH, got '{t}'")
71
+ raise typer.BadParameter(
72
+ f"expected num=PORT_NUMBER type=meshagent.callable|mcp.sse liveness=OPTIONAL_PATH, got '{t}'"
73
+ )
61
74
  k, v = t.split("=", 1)
62
75
  kv[k] = v
63
76
  try:
@@ -159,7 +172,12 @@ async def service_test(
159
172
  *,
160
173
  project_id: str = None,
161
174
  api_key_id: Annotated[Optional[str], typer.Option()] = None,
162
- room: Annotated[str, typer.Option(help="A room name to test the service in (must not be currently running)")],
175
+ room: Annotated[
176
+ str,
177
+ typer.Option(
178
+ help="A room name to test the service in (must not be currently running)"
179
+ ),
180
+ ],
163
181
  name: Annotated[str, typer.Option(help="Friendly service name")],
164
182
  role: Annotated[str, typer.Option(help="Service role (agent|tool)")] = None,
165
183
  image: Annotated[str, typer.Option(help="Container image reference")],
@@ -191,11 +209,11 @@ async def service_test(
191
209
  ] = ...,
192
210
  timeout: Annotated[
193
211
  Optional[int],
194
- typer.Option("--timeout", help="The maximum time that this room should run (default 1hr)"),
212
+ typer.Option(
213
+ "--timeout", help="The maximum time that this room should run (default 1hr)"
214
+ ),
195
215
  ] = None,
196
216
  ):
197
-
198
-
199
217
  """Create a service attached to the project."""
200
218
  my_client = await get_client()
201
219
  try:
@@ -233,45 +251,45 @@ async def service_test(
233
251
 
234
252
  try:
235
253
  token = ParticipantToken(
236
- name=name,
237
- project_id=project_id,
238
- api_key_id=api_key_id
254
+ name=name, project_id=project_id, api_key_id=api_key_id
239
255
  )
240
256
  token.add_role_grant("user")
241
257
  token.add_room_grant(room)
242
258
  token.extra_payload = {
243
- "max_runtime_seconds" : timeout, # run for 1 hr max
244
- "meshagent_dev_services" : [
245
- service_obj.model_dump(mode="json")
246
- ]
259
+ "max_runtime_seconds": timeout, # run for 1 hr max
260
+ "meshagent_dev_services": [service_obj.model_dump(mode="json")],
247
261
  }
248
-
262
+
249
263
  print("[bold green]Connecting to room...[/bold green]")
250
264
 
251
- key = (await my_client.decrypt_project_api_key(project_id=project_id, id=api_key_id))["token"]
265
+ key = (
266
+ await my_client.decrypt_project_api_key(
267
+ project_id=project_id, id=api_key_id
268
+ )
269
+ )["token"]
252
270
 
253
271
  async with RoomClient(
254
272
  protocol=WebSocketClientProtocol(
255
- url=websocket_room_url(room_name=room, base_url=meshagent_base_url()),
256
- token=token.to_jwt(token=key)
273
+ url=websocket_room_url(
274
+ room_name=room, base_url=meshagent_base_url()
275
+ ),
276
+ token=token.to_jwt(token=key),
257
277
  )
258
278
  ) as client:
259
-
260
- print(f"[green]Your test room '{room}' has been started. It will time out after a few minutes if you do not join it.[/green]")
279
+ print(
280
+ f"[green]Your test room '{client.room_name}' has been started. It will time out after a few minutes if you do not join it.[/green]"
281
+ )
261
282
 
262
-
263
283
  except ClientResponseError as exc:
264
284
  if exc.status == 409:
265
285
  print(f"[red]Room already in use: {room}[/red]")
266
286
  raise typer.Exit(code=1)
267
287
  raise
268
288
 
269
-
270
289
  finally:
271
290
  await my_client.close()
272
291
 
273
292
 
274
-
275
293
  @app.async_command("show")
276
294
  async def service_show(
277
295
  *,
@@ -291,7 +309,13 @@ async def service_show(
291
309
 
292
310
 
293
311
  @app.async_command("list")
294
- async def service_list(*, project_id: str = None, o: Annotated[str, typer.Option(help="output format [json|table]")]):
312
+ async def service_list(
313
+ *,
314
+ project_id: str = None,
315
+ o: Annotated[
316
+ str, typer.Option("--output", "-o", help="output format [json|table]")
317
+ ] = "table",
318
+ ):
295
319
  """List all services for the project."""
296
320
  client = await get_client()
297
321
  try:
@@ -304,10 +328,7 @@ async def service_list(*, project_id: str = None, o: Annotated[str, typer.Option
304
328
  print(Services(services=services).model_dump_json(indent=2))
305
329
  else:
306
330
  print_json_table(
307
- [svc.model_dump(mode="json") for svc in services],
308
- "id",
309
- "name",
310
- "image"
331
+ [svc.model_dump(mode="json") for svc in services], "id", "name", "image"
311
332
  )
312
333
  finally:
313
334
  await client.close()
meshagent/cli/sessions.py CHANGED
@@ -1,12 +1,15 @@
1
1
  from meshagent.cli import async_typer
2
- from meshagent.cli.helper import get_client, print_json_table, set_active_project, resolve_project_id
2
+ from meshagent.cli.helper import get_client, print_json_table, resolve_project_id
3
3
 
4
4
  app = async_typer.AsyncTyper()
5
5
 
6
+
6
7
  @app.async_command("list")
7
8
  async def list(*, project_id: str = None):
8
9
  client = await get_client()
9
- sessions = await client.list_recent_sessions(project_id=await resolve_project_id(project_id=project_id))
10
+ sessions = await client.list_recent_sessions(
11
+ project_id=await resolve_project_id(project_id=project_id)
12
+ )
10
13
  print_json_table(sessions["sessions"])
11
14
  await client.close()
12
15
 
@@ -14,6 +17,9 @@ async def list(*, project_id: str = None):
14
17
  @app.async_command("show")
15
18
  async def show(*, project_id: str = None, session_id: str):
16
19
  client = await get_client()
17
- events = await client.list_session_events(project_id=await resolve_project_id(project_id=project_id), session_id=session_id)
20
+ events = await client.list_session_events(
21
+ project_id=await resolve_project_id(project_id=project_id),
22
+ session_id=session_id,
23
+ )
18
24
  print_json_table(events["events"], "type", "data")
19
25
  await client.close()