swiftgate-cli 1.0.0__tar.gz → 1.0.2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: swiftgate-cli
3
- Version: 1.0.0
3
+ Version: 1.0.2
4
4
  Summary: SwiftGate CLI — autonomous bidirectional agent bridge for SwiftGate OS
5
5
  Project-URL: Homepage, https://swiftgate.ai
6
6
  Project-URL: Repository, https://github.com/thetaroot/swiftgate
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "swiftgate-cli"
7
- version = "1.0.0"
7
+ version = "1.0.2"
8
8
  description = "SwiftGate CLI — autonomous bidirectional agent bridge for SwiftGate OS"
9
9
  readme = "README.md"
10
10
  license = { text = "MIT" }
@@ -35,7 +35,7 @@ logger = logging.getLogger("swiftgate")
35
35
 
36
36
 
37
37
  @click.group()
38
- @click.version_option(version="1.0.0", prog_name="swiftgate-cli")
38
+ @click.version_option(version="1.0.2", prog_name="swiftgate-cli")
39
39
  def cli():
40
40
  """swiftgate-cli — Autonomous bidirectional agent bridge for SwiftGate OS.
41
41
 
@@ -81,7 +81,7 @@ def setup(token: str, server: str):
81
81
  @cli.command()
82
82
  @click.option("--agent", required=True, help="Agent workspace slug")
83
83
  @click.option("--mcp-token", default="", help="MCP token from agent registration (sg_ea_...)")
84
- async def start(agent: str, mcp_token: str):
84
+ def start(agent: str, mcp_token: str):
85
85
  """Start an agent and bridge it to SwiftGate.
86
86
 
87
87
  Fetches agent config from SwiftGate, writes MCP configuration,
@@ -91,6 +91,10 @@ async def start(agent: str, mcp_token: str):
91
91
  The MCP token is required on first start. It is stored in
92
92
  ~/.swiftgate/config.json for subsequent starts.
93
93
  """
94
+ asyncio.run(_start_async(agent, mcp_token))
95
+
96
+
97
+ async def _start_async(agent: str, mcp_token: str) -> None:
94
98
  if not is_setup():
95
99
  click.echo(click.style("Not set up. Run: swiftgate-cli setup --token sg_acc_...", fg="red"))
96
100
  sys.exit(1)
@@ -103,23 +107,20 @@ async def start(agent: str, mcp_token: str):
103
107
  click.echo(f"Usage: swiftgate-cli start --agent {agent} --mcp-token sg_ea_...")
104
108
  sys.exit(1)
105
109
 
106
- # Store token for future use
107
110
  if mcp_token and mcp_token.startswith("sg_ea_"):
108
111
  _store_token(agent, mcp_token)
109
112
 
110
- client = APIClient()
111
-
112
- # Store token for future use
113
- if mcp_token and mcp_token.startswith("sg_ea_"):
114
- _store_token(agent, mcp_token)
115
-
116
- # Determine agent type from local config or default
117
113
  agent_type = _get_stored_type(agent) or "opencode"
118
- slug = agent
114
+ command = _agent_command(agent_type)
115
+ if not command:
116
+ click.echo(click.style(f"Unknown agent type: {agent_type}", fg="red"))
117
+ sys.exit(1)
119
118
 
119
+ slug = agent
120
120
  click.echo(f"Starting agent '{slug}' ({agent_type})...")
121
121
 
122
- # Create bridge
122
+ client = APIClient()
123
+
123
124
  bridge = AgentBridge(
124
125
  workspace_slug=slug,
125
126
  agent_type=agent_type,
@@ -128,23 +129,19 @@ async def start(agent: str, mcp_token: str):
128
129
  server=get_server(),
129
130
  )
130
131
 
131
- # Spawn agent
132
132
  ok = await bridge.start()
133
133
  if not ok:
134
134
  click.echo(click.style("Failed to spawn agent process", fg="red"))
135
135
  sys.exit(1)
136
136
 
137
- # Notify SwiftGate
138
137
  await client.signal_agent_started(slug)
139
138
 
140
- # Start SSE listener
141
139
  listener = SSEWakeListener(client.get_sse_url())
142
140
  listener.register(slug, lambda s, c: bridge.wake(c))
143
141
  sse_task = asyncio.create_task(listener.listen())
144
142
 
145
- # Forward IO
146
143
  click.echo(click.style(f"✓ Agent '{slug}' running. Terminal connected.", fg="green"))
147
- click.echo(click.style(" (Press Ctrl+C to stop)", fg="dim"))
144
+ click.echo(click.style(" (Press Ctrl+C to stop)", fg="bright_black"))
148
145
 
149
146
  try:
150
147
  await bridge.forward_io()
@@ -171,34 +168,19 @@ def list(ctx):
171
168
  click.echo(click.style("Not set up. Run: swiftgate-cli setup --token sg_acc_...", fg="red"))
172
169
  return
173
170
 
174
- async def _list():
175
- client = APIClient()
176
- return await client.fetch_agents()
177
-
178
- agents = asyncio.run(_list())
179
- if not agents:
180
- click.echo("No agents registered.")
181
- return
182
-
183
- click.echo(f"{'Workspace Slug':<30} {'Type':<12} {'Transport':<10} {'Status':<10}")
184
- click.echo("-" * 62)
185
- for a in agents:
186
- click.echo(
187
- f"{a['workspace_slug']:<30} "
188
- f"{a['agent_type']:<12} "
189
- f"{a.get('transport_mode', 'http'):<10} "
190
- f"{a['status']:<10}"
191
- )
192
-
193
171
 
194
172
  @cli.command()
195
173
  @click.option("--agent", required=True, help="Agent workspace slug to stop")
196
- async def stop(agent: str):
174
+ def stop(agent: str):
197
175
  """Stop a running agent (placeholder for local process management).
198
176
 
199
177
  Use Ctrl+C in the agent's terminal to stop it.
200
178
  This command notifies SwiftGate that the agent has stopped.
201
179
  """
180
+ asyncio.run(_stop_async(agent))
181
+
182
+
183
+ async def _stop_async(agent: str) -> None:
202
184
  if not is_setup():
203
185
  click.echo(click.style("Not set up. Run: swiftgate-cli setup --token sg_acc_...", fg="red"))
204
186
  sys.exit(1)
File without changes
File without changes