meshagent-cli 0.21.0__py3-none-any.whl → 0.23.0__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.
meshagent/cli/agent.py CHANGED
@@ -10,6 +10,8 @@ from meshagent.api import (
10
10
  RoomClient,
11
11
  WebSocketClientProtocol,
12
12
  RoomException,
13
+ TextResponse,
14
+ JsonResponse,
13
15
  )
14
16
  from meshagent.cli.helper import resolve_project_id
15
17
  from meshagent.cli import async_typer
@@ -71,7 +73,12 @@ async def ask(
71
73
  print("[magenta]Asking agent...[/magenta]")
72
74
 
73
75
  response = await client.agents.ask(agent=agent, arguments=json.loads(input))
74
- print(json.dumps(response.json))
76
+ if isinstance(response, TextResponse):
77
+ print(response.text)
78
+ elif isinstance(response, JsonResponse):
79
+ print(json.dumps(response.json))
80
+ else:
81
+ print(response)
75
82
  except RoomException as e:
76
83
  print(f"[red]{e}[/red]")
77
84
  finally:
@@ -196,7 +203,6 @@ async def list_agents_command(
196
203
  "name": agent.name,
197
204
  "title": agent.title,
198
205
  "description": agent.description,
199
- "requires": [r.to_json() for r in agent.requires],
200
206
  "supports_tools": agent.supports_tools,
201
207
  "labels": agent.labels,
202
208
  }
meshagent/cli/call.py CHANGED
@@ -1,4 +1,5 @@
1
1
  import typer
2
+ import os
2
3
  from rich import print
3
4
  from typing import Annotated, Optional
4
5
  from meshagent.cli.common_options import ProjectIdOption, RoomOption
@@ -78,10 +79,6 @@ async def make_call(
78
79
  room: RoomOption,
79
80
  role: str = "agent",
80
81
  local: Optional[bool] = None,
81
- agent_name: Annotated[
82
- Optional[str], typer.Option(..., help="deprecated and unused", hidden=True)
83
- ] = None,
84
- name: Annotated[str, typer.Option(..., help="deprecated", hidden=True)] = None,
85
82
  participant_name: Annotated[
86
83
  Optional[str],
87
84
  typer.Option(..., help="the participant name to be used by the callee"),
@@ -126,8 +123,6 @@ async def make_call(
126
123
  room=room,
127
124
  role=role,
128
125
  local=local,
129
- agent_name=agent_name,
130
- name=name,
131
126
  participant_name=participant_name,
132
127
  url=url,
133
128
  arguments=arguments,
@@ -142,10 +137,6 @@ async def _make_call(
142
137
  room: RoomOption,
143
138
  role: str = "agent",
144
139
  local: Optional[bool] = None,
145
- agent_name: Annotated[
146
- Optional[str], typer.Option(..., help="deprecated and unused", hidden=True)
147
- ] = None,
148
- name: Annotated[str, typer.Option(..., help="deprecated", hidden=True)] = None,
149
140
  participant_name: Annotated[
150
141
  Optional[str],
151
142
  typer.Option(..., help="the participant name to be used by the callee"),
@@ -162,15 +153,6 @@ async def _make_call(
162
153
  Instruct an agent to 'call' a given URL with specific arguments.
163
154
 
164
155
  """
165
- if name is not None:
166
- print("[yellow]name is deprecated and should no longer be passed[/yellow]")
167
-
168
- if agent_name is not None:
169
- print(
170
- "[yellow]agent-name is deprecated and should no longer be passed, use participant-name instead[/yellow]"
171
- )
172
- participant_name = agent_name
173
-
174
156
  if participant_name is None:
175
157
  print("[red]--participant-name is required[/red]")
176
158
  raise typer.Exit(1)
@@ -182,13 +164,18 @@ async def _make_call(
182
164
  room = resolve_room(room)
183
165
 
184
166
  if token is None:
185
- token = ParticipantToken(
186
- name=participant_name,
187
- )
188
- token.add_api_grant(permissions or ApiScope.agent_default())
189
- token.add_role_grant(role=role)
190
- token.add_room_grant(room)
191
- token.grants.append(ParticipantGrant(name="tunnel_ports", scope="9000"))
167
+ jwt = os.getenv("MESHAGENT_TOKEN")
168
+ if jwt is None:
169
+ token = ParticipantToken(
170
+ name=participant_name,
171
+ )
172
+ token.add_api_grant(permissions or ApiScope.agent_default())
173
+ token.add_role_grant(role=role)
174
+ token.add_room_grant(room)
175
+ token.grants.append(ParticipantGrant(name="tunnel_ports", scope="9000"))
176
+ jwt = token.to_jwt(api_key=key)
177
+ else:
178
+ jwt = token.to_jwt(api_key=key)
192
179
 
193
180
  if local is None:
194
181
  local = is_local_url(url)
@@ -199,7 +186,7 @@ async def _make_call(
199
186
  data = {
200
187
  "room_url": websocket_room_url(room_name=room),
201
188
  "room_name": room,
202
- "token": token.to_jwt(api_key=key),
189
+ "token": jwt,
203
190
  "arguments": json.loads(arguments)
204
191
  if isinstance(arguments, str)
205
192
  else arguments,
@@ -215,7 +202,7 @@ async def _make_call(
215
202
  url=websocket_room_url(
216
203
  room_name=room, base_url=meshagent_base_url()
217
204
  ),
218
- token=token.to_jwt(api_key=key),
205
+ token=jwt,
219
206
  )
220
207
  ) as client:
221
208
  print("[bold green]Making agent call...[/bold green]")