@@ -65,40 +65,40 @@ def callback(
6565 "--dev" ,
6666 help = "Use development API server (localhost:3000)" ,
6767 ),
68- api_key : Optional [str ] = typer .Option (
68+ sync_token : Optional [str ] = typer .Option (
6969 None ,
70- "--api-key " , "-k " ,
71- help = "HyperAide API key (or set HYPERAIDE_API_KEY env var)" ,
72- envvar = "HYPERAIDE_API_KEY " ,
70+ "--sync-token " , "-t " ,
71+ help = "HyperAide sync token (or set HYPERAIDE_SYNC_TOKEN env var)" ,
72+ envvar = "HYPERAIDE_SYNC_TOKEN " ,
7373 ),
7474):
7575 """
7676 HyperAide Browser Auth Sync - sync your browser authentication.
7777 """
7878 global _dev_mode
7979 _dev_mode = dev
80-
80+
8181 if dev :
8282 os .environ ["HYPERAIDE_DEV" ] = "1"
83-
83+
8484 # If no subcommand, run the sync (main) command
8585 if ctx .invoked_subcommand is None :
86- sync_browser_auth (api_key = api_key )
86+ sync_browser_auth (sync_token = sync_token )
8787
8888
8989@app .command (name = "sync" )
9090def sync_command (
91- api_key : Optional [str ] = typer .Option (
91+ sync_token : Optional [str ] = typer .Option (
9292 None ,
93- "--api-key " , "-k " ,
94- help = "HyperAide API key (or set HYPERAIDE_API_KEY env var)" ,
95- envvar = "HYPERAIDE_API_KEY " ,
93+ "--sync-token " , "-t " ,
94+ help = "HyperAide sync token (or set HYPERAIDE_SYNC_TOKEN env var)" ,
95+ envvar = "HYPERAIDE_SYNC_TOKEN " ,
9696 ),
9797):
9898 """
9999 Sync your browser authentication to HyperAide.
100100 """
101- sync_browser_auth (api_key = api_key )
101+ sync_browser_auth (sync_token = sync_token )
102102
103103# Configuration
104104DEFAULT_API_URL = "https://api.hyperaide.com"
@@ -133,53 +133,53 @@ def get_welcome_url() -> str:
133133 return DEFAULT_WELCOME_URL
134134
135135
136- def get_api_key () -> Optional [str ]:
137- """Get API key from environment variable."""
138- return os .environ .get ("HYPERAIDE_API_KEY " )
136+ def get_sync_token () -> Optional [str ]:
137+ """Get sync token from environment variable."""
138+ return os .environ .get ("HYPERAIDE_SYNC_TOKEN " )
139139
140140
141- def require_api_key ( api_key : Optional [str ]) -> str :
142- """Require API key from argument or environment, exit if missing."""
143- if api_key :
144- return api_key
145-
146- env_key = get_api_key ()
147- if env_key :
148- return env_key
149-
150- console .print ("[red]Error: HYPERAIDE_API_KEY environment variable is required.[/red]" )
151- console .print ("[dim]Usage: HYPERAIDE_API_KEY=your_key hyperaide-sync[/dim]" )
141+ def require_sync_token ( sync_token : Optional [str ]) -> str :
142+ """Require sync token from argument or environment, exit if missing."""
143+ if sync_token :
144+ return sync_token
145+
146+ env_token = get_sync_token ()
147+ if env_token :
148+ return env_token
149+
150+ console .print ("[red]Error: HYPERAIDE_SYNC_TOKEN environment variable is required.[/red]" )
151+ console .print ("[dim]Usage: HYPERAIDE_SYNC_TOKEN=your_token hyperaide-sync[/dim]" )
152152 sys .exit (1 )
153153
154154
155- def validate_api_key ( api_key : str ) -> dict :
156- """Validate API key with the server and start sync session."""
155+ def validate_sync_token ( sync_token : str ) -> dict :
156+ """Validate sync token with the server and start sync session."""
157157 api_url = get_api_url ()
158-
158+
159159 with Progress (
160160 SpinnerColumn (),
161161 TextColumn ("[progress.description]{task.description}" ),
162162 console = console ,
163163 ) as progress :
164- progress .add_task ("Validating API key ..." , total = None )
165-
164+ progress .add_task ("Validating sync token ..." , total = None )
165+
166166 try :
167167 response = httpx .post (
168168 f"{ api_url } /api/v1/browser_sync/start" ,
169- headers = {"x-api-key " : api_key },
169+ headers = {"x-sync-token " : sync_token },
170170 timeout = 30 ,
171171 )
172-
172+
173173 if response .status_code == 401 :
174- console .print ("[red]Invalid API key . Please check and try again.[/red]" )
174+ console .print ("[red]Invalid sync token . Please check and try again.[/red]" )
175175 sys .exit (1 )
176176 elif response .status_code != 200 :
177177 console .print (f"[red]Server error: { response .status_code } [/red]" )
178178 console .print (f"[dim]{ response .text } [/dim]" )
179179 sys .exit (1 )
180-
180+
181181 return response .json ()
182-
182+
183183 except httpx .RequestError as e :
184184 console .print (f"[red]Failed to connect to HyperAide API: { e } [/red]" )
185185 sys .exit (1 )
@@ -311,22 +311,22 @@ def on_navigate(url):
311311 return auth_cookies , list (visited_domains )
312312
313313
314- def complete_sync (api_key : str , cookies : list [dict ], visited_domains : list [str ]) -> dict :
314+ def complete_sync (sync_token : str , cookies : list [dict ], visited_domains : list [str ]) -> dict :
315315 """Send cookies to server to complete sync."""
316316 api_url = get_api_url ()
317-
317+
318318 with Progress (
319319 SpinnerColumn (),
320320 TextColumn ("[progress.description]{task.description}" ),
321321 console = console ,
322322 ) as progress :
323323 progress .add_task ("Syncing authentication..." , total = None )
324-
324+
325325 try :
326326 response = httpx .post (
327327 f"{ api_url } /api/v1/browser_sync/complete" ,
328328 headers = {
329- "x-api-key " : api_key ,
329+ "x-sync-token " : sync_token ,
330330 "Content-Type" : "application/json" ,
331331 },
332332 json = {
@@ -335,7 +335,7 @@ def complete_sync(api_key: str, cookies: list[dict], visited_domains: list[str])
335335 },
336336 timeout = 60 ,
337337 )
338-
338+
339339 if response .status_code == 400 :
340340 error_data = response .json () if response .headers .get ("content-type" , "" ).startswith ("application/json" ) else {}
341341 error_msg = error_data .get ("error" , "No cookies provided" )
@@ -346,9 +346,9 @@ def complete_sync(api_key: str, cookies: list[dict], visited_domains: list[str])
346346 console .print (f"[red]Failed to complete sync: { response .status_code } [/red]" )
347347 console .print (f"[dim]{ response .text } [/dim]" )
348348 sys .exit (1 )
349-
349+
350350 return response .json ()
351-
351+
352352 except httpx .RequestError as e :
353353 console .print (f"[red]Failed to complete sync: { e } [/red]" )
354354 sys .exit (1 )
@@ -388,7 +388,7 @@ def display_results(result: dict):
388388 console .print (table )
389389
390390
391- def sync_browser_auth (api_key : Optional [str ] = None ):
391+ def sync_browser_auth (sync_token : Optional [str ] = None ):
392392 """
393393 Main sync function - opens browser, captures cookies, syncs to HyperAide.
394394 """
@@ -401,12 +401,12 @@ def sync_browser_auth(api_key: Optional[str] = None):
401401 title = "Welcome" ,
402402 border_style = "cyan" ,
403403 ))
404-
405- # Require API key
406- api_key = require_api_key ( api_key )
407-
408- # Validate API key and start sync session
409- start_result = validate_api_key ( api_key )
404+
405+ # Require sync token
406+ sync_token = require_sync_token ( sync_token )
407+
408+ # Validate sync token and start sync session
409+ start_result = validate_sync_token ( sync_token )
410410
411411 # Check if user has existing context
412412 if start_result .get ("existing" ):
@@ -459,7 +459,7 @@ def sync_browser_auth(api_key: Optional[str] = None):
459459 return
460460
461461 # Complete sync
462- result = complete_sync (api_key , cookies , visited_domains )
462+ result = complete_sync (sync_token , cookies , visited_domains )
463463
464464 # Display results
465465 display_results (result )
@@ -470,11 +470,11 @@ def sync_browser_auth(api_key: Optional[str] = None):
470470
471471@app .command ()
472472def reset (
473- api_key : Optional [str ] = typer .Option (
473+ sync_token : Optional [str ] = typer .Option (
474474 None ,
475- "--api-key " , "-k " ,
476- help = "HyperAide API key " ,
477- envvar = "HYPERAIDE_API_KEY " ,
475+ "--sync-token " , "-t " ,
476+ help = "HyperAide sync token " ,
477+ envvar = "HYPERAIDE_SYNC_TOKEN " ,
478478 ),
479479 force : bool = typer .Option (
480480 False ,
@@ -485,10 +485,10 @@ def reset(
485485 """
486486 Reset your browser sync and disconnect all sites.
487487 """
488-
489- # Require API key
490- api_key = require_api_key ( api_key )
491-
488+
489+ # Require sync token
490+ sync_token = require_sync_token ( sync_token )
491+
492492 # Confirm reset
493493 if not force :
494494 confirm = typer .confirm (
@@ -498,70 +498,70 @@ def reset(
498498 if not confirm :
499499 console .print ("[yellow]Reset cancelled.[/yellow]" )
500500 return
501-
501+
502502 api_url = get_api_url ()
503-
503+
504504 with Progress (
505505 SpinnerColumn (),
506506 TextColumn ("[progress.description]{task.description}" ),
507507 console = console ,
508508 ) as progress :
509509 progress .add_task ("Resetting browser sync..." , total = None )
510-
510+
511511 try :
512512 response = httpx .delete (
513513 f"{ api_url } /api/v1/browser_sync" ,
514- headers = {"x-api-key " : api_key },
514+ headers = {"x-sync-token " : sync_token },
515515 timeout = 30 ,
516516 )
517-
517+
518518 if response .status_code == 401 :
519- console .print ("[red]Invalid API key .[/red]" )
519+ console .print ("[red]Invalid sync token .[/red]" )
520520 sys .exit (1 )
521521 elif response .status_code != 200 :
522522 console .print (f"[red]Failed to reset: { response .status_code } [/red]" )
523523 sys .exit (1 )
524-
524+
525525 console .print ()
526526 console .print (Panel (
527527 "[green]Browser sync has been reset.[/green]\n \n "
528528 "All connected sites have been disconnected.\n "
529529 "Run [bold]hyperaide-sync[/bold] to sync again." ,
530530 title = "Reset Complete" ,
531531 ))
532-
532+
533533 except httpx .RequestError as e :
534534 console .print (f"[red]Failed to reset: { e } [/red]" )
535535 sys .exit (1 )
536536
537537
538538@app .command ()
539539def status (
540- api_key : Optional [str ] = typer .Option (
540+ sync_token : Optional [str ] = typer .Option (
541541 None ,
542- "--api-key " , "-k " ,
543- help = "HyperAide API key " ,
544- envvar = "HYPERAIDE_API_KEY " ,
542+ "--sync-token " , "-t " ,
543+ help = "HyperAide sync token " ,
544+ envvar = "HYPERAIDE_SYNC_TOKEN " ,
545545 ),
546546):
547547 """
548548 Check your current browser sync status.
549549 """
550-
551- # Require API key
552- api_key = require_api_key ( api_key )
553-
550+
551+ # Require sync token
552+ sync_token = require_sync_token ( sync_token )
553+
554554 api_url = get_api_url ()
555-
555+
556556 try :
557557 response = httpx .get (
558558 f"{ api_url } /api/v1/browser_sync" ,
559- headers = {"x-api-key " : api_key },
559+ headers = {"x-sync-token " : sync_token },
560560 timeout = 30 ,
561561 )
562-
562+
563563 if response .status_code == 401 :
564- console .print ("[red]Invalid API key .[/red]" )
564+ console .print ("[red]Invalid sync token .[/red]" )
565565 sys .exit (1 )
566566 elif response .status_code != 200 :
567567 console .print (f"[red]Failed to get status: { response .status_code } [/red]" )
0 commit comments