@useconvoy/cli 0.120.0 → 0.123.6

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 (71) hide show
  1. package/dist/marketplace/convoy/skills/convoy/SKILL.md +1 -0
  2. package/dist/marketplace/convoy/skills/convoy/references/inline-html.md +101 -0
  3. package/dist/src/agent/runtimes/agent-instructions.js +2 -1
  4. package/dist/src/agent/runtimes/agent-instructions.js.map +1 -1
  5. package/dist/src/commands/browser/workflow.js +6 -0
  6. package/dist/src/commands/browser/workflow.js.map +1 -1
  7. package/dist/src/commands/environment/index.d.ts +12 -0
  8. package/dist/src/commands/environment/index.js +2 -1
  9. package/dist/src/commands/environment/index.js.map +1 -1
  10. package/dist/src/commands/project/command.js +8 -1
  11. package/dist/src/commands/project/command.js.map +1 -1
  12. package/dist/src/commands/project/launcher.d.ts +13 -0
  13. package/dist/src/commands/project/launcher.js +5 -1
  14. package/dist/src/commands/project/launcher.js.map +1 -1
  15. package/dist/src/commands/project/validators.d.ts +27 -0
  16. package/dist/src/commands/project/validators.js +6 -0
  17. package/dist/src/commands/project/validators.js.map +1 -1
  18. package/dist/src/commands/project/workflow.d.ts +12 -0
  19. package/dist/src/commands/project/workflow.js +7 -0
  20. package/dist/src/commands/project/workflow.js.map +1 -1
  21. package/dist/src/commands/remote/workflow.d.ts +12 -0
  22. package/dist/src/commands/remote/workflow.js +2 -1
  23. package/dist/src/commands/remote/workflow.js.map +1 -1
  24. package/dist/src/commands/threads/attach.js +8 -2
  25. package/dist/src/commands/threads/attach.js.map +1 -1
  26. package/dist/src/commands/tui/actions/app.js +8 -4
  27. package/dist/src/commands/tui/actions/app.js.map +1 -1
  28. package/dist/src/commands/tui/app.js +23 -13
  29. package/dist/src/commands/tui/app.js.map +1 -1
  30. package/dist/src/commands/tui/credentials/index.d.ts +1 -0
  31. package/dist/src/commands/tui/credentials/index.js +1 -0
  32. package/dist/src/commands/tui/credentials/index.js.map +1 -1
  33. package/dist/src/commands/tui/environments/app.js +19 -9
  34. package/dist/src/commands/tui/environments/app.js.map +1 -1
  35. package/dist/src/commands/tui/formatters.d.ts +7 -0
  36. package/dist/src/commands/tui/formatters.js +20 -0
  37. package/dist/src/commands/tui/formatters.js.map +1 -1
  38. package/dist/src/commands/tui/onboarding/app.js +22 -9
  39. package/dist/src/commands/tui/onboarding/app.js.map +1 -1
  40. package/dist/src/commands/tui/onboarding/formatters.js +1 -1
  41. package/dist/src/commands/tui/onboarding/formatters.js.map +1 -1
  42. package/dist/src/commands/tui/onboarding/index.d.ts +1 -0
  43. package/dist/src/commands/tui/onboarding/runtime-access.d.ts +8 -0
  44. package/dist/src/commands/tui/onboarding/runtime-access.js +194 -0
  45. package/dist/src/commands/tui/onboarding/runtime-access.js.map +1 -0
  46. package/dist/src/commands/tui/onboarding/validators.d.ts +14 -0
  47. package/dist/src/commands/tui/onboarding/validators.js +2 -0
  48. package/dist/src/commands/tui/onboarding/validators.js.map +1 -0
  49. package/dist/src/commands/tui/onboarding/workflow.d.ts +11 -0
  50. package/dist/src/commands/tui/onboarding/workflow.js +4 -0
  51. package/dist/src/commands/tui/onboarding/workflow.js.map +1 -1
  52. package/dist/src/commands/tui/resolution.d.ts +2 -1
  53. package/dist/src/commands/tui/resolution.js +3 -1
  54. package/dist/src/commands/tui/resolution.js.map +1 -1
  55. package/dist/src/commands/tui/workflow.d.ts +85 -0
  56. package/dist/src/commands/tui/workflow.js +34 -0
  57. package/dist/src/commands/tui/workflow.js.map +1 -1
  58. package/dist/src/convex/_generated/ai/ai-files.state.json +5 -4
  59. package/dist/src/convex/_generated/ai/guidelines.md +185 -270
  60. package/dist/templates/devcontainer/Dockerfile +4 -0
  61. package/dist/templates/devcontainer/README.md +2 -0
  62. package/dist/templates/devcontainer/devcontainer.json +1 -1
  63. package/dist/templates/project-isolation/devcontainer.json +1 -1
  64. package/dist/templates/project-isolation/environment.py +8 -0
  65. package/dist/templates/project-isolation/environment.test.py +12 -0
  66. package/dist/templates/project-isolation/launcher.py +75 -3
  67. package/dist/templates/project-isolation/launcher.test.py +33 -0
  68. package/package.json +1 -1
  69. package/dist/templates/project-isolation/__pycache__/environment.cpython-311.pyc +0 -0
  70. package/dist/templates/project-isolation/__pycache__/install.cpython-311.pyc +0 -0
  71. package/dist/templates/project-isolation/__pycache__/launcher.cpython-311.pyc +0 -0
@@ -578,6 +578,78 @@ def supervise(config, entry, request, shell=False):
578
578
  child.wait()
579
579
 
580
580
 
581
+ def account_result(runtime, code, output):
582
+ """Return only recognized account metadata, never raw runtime output."""
583
+ unknown = {"status": "unknown"}
584
+ if runtime == "codex":
585
+ lines = output.strip().splitlines()
586
+ if code == 0 and "Logged in using ChatGPT" in lines:
587
+ return {"status": "signed-in", "method": "ChatGPT"}
588
+ if code == 0 and any(line.startswith("Logged in using an API key") for line in lines):
589
+ return {"status": "signed-in", "method": "API key"}
590
+ if code == 1 and lines and lines[-1] == "Not logged in":
591
+ return {"status": "signed-out"}
592
+ return unknown
593
+ try:
594
+ data = json.loads(output)
595
+ if code == 0 and data.get("loggedIn") is True:
596
+ result = {"status": "signed-in"}
597
+ email = data.get("email")
598
+ if isinstance(email, str) and len(email) <= 254 and re.fullmatch(r"[^\s@]+@[^\s@]+", email):
599
+ result["account"] = email
600
+ return result
601
+ if code in (0, 1) and data.get("loggedIn") is False:
602
+ return {"status": "signed-out"}
603
+ except (ValueError, AttributeError):
604
+ pass
605
+ return unknown
606
+
607
+
608
+ def account_status(config, entry):
609
+ require(entry["uid"] not in {item.pw_uid for item in pwd.getpwall()} and
610
+ entry["uid"] not in {item.gr_gid for item in grp.getgrall()}, "Project UID/GID conflicts with a system account")
611
+ private_directory(entry["path"], entry["uid"])
612
+ private_directory(entry["path"] + "-worktrees", entry["uid"])
613
+ private_directory(Path(config["state"]) / entry["identity"], entry["uid"])
614
+ result = {}
615
+ installed = detect_runtimes(config)
616
+ for runtime, command in {"codex": ["codex", "login", "status"],
617
+ "claude-code": ["claude", "auth", "status", "--json"]}.items():
618
+ result[runtime] = {"status": "unknown"}
619
+ if runtime not in installed:
620
+ continue
621
+ child = subprocess.Popen(sandbox_args(config, entry) + command, env=SAFE_ENV,
622
+ preexec_fn=lambda: drop_privileges(entry["uid"]),
623
+ stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
624
+ close_fds=True, start_new_session=True)
625
+ output = bytearray()
626
+ try:
627
+ with selectors.DefaultSelector() as poll:
628
+ poll.register(child.stdout, selectors.EVENT_READ)
629
+ deadline = time.monotonic() + 8
630
+ while time.monotonic() < deadline:
631
+ if not poll.select(max(0, deadline - time.monotonic())):
632
+ break
633
+ chunk = os.read(child.stdout.fileno(), 4096)
634
+ if not chunk:
635
+ code = child.wait(timeout=max(0.01, deadline - time.monotonic()))
636
+ result[runtime] = account_result(runtime, code, output.decode("utf-8", errors="replace"))
637
+ break
638
+ output.extend(chunk)
639
+ if len(output) > 16384:
640
+ break
641
+ except (OSError, subprocess.TimeoutExpired):
642
+ pass
643
+ finally:
644
+ try:
645
+ os.killpg(child.pid, signal.SIGKILL)
646
+ except ProcessLookupError:
647
+ pass
648
+ child.wait()
649
+ child.stdout.close()
650
+ return result
651
+
652
+
581
653
  def main():
582
654
  config = load_config()
583
655
  shell = len(sys.argv) == 3 and sys.argv[1] == "shell" or len(sys.argv) == 4 and sys.argv[1] == "login"
@@ -589,7 +661,7 @@ def main():
589
661
  require(len(raw) <= 65536, "Request too large")
590
662
  request = json.loads(raw)
591
663
  action = request.get("action")
592
- require(action in {"list", "add", "remove", "connect", "shell", "check"}, "Unsupported operation")
664
+ require(action in {"list", "add", "remove", "connect", "shell", "check", "account"}, "Unsupported operation")
593
665
  identity = request.get("identity")
594
666
  if action != "list":
595
667
  require(isinstance(identity, str) and re.fullmatch(r"[a-f0-9]{64}", identity), "Invalid project identity")
@@ -605,11 +677,11 @@ def main():
605
677
  "status": "pending" if not entry.get("ready") else "stopped" if entry.get("enabled", True) else "removed"}
606
678
  for key, entry in registry.items()
607
679
  ]}
608
- elif action == "check":
680
+ elif action in ("check", "account"):
609
681
  require(identity in registry and registry[identity].get("ready"), "Project is not registered; repeat project add")
610
682
  os.close(registry_lock)
611
683
  registry_lock = None
612
- result = check(config, registry[identity])
684
+ result = account_status(config, registry[identity]) if action == "account" else check(config, registry[identity])
613
685
  else:
614
686
  holder = {"shell": "login" if request.get("login") else "shell",
615
687
  "connect": request.get("holder") if request.get("holder") in ("service", "connect") else "connect"}.get(action, "registration")
@@ -521,5 +521,38 @@ class LauncherPolicyTests(unittest.TestCase):
521
521
  libc.return_value.prctl.assert_called_once_with(38, 1, 0, 0, 0)
522
522
 
523
523
 
524
+ class AccountStatusTests(unittest.TestCase):
525
+ def test_recognized_status_and_safe_projection(self):
526
+ self.assertEqual(launcher.account_result("codex", 0, "Logged in using ChatGPT\n"),
527
+ {"status": "signed-in", "method": "ChatGPT"})
528
+ self.assertEqual(launcher.account_result("codex", 0, "Logged in using an API key - sk-secret"),
529
+ {"status": "signed-in", "method": "API key"})
530
+ self.assertEqual(launcher.account_result("codex", 1, "Not logged in\n"), {"status": "signed-out"})
531
+ self.assertEqual(launcher.account_result("claude-code", 0, json.dumps({"loggedIn": True, "email": "me@example.com", "token": "secret"})),
532
+ {"status": "signed-in", "account": "me@example.com"})
533
+ self.assertEqual(launcher.account_result("claude-code", 1, '{"loggedIn":false}'), {"status": "signed-out"})
534
+ for runtime, code, output in [("codex", 1, "broken: sk-secret"), ("codex", 1, "Logged in using ChatGPT"),
535
+ ("claude-code", 2, '{"loggedIn":false}'), ("claude-code", 0, '[]')]:
536
+ self.assertEqual(launcher.account_result(runtime, code, output), {"status": "unknown"})
537
+
538
+ def test_codex_status_tolerates_startup_warning(self):
539
+ self.assertEqual(launcher.account_result("codex", 1, "WARNING: could not create PATH aliases\nNot logged in\n"), {"status": "signed-out"})
540
+
541
+ def test_sandbox_output_is_bounded_and_failures_are_unknown(self):
542
+ entry = {"uid": 24001, "identity": "a" * 64, "path": "/project"}
543
+ for script, expected in [("print('Logged in using ChatGPT')", "signed-in"),
544
+ ("while True: print('x' * 4096, flush=True)", "unknown"),
545
+ ("print('secret error'); raise SystemExit(1)", "unknown")]:
546
+ with patch.object(launcher, "private_directory"), patch.object(launcher, "drop_privileges") as drop, \
547
+ patch.object(launcher, "detect_runtimes", return_value=["codex"]), \
548
+ patch.object(launcher, "sandbox_args", return_value=["/usr/bin/python3", "-c", script]) as sandbox:
549
+ started = time.monotonic()
550
+ result = launcher.account_status({"state": "/state"}, entry)
551
+ self.assertLess(time.monotonic() - started, 2)
552
+ self.assertEqual(result["codex"]["status"], expected)
553
+ self.assertEqual(result["claude-code"], {"status": "unknown"})
554
+ sandbox.assert_called_once_with({"state": "/state"}, entry)
555
+
556
+
524
557
  if __name__ == "__main__":
525
558
  unittest.main()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useconvoy/cli",
3
- "version": "0.120.0",
3
+ "version": "0.123.6",
4
4
  "description": "CLI agent for Convoy",
5
5
  "license": "Elastic-2.0",
6
6
  "homepage": "https://docs.convoy.build/docs/cli/install",