deliberaide-cli 0.1.7__tar.gz → 0.3.1__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.
Files changed (22) hide show
  1. {deliberaide_cli-0.1.7 → deliberaide_cli-0.3.1}/PKG-INFO +21 -1
  2. {deliberaide_cli-0.1.7 → deliberaide_cli-0.3.1}/deliberaide_cli/README.md +20 -0
  3. {deliberaide_cli-0.1.7 → deliberaide_cli-0.3.1}/deliberaide_cli/__init__.py +1 -1
  4. {deliberaide_cli-0.1.7 → deliberaide_cli-0.3.1}/deliberaide_cli/copilot_chat.py +219 -16
  5. {deliberaide_cli-0.1.7 → deliberaide_cli-0.3.1}/deliberaide_cli/deliberaide_cli.py +4 -12
  6. {deliberaide_cli-0.1.7 → deliberaide_cli-0.3.1}/deliberaide_cli/route_manifest.json +28568 -17721
  7. {deliberaide_cli-0.1.7 → deliberaide_cli-0.3.1}/deliberaide_cli/utils/api_backend.py +36 -1
  8. {deliberaide_cli-0.1.7 → deliberaide_cli-0.3.1}/deliberaide_cli.egg-info/PKG-INFO +21 -1
  9. {deliberaide_cli-0.1.7 → deliberaide_cli-0.3.1}/setup.py +1 -1
  10. {deliberaide_cli-0.1.7 → deliberaide_cli-0.3.1}/deliberaide_cli/__main__.py +0 -0
  11. {deliberaide_cli-0.1.7 → deliberaide_cli-0.3.1}/deliberaide_cli/core/__init__.py +0 -0
  12. {deliberaide_cli-0.1.7 → deliberaide_cli-0.3.1}/deliberaide_cli/core/manifest.py +0 -0
  13. {deliberaide_cli-0.1.7 → deliberaide_cli-0.3.1}/deliberaide_cli/core/session.py +0 -0
  14. {deliberaide_cli-0.1.7 → deliberaide_cli-0.3.1}/deliberaide_cli/utils/__init__.py +0 -0
  15. {deliberaide_cli-0.1.7 → deliberaide_cli-0.3.1}/deliberaide_cli/utils/formatting.py +0 -0
  16. {deliberaide_cli-0.1.7 → deliberaide_cli-0.3.1}/deliberaide_cli/utils/repl_skin.py +0 -0
  17. {deliberaide_cli-0.1.7 → deliberaide_cli-0.3.1}/deliberaide_cli.egg-info/SOURCES.txt +0 -0
  18. {deliberaide_cli-0.1.7 → deliberaide_cli-0.3.1}/deliberaide_cli.egg-info/dependency_links.txt +0 -0
  19. {deliberaide_cli-0.1.7 → deliberaide_cli-0.3.1}/deliberaide_cli.egg-info/entry_points.txt +0 -0
  20. {deliberaide_cli-0.1.7 → deliberaide_cli-0.3.1}/deliberaide_cli.egg-info/requires.txt +0 -0
  21. {deliberaide_cli-0.1.7 → deliberaide_cli-0.3.1}/deliberaide_cli.egg-info/top_level.txt +0 -0
  22. {deliberaide_cli-0.1.7 → deliberaide_cli-0.3.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: deliberaide-cli
3
- Version: 0.1.7
3
+ Version: 0.3.1
4
4
  Summary: Stateful, agent-native CLI for the deliberAIde v2 API
5
5
  Home-page: https://deliberaide.com
6
6
  Author: deliberAIde
@@ -73,6 +73,26 @@ deliberaide-cli context set org_id 11111111-1111-1111-1111-111111111111
73
73
  deliberaide-cli projects create-project --name "Pilot workspace"
74
74
  ```
75
75
 
76
+ ## Staff billing and HQ
77
+
78
+ Active deliberAIde staff (superadmins) can run the same metering, billing and HQ
79
+ operations as the HQ web app. Every account sees these commands, but the server
80
+ refuses them with `403` unless the signed-in account is active staff.
81
+
82
+ ```powershell
83
+ deliberaide-cli hq bootstrap # verify staff access to HQ
84
+ deliberaide-cli billing-review summary # unread/open staff reviews
85
+ deliberaide-cli billing-review list-reviews --include-resolved true
86
+ deliberaide-cli billing-review detail --case-id <uuid>
87
+ deliberaide-cli admin list-accounting-organisations
88
+ deliberaide-cli billing get-customer-usage-summary --x-organisation-id <uuid>
89
+ deliberaide-cli routes search billing-review # every staff billing route
90
+ ```
91
+
92
+ Actions that change a review or a balance (`billing-review act`,
93
+ `billing-review preview` / `apply`) follow the same preview, revision and
94
+ reason rules as the web app.
95
+
76
96
  ## Sign in from the browser
77
97
 
78
98
  By default, `auth login` starts a CLI approval session, opens your browser, and waits for approval:
@@ -35,6 +35,26 @@ deliberaide-cli context set org_id 11111111-1111-1111-1111-111111111111
35
35
  deliberaide-cli projects create-project --name "Pilot workspace"
36
36
  ```
37
37
 
38
+ ## Staff billing and HQ
39
+
40
+ Active deliberAIde staff (superadmins) can run the same metering, billing and HQ
41
+ operations as the HQ web app. Every account sees these commands, but the server
42
+ refuses them with `403` unless the signed-in account is active staff.
43
+
44
+ ```powershell
45
+ deliberaide-cli hq bootstrap # verify staff access to HQ
46
+ deliberaide-cli billing-review summary # unread/open staff reviews
47
+ deliberaide-cli billing-review list-reviews --include-resolved true
48
+ deliberaide-cli billing-review detail --case-id <uuid>
49
+ deliberaide-cli admin list-accounting-organisations
50
+ deliberaide-cli billing get-customer-usage-summary --x-organisation-id <uuid>
51
+ deliberaide-cli routes search billing-review # every staff billing route
52
+ ```
53
+
54
+ Actions that change a review or a balance (`billing-review act`,
55
+ `billing-review preview` / `apply`) follow the same preview, revision and
56
+ reason rules as the web app.
57
+
38
58
  ## Sign in from the browser
39
59
 
40
60
  By default, `auth login` starts a CLI approval session, opens your browser, and waits for approval:
@@ -1,3 +1,3 @@
1
1
  __all__ = ["__version__"]
2
2
 
3
- __version__ = "0.1.7"
3
+ __version__ = "0.3.1"
@@ -16,7 +16,9 @@ from __future__ import annotations
16
16
 
17
17
  import json
18
18
  import time
19
+ import uuid
19
20
  from dataclasses import dataclass, field
21
+ from decimal import Decimal, InvalidOperation
20
22
  from typing import Any, Callable, Iterable
21
23
 
22
24
  import click
@@ -30,6 +32,14 @@ DEFAULT_WORKFLOW = "agent" # lib/stores/conversation.ts getInitialWorkflow()
30
32
  WS_PATH = "/api/v1/ws/copilot"
31
33
  ORG_HEADER = "x-organisation-id"
32
34
  TERMINAL_FRAMES = {"copilot_done", "error", "quota_exceeded"}
35
+ # After a cost card the server ends the turn; do not wait longer than this for its "done".
36
+ APPROVAL_SETTLE_SECONDS = 10.0
37
+ EXIT_APPROVAL_REQUIRED = 3
38
+ # The hidden control turn the web app sends after "Start task" (buildAgentRequestContinuation).
39
+ APPROVED_CONTINUATION_TEXT = (
40
+ "[[mode_switch_continue]] Continue with the approved large-scope request. Do not ask for approval again "
41
+ "for this request; continue from the latest user request using the approved agent request state."
42
+ )
33
43
 
34
44
 
35
45
  # ------------------------------------------------------------------ runtime_context
@@ -123,6 +133,7 @@ class ChatResult:
123
133
  duration_seconds: float = 0.0
124
134
  timed_out: bool = False
125
135
  over_budget: bool = False # the printing budget passed; the turn may still have finished during the hold
136
+ approval: dict[str, Any] | None = None # the server held the request behind a cost card
126
137
 
127
138
  @property
128
139
  def ok(self) -> bool:
@@ -144,9 +155,16 @@ def copilot_message_frame(
144
155
  web_search_enabled: bool | None,
145
156
  show_in_chat: bool | None,
146
157
  organisation_id: str | None,
158
+ action_id: str | None = None,
147
159
  ) -> dict[str, Any]:
148
- """Mirror ``WebSocketClient.sendCopilotMessage``; optional keys are omitted, not nulled."""
160
+ """Mirror ``WebSocketClient.sendCopilotMessage``; optional keys are omitted, not nulled.
161
+
162
+ ``action_id`` is the caller-stable identity of this request. The server needs one for
163
+ every AI request it bills; the same id sent again is the same request, not a new one.
164
+ """
149
165
  data: dict[str, Any] = {"text": text, "runtime_context": runtime_context}
166
+ if action_id:
167
+ data["action_id"] = action_id
150
168
  if conversation_id:
151
169
  data["conversation_id"] = conversation_id
152
170
  if reasoning_effort:
@@ -195,6 +213,8 @@ def run_chat_turn(
195
213
  now = time.monotonic()
196
214
  remaining = (hard_deadline if quiet else deadline) - now
197
215
  if remaining <= 0:
216
+ if result.approval is not None and result.final is None:
217
+ break
198
218
  if not quiet and hold_seconds > 0:
199
219
  quiet = True
200
220
  result.over_budget = True
@@ -233,6 +253,11 @@ def run_chat_turn(
233
253
  result.final = data
234
254
  if data.get("conversation_id"):
235
255
  result.conversation_id = str(data["conversation_id"])
256
+ elif frame_type == "copilot_approval_required":
257
+ result.approval = data
258
+ if data.get("conversation_id"):
259
+ result.conversation_id = str(data["conversation_id"])
260
+ deadline = hard_deadline = min(hard_deadline, time.monotonic() + APPROVAL_SETTLE_SECONDS)
236
261
  elif frame_type in ("error", "quota_exceeded"):
237
262
  result.error = {"type": frame_type, **data}
238
263
  break
@@ -271,6 +296,82 @@ def keep_socket_alive(websocket: Any, seconds: float, *, ping_interval: float =
271
296
  return "terminal"
272
297
 
273
298
 
299
+ # ------------------------------------------------------------------ cost card
300
+
301
+
302
+ def approval_summary(approval: dict[str, Any]) -> dict[str, Any]:
303
+ """The few fields of a ``copilot_approval_required`` frame a caller decides on."""
304
+ tool_args = approval.get("tool_args") if isinstance(approval.get("tool_args"), dict) else {}
305
+ estimate = tool_args.get("cost_estimate") if isinstance(tool_args.get("cost_estimate"), dict) else {}
306
+ return {
307
+ "approval_request_id": str(approval.get("action_id") or ""),
308
+ "kind": "estimate" if approval.get("tool_name") == "agent_request" else "tool",
309
+ "tool_name": approval.get("tool_name"),
310
+ "description": approval.get("description"),
311
+ "meter": estimate.get("meter"),
312
+ "estimate_low": estimate.get("estimate_low"),
313
+ "estimate_expected": estimate.get("estimate_expected"),
314
+ "estimate_high": estimate.get("estimate_high"),
315
+ "unspent_quantity": estimate.get("unspent_quantity"),
316
+ "may_exceed_unspent": estimate.get("may_exceed_unspent"),
317
+ "can_start": estimate.get("can_start"),
318
+ }
319
+
320
+
321
+ def may_auto_approve(summary: dict[str, Any], *, yes: bool, max_credits: float | None) -> bool:
322
+ """Start without asking only for an estimate card the caller agreed to up front.
323
+
324
+ ``--yes`` accepts any estimate; ``--max-credits N`` accepts one whose upper end is at
325
+ most N. A card the server says cannot start, a card that is not an estimate (a tool
326
+ asking for confirmation) and an estimate without a readable upper end are never
327
+ accepted automatically.
328
+ """
329
+ if summary.get("kind") != "estimate" or not summary.get("approval_request_id"):
330
+ return False
331
+ if summary.get("can_start") is False:
332
+ return False
333
+ if yes:
334
+ return True
335
+ if max_credits is None:
336
+ return False
337
+ try:
338
+ high = Decimal(str(summary.get("estimate_high")))
339
+ except (InvalidOperation, ValueError):
340
+ return False
341
+ return high.is_finite() and high <= Decimal(str(max_credits))
342
+
343
+
344
+ def approved_continuation_frame(
345
+ *,
346
+ approval_request_id: str,
347
+ conversation_id: str,
348
+ runtime_context: dict[str, Any],
349
+ organisation_id: str | None,
350
+ ) -> dict[str, Any]:
351
+ """The turn that starts an approved request; it carries no user text of its own."""
352
+ return copilot_message_frame(
353
+ text=APPROVED_CONTINUATION_TEXT,
354
+ conversation_id=conversation_id,
355
+ runtime_context={**runtime_context, "approved_agent_request_id": approval_request_id},
356
+ reasoning_effort=None,
357
+ web_search_enabled=None,
358
+ show_in_chat=False,
359
+ organisation_id=organisation_id,
360
+ action_id=approval_request_id,
361
+ )
362
+
363
+
364
+ def _approve_request(runtime: Any, conversation_id: str, approval_request_id: str, headers: dict[str, str]) -> None:
365
+ response = runtime.backend.request(
366
+ "POST", f"/api/v1/request/{conversation_id}/approve",
367
+ json_body={"approval_request_id": approval_request_id}, headers=headers,
368
+ )
369
+ if not response.is_success:
370
+ raise click.ClickException(
371
+ f"The estimate could not be approved (HTTP {response.status_code}): {response.text[:300]}"
372
+ )
373
+
374
+
274
375
  # ------------------------------------------------------------------ wait (HTTP)
275
376
 
276
377
 
@@ -363,6 +464,13 @@ def _human_frame_printer(echo: Callable[[str], None]) -> Callable[[dict[str, Any
363
464
  else:
364
465
  echo("")
365
466
  echo(str(data.get("content", "")))
467
+ elif kind == "copilot_approval_required":
468
+ summary = approval_summary(data)
469
+ if summary["kind"] == "estimate":
470
+ echo(f" [estimate] about {summary['estimate_expected']} AI credits "
471
+ f"(range {summary['estimate_low']} to {summary['estimate_high']}); not started yet")
472
+ else:
473
+ echo(f" [approval required] {summary['description'] or summary['tool_name']}")
366
474
  elif kind in ("error", "quota_exceeded", "quota_warning"):
367
475
  echo(f" [{kind}] {json_dumps(data, compact=True)}")
368
476
  elif kind == "copilot_done":
@@ -406,6 +514,16 @@ def install_copilot_commands(root: click.Group) -> None:
406
514
  @click.option("--ping-interval", type=float, default=30.0, show_default=True, help="Heartbeat while the server is silent.")
407
515
  @click.option("--stream/--no-stream", default=True, show_default=True, help="Print server frames as they arrive (NDJSON in --json mode).")
408
516
  @click.option("--dry-run", is_flag=True, help="Print the frame that would be sent and exit.")
517
+ @click.option("--action-id", default=None,
518
+ help="Stable id of this request (a UUID). Generated when omitted. Send the same id again to retry "
519
+ "the same request without being charged twice.")
520
+ @click.option("--yes", "approve_yes", is_flag=True,
521
+ help="If the server answers with a cost estimate that needs approval, approve it and start.")
522
+ @click.option("--max-credits", type=float, default=None,
523
+ help="Like --yes, but only when the upper end of the estimate is at most this many AI credits.")
524
+ @click.option("--approve", "approve_request_id", default=None,
525
+ help="Start a request whose estimate an earlier `copilot chat` printed. Needs --conversation-id; "
526
+ "takes no --text.")
409
527
  @click.pass_obj
410
528
  def copilot_chat(
411
529
  runtime: Any,
@@ -427,10 +545,30 @@ def install_copilot_commands(root: click.Group) -> None:
427
545
  ping_interval: float,
428
546
  stream: bool,
429
547
  dry_run: bool,
548
+ action_id: str | None,
549
+ approve_yes: bool,
550
+ max_credits: float | None,
551
+ approve_request_id: str | None,
430
552
  ) -> None:
431
- """Send one Co-Pilot message over the WebSocket, exactly like the web app, and stream the turn."""
432
- if (text is None) == (text_file is None):
553
+ """Send one Co-Pilot message over the WebSocket, exactly like the web app, and stream the turn.
554
+
555
+ Larger tasks are not started right away: the server answers with a cost estimate.
556
+ By default the command then prints the estimate and exits with code 3; start the
557
+ task with `copilot chat --conversation-id <id> --approve <approval id>`, or pass
558
+ --yes / --max-credits up front.
559
+ """
560
+ if approve_request_id is not None:
561
+ if text is not None or text_file is not None:
562
+ raise click.UsageError("--approve starts the request already held; do not give --text or --text-file.")
563
+ if not conversation_id:
564
+ raise click.UsageError("--approve needs --conversation-id.")
565
+ elif (text is None) == (text_file is None):
433
566
  raise click.UsageError("Give exactly one of --text or --text-file.")
567
+ if action_id is not None:
568
+ try:
569
+ action_id = str(uuid.UUID(action_id.strip()))
570
+ except ValueError:
571
+ raise click.UsageError("--action-id must be a UUID.") from None
434
572
  if text_file is not None:
435
573
  from pathlib import Path
436
574
  text = Path(text_file).read_text(encoding="utf-8").strip()
@@ -454,15 +592,24 @@ def install_copilot_commands(root: click.Group) -> None:
454
592
  project_id=scope.get("project_id"),
455
593
  workspace_state=scope.get("workspace_state") or None,
456
594
  )
457
- frame = copilot_message_frame(
458
- text=text,
459
- conversation_id=conversation_id,
460
- runtime_context=runtime_context,
461
- reasoning_effort=reasoning_effort,
462
- web_search_enabled=web_search,
463
- show_in_chat=False if hide_from_chat else None,
464
- organisation_id=org_headers.get(ORG_HEADER),
465
- )
595
+ if approve_request_id is not None:
596
+ frame = approved_continuation_frame(
597
+ approval_request_id=approve_request_id.strip(),
598
+ conversation_id=str(conversation_id),
599
+ runtime_context=runtime_context,
600
+ organisation_id=org_headers.get(ORG_HEADER),
601
+ )
602
+ else:
603
+ frame = copilot_message_frame(
604
+ text=str(text),
605
+ conversation_id=conversation_id,
606
+ runtime_context=runtime_context,
607
+ reasoning_effort=reasoning_effort,
608
+ web_search_enabled=web_search,
609
+ show_in_chat=False if hide_from_chat else None,
610
+ organisation_id=org_headers.get(ORG_HEADER),
611
+ action_id=action_id or str(uuid.uuid4()),
612
+ )
466
613
  if dry_run:
467
614
  click.echo(json_dumps({"url": runtime.backend.build_websocket_url(WS_PATH), "frame": frame}))
468
615
  return
@@ -496,11 +643,11 @@ def install_copilot_commands(root: click.Group) -> None:
496
643
  )
497
644
  click.echo(f"conversation id: {partial.conversation_id or '?'}", err=True)
498
645
 
499
- with websocket_connect(url, additional_headers=headers, open_timeout=runtime.profile.timeout_seconds) as websocket:
500
- result = run_chat_turn(
646
+ def one_turn(websocket: Any, turn_frame: dict[str, Any], turn_conversation_id: str | None) -> ChatResult:
647
+ return run_chat_turn(
501
648
  websocket,
502
- frame,
503
- conversation_id=conversation_id,
649
+ turn_frame,
650
+ conversation_id=turn_conversation_id,
504
651
  timeout_seconds=timeout_seconds,
505
652
  ping_interval=ping_interval,
506
653
  on_frame=on_frame,
@@ -508,6 +655,38 @@ def install_copilot_commands(root: click.Group) -> None:
508
655
  on_budget=on_budget,
509
656
  )
510
657
 
658
+ approved_automatically = False
659
+ with websocket_connect(url, additional_headers=headers, open_timeout=runtime.profile.timeout_seconds) as websocket:
660
+ if approve_request_id is not None:
661
+ _approve_request(runtime, str(conversation_id), approve_request_id.strip(), org_headers)
662
+ result = one_turn(websocket, frame, conversation_id)
663
+ pending = approval_summary(result.approval) if result.approval is not None and result.final is None else None
664
+ if (
665
+ pending is not None
666
+ and approve_request_id is None
667
+ and result.conversation_id
668
+ and may_auto_approve(pending, yes=approve_yes, max_credits=max_credits)
669
+ ):
670
+ _approve_request(runtime, result.conversation_id, pending["approval_request_id"], org_headers)
671
+ approved_automatically = True
672
+ first_frames = result.frames
673
+ result = one_turn(
674
+ websocket,
675
+ approved_continuation_frame(
676
+ approval_request_id=pending["approval_request_id"],
677
+ conversation_id=result.conversation_id,
678
+ runtime_context=runtime_context,
679
+ organisation_id=org_headers.get(ORG_HEADER),
680
+ ),
681
+ result.conversation_id,
682
+ )
683
+ result.frames += first_frames
684
+
685
+ approval_pending = (
686
+ approval_summary(result.approval)
687
+ if result.approval is not None and result.final is None and result.error is None
688
+ else None
689
+ )
511
690
  envelope = {
512
691
  "ok": result.ok,
513
692
  "operation": "copilot.chat",
@@ -516,6 +695,8 @@ def install_copilot_commands(root: click.Group) -> None:
516
695
  "conversation_id": result.conversation_id,
517
696
  "message": result.final,
518
697
  "error": result.error,
698
+ "approval_required": approval_pending,
699
+ "approved_automatically": approved_automatically,
519
700
  "timed_out": result.timed_out,
520
701
  "over_budget": result.over_budget,
521
702
  "still_running": result.timed_out and result.error is None,
@@ -528,6 +709,28 @@ def install_copilot_commands(root: click.Group) -> None:
528
709
  click.echo(json_dumps(envelope, compact=True))
529
710
  elif not stream:
530
711
  click.echo(str((result.final or {}).get("content") or ""))
712
+ if approval_pending is not None:
713
+ start = (
714
+ f"deliberaide-cli --profile {runtime.profile.name} copilot chat "
715
+ f"--conversation-id {result.conversation_id or '<id>'} --approve {approval_pending['approval_request_id']}"
716
+ )
717
+ if approval_pending["kind"] != "estimate":
718
+ click.echo("Co-Pilot asks for a confirmation this command cannot give. Open the conversation in the web app.", err=True)
719
+ elif approval_pending.get("can_start") is False:
720
+ click.echo(
721
+ f"Not started: the estimate is {approval_pending['estimate_low']} to {approval_pending['estimate_high']} "
722
+ f"AI credits, more than this organisation has available ({approval_pending['unspent_quantity']}).",
723
+ err=True,
724
+ )
725
+ else:
726
+ click.echo(
727
+ f"Not started yet. Estimated cost: about {approval_pending['estimate_expected']} AI credits "
728
+ f"(range {approval_pending['estimate_low']} to {approval_pending['estimate_high']}). To start it, run:",
729
+ err=True,
730
+ )
731
+ click.echo(f" {start}", err=True)
732
+ click.echo("Pass --yes or --max-credits N to `copilot chat` to start such tasks without this step.", err=True)
733
+ raise SystemExit(EXIT_APPROVAL_REQUIRED)
531
734
  if not result.ok:
532
735
  if result.timed_out and result.error is None:
533
736
  click.echo(
@@ -711,18 +711,8 @@ def _store_cli_auth_tokens(
711
711
  refresh_token: str,
712
712
  ) -> None:
713
713
  hostname = urlparse(runtime.profile.base_url).hostname or ""
714
- runtime.backend.client.cookies.set(
715
- access_cookie_name,
716
- access_token,
717
- domain=hostname,
718
- path="/",
719
- )
720
- runtime.backend.client.cookies.set(
721
- refresh_cookie_name,
722
- refresh_token,
723
- domain=hostname,
724
- path="/",
725
- )
714
+ runtime.backend.set_cookie(access_cookie_name, access_token, domain=hostname)
715
+ runtime.backend.set_cookie(refresh_cookie_name, refresh_token, domain=hostname)
726
716
  runtime.save()
727
717
 
728
718
 
@@ -789,6 +779,8 @@ def _login_with_browser(
789
779
  if not runtime.json_output:
790
780
  click.echo("Browser sign-in started.")
791
781
  click.echo(f"Open this page if it does not launch automatically: {verification_url}")
782
+ if payload.get("user_code"):
783
+ click.echo(f"When asked, enter this code in the browser: {payload['user_code']}")
792
784
 
793
785
  deadline = time.time() + timeout_seconds
794
786
  while time.time() < deadline: