mirror of
https://github.com/usestrix/strix.git
synced 2026-09-14 14:19:09 +08:00
de730119f0
* feat(cli): add strix login for managed platform sign-in (device flow) * feat(cli): add --scopes flag to strix login * docs: document strix login and managed billing in README, AGENTS, docs, and managed skill * fix(cli): handle malformed login responses and credential file failures * fix(cli): reject sign-in responses without an API token * feat(login): interactive workspace and scope selection with presets * fix(login): reject malformed API token values in sign-in responses * fix(login): skip the scope prompt when stdin is not a terminal * fix(login): tolerate malformed selection containers and remove unreadable credential files on logout * fix(login): treat overflowing timing values as invalid * fix(login): show the configured platform host in the sign-in banner * fix(login): bound device flow timing values and clean up unreplaced secret temp files * feat(cli): add the strix cloud command surface for the managed platform * feat(cli): manage workspaces and hosted onboarding links from strix cloud * fix(cli): report a leftover temporary secret file instead of hiding it * feat(cli): pass a Stripe payment method to the top-up wallet client * docs(cloud): recommend the Stripe agent wallet as the default payment path * fix(cloud): preserve API auth during MPP payment * fix(cloud): drop knowledge query and settings commands removed from the API * fix(cloud): align agent commands with API contracts * fix(cloud): send required PR review integration fields * fix(cloud): preserve scopes when switching workspaces * fix(cloud): make session command help non-destructive * feat(cloud): improve human navigation and output * feat(cli): add native shell completions * feat(cloud): tailor human list and detail views * feat(cloud): upload local source for managed scans * fix(cloud): infer scan type from local targets * Add agent-friendly managed cloud CLI * Harden cloud CLI type boundaries * Clarify cloud test user MFA options * Correct cloud vulnerability status guidance * Clarify chat file path handling * Allow signed storage upload URLs * Fix provider token request handling * Improve cloud CLI human list views * Make cloud CLI workflows actionable and safe * Make cloud workspace switching session-safe * Preserve CLI session metadata in JSON output * Remove preview protection bypass plumbing from cloud CLI
47 lines
1.6 KiB
Python
47 lines
1.6 KiB
Python
"""Stable, privacy-safe identity for this Strix CLI installation."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import platform
|
|
from pathlib import Path
|
|
from typing import Any, cast
|
|
from uuid import uuid4
|
|
|
|
from strix.utils.secret_files import write_secret_text
|
|
|
|
|
|
IDENTITY_PATH = Path.home() / ".strix" / "cli-identity.json"
|
|
|
|
|
|
def _default_device_name(instance_id: str) -> str:
|
|
system = {"Darwin": "macOS", "Windows": "Windows", "Linux": "Linux"}.get(
|
|
platform.system(), "Computer"
|
|
)
|
|
return f"{system} CLI · {instance_id[:8]}"
|
|
|
|
|
|
def read_or_create_identity(*, device_name: str | None = None) -> dict[str, str]:
|
|
"""Return one installation ID, optionally updating its user-facing label."""
|
|
record: dict[str, Any] = {}
|
|
try:
|
|
raw = json.loads(IDENTITY_PATH.read_text(encoding="utf-8"))
|
|
if isinstance(raw, dict):
|
|
record = cast("dict[str, Any]", raw)
|
|
except (OSError, json.JSONDecodeError):
|
|
pass
|
|
|
|
instance_id = record.get("client_instance_id")
|
|
if not isinstance(instance_id, str) or len(instance_id) < 8:
|
|
instance_id = str(uuid4())
|
|
label = device_name.strip() if device_name is not None else record.get("device_name")
|
|
if not isinstance(label, str) or not label.strip():
|
|
label = _default_device_name(instance_id)
|
|
label = " ".join(label.split())
|
|
if not 1 <= len(label) <= 80:
|
|
raise ValueError("device name must be 1-80 printable characters")
|
|
|
|
identity = {"client_instance_id": instance_id, "device_name": label}
|
|
write_secret_text(IDENTITY_PATH, json.dumps(identity, indent=2))
|
|
return identity
|