sinapsis_cli 1.0.0__py3-none-any.whl
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.
- sinapsis_cli/__init__.py +13 -0
- sinapsis_cli/commands/__init__.py +0 -0
- sinapsis_cli/commands/cloud/__init__.py +0 -0
- sinapsis_cli/commands/cloud/_agent_selection.py +112 -0
- sinapsis_cli/commands/cloud/_secrets_render.py +15 -0
- sinapsis_cli/commands/cloud/_webhook_render.py +19 -0
- sinapsis_cli/commands/cloud/agents.py +137 -0
- sinapsis_cli/commands/cloud/api_keys.py +155 -0
- sinapsis_cli/commands/cloud/files.py +135 -0
- sinapsis_cli/commands/cloud/jobs.py +532 -0
- sinapsis_cli/commands/cloud/packages.py +164 -0
- sinapsis_cli/commands/cloud/schedules.py +392 -0
- sinapsis_cli/commands/cloud/secrets.py +96 -0
- sinapsis_cli/commands/cloud/templates.py +95 -0
- sinapsis_cli/commands/cloud/webhooks.py +156 -0
- sinapsis_cli/commands/common/__init__.py +0 -0
- sinapsis_cli/commands/common/auth.py +219 -0
- sinapsis_cli/commands/common/profiles.py +156 -0
- sinapsis_cli/commands/common/telemetry.py +150 -0
- sinapsis_cli/commands/local_api/__init__.py +0 -0
- sinapsis_cli/commands/local_api/jobs.py +284 -0
- sinapsis_cli/commands/local_venv/__init__.py +0 -0
- sinapsis_cli/commands/local_venv/_templates_render.py +56 -0
- sinapsis_cli/commands/local_venv/jobs.py +76 -0
- sinapsis_cli/commands/local_venv/templates.py +47 -0
- sinapsis_cli/composition.py +215 -0
- sinapsis_cli/config.py +446 -0
- sinapsis_cli/execution.py +77 -0
- sinapsis_cli/main.py +185 -0
- sinapsis_cli/main_multi.py +152 -0
- sinapsis_cli/shared/__init__.py +3 -0
- sinapsis_cli/shared/jobs.py +134 -0
- sinapsis_cli/shared/terminal.py +8 -0
- sinapsis_cli/shared/writer.py +427 -0
- sinapsis_cli/state.py +310 -0
- sinapsis_cli/telemetry/__init__.py +7 -0
- sinapsis_cli/telemetry/collector.py +84 -0
- sinapsis_cli/telemetry/core.py +331 -0
- sinapsis_cli/telemetry/scheduler.py +234 -0
- sinapsis_cli/telemetry/transport.py +150 -0
- sinapsis_cli-1.0.0.dist-info/METADATA +386 -0
- sinapsis_cli-1.0.0.dist-info/RECORD +46 -0
- sinapsis_cli-1.0.0.dist-info/WHEEL +4 -0
- sinapsis_cli-1.0.0.dist-info/entry_points.txt +5 -0
- sinapsis_cli-1.0.0.dist-info/licenses/LICENSE-APACHE +202 -0
- sinapsis_cli-1.0.0.dist-info/licenses/LICENSE-MIT +21 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"""Alternative Sinapsis CLI entry point with optional full-color output."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
import typer.rich_utils
|
|
6
|
+
from rich.console import Console
|
|
7
|
+
from rich.text import Text
|
|
8
|
+
from rich.theme import Theme
|
|
9
|
+
|
|
10
|
+
from sinapsis_cli.main import create_app, resolve_invocation
|
|
11
|
+
|
|
12
|
+
neo_theme = Theme(
|
|
13
|
+
{
|
|
14
|
+
"panel.title": "bold #00F5FF",
|
|
15
|
+
"command": "bold #00FFCC",
|
|
16
|
+
"option": "bold #FF79C6",
|
|
17
|
+
"brand": "bold #FF007F",
|
|
18
|
+
"accent": "bold #00F5FF",
|
|
19
|
+
"muted": "#6272A4",
|
|
20
|
+
}
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
plain_console = Console()
|
|
24
|
+
color_console = Console(theme=neo_theme, style="on #1E1B4B")
|
|
25
|
+
from rich.console import Console
|
|
26
|
+
|
|
27
|
+
console = Console()
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
LOGO = [
|
|
31
|
+
" XXXX",
|
|
32
|
+
" XXXXXX",
|
|
33
|
+
" XXXX XXX",
|
|
34
|
+
" XXXXXXXXXXX XXXXXXXXXXX XXX",
|
|
35
|
+
" XXXXXXXXXXXX XXXXXXXXXXXX XXX",
|
|
36
|
+
" XXXXXXXXXXX XXXXXXXXXXX XXX",
|
|
37
|
+
" XXXXXXXXXXX XXXXXXXXXXX",
|
|
38
|
+
" XXXXXXXXXXXXXXXXXXXX",
|
|
39
|
+
" XXXXXXXXXXXXXXXX",
|
|
40
|
+
" XXXXXXXXXXXX",
|
|
41
|
+
" XXXXXXXXXXXXXXXX",
|
|
42
|
+
" XXXXXXXXXXXXXXXXXXXX",
|
|
43
|
+
" XXXXXXXXXXXXXXXXXXXXXXXX",
|
|
44
|
+
" XXXXXXXXXXXX XXXXXXXXXXXX",
|
|
45
|
+
" XXXXXXXXXXXX XXXXXXXXXXXX",
|
|
46
|
+
" XXXXXXXXXXX XXXXXXXXXXX",
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
# sinapsis brand gradient:
|
|
51
|
+
# cyan → blue → indigo → violet → purple
|
|
52
|
+
GRADIENT = [
|
|
53
|
+
(0.00, "#38B6FF"),
|
|
54
|
+
(0.25, "#3978F6"),
|
|
55
|
+
(0.50, "#4650E8"),
|
|
56
|
+
(0.75, "#7248E8"),
|
|
57
|
+
(1.00, "#A855F7"),
|
|
58
|
+
]
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def _hex_to_rgb(color: str) -> tuple[int, int, int]:
|
|
62
|
+
"""Convert a hex color to an RGB tuple."""
|
|
63
|
+
color = color.lstrip("#")
|
|
64
|
+
|
|
65
|
+
return tuple(int(color[i : i + 2], 16) for i in (0, 2, 4))
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def _rgb_to_hex(rgb: tuple[int, int, int]) -> str:
|
|
69
|
+
"""Convert an RGB tuple to a hex color."""
|
|
70
|
+
return "#{:02x}{:02x}{:02x}".format(*rgb)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def _interpolate_color(start: str, end: str, amount: float) -> str:
|
|
74
|
+
"""Interpolate between two hex colors."""
|
|
75
|
+
start_rgb = _hex_to_rgb(start)
|
|
76
|
+
end_rgb = _hex_to_rgb(end)
|
|
77
|
+
|
|
78
|
+
rgb = tuple(
|
|
79
|
+
round(start_value + (end_value - start_value) * amount) for start_value, end_value in zip(start_rgb, end_rgb)
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
return _rgb_to_hex(rgb)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def _gradient_color(position: float) -> str:
|
|
86
|
+
"""Return a color from the sinapsis gradient at position 0.0–1.0."""
|
|
87
|
+
position = max(0.0, min(1.0, position))
|
|
88
|
+
|
|
89
|
+
for index in range(len(GRADIENT) - 1):
|
|
90
|
+
start_position, start_color = GRADIENT[index]
|
|
91
|
+
end_position, end_color = GRADIENT[index + 1]
|
|
92
|
+
|
|
93
|
+
if start_position <= position <= end_position:
|
|
94
|
+
amount = (position - start_position) / (end_position - start_position)
|
|
95
|
+
|
|
96
|
+
return _interpolate_color(start_color, end_color, amount)
|
|
97
|
+
|
|
98
|
+
return GRADIENT[-1][1]
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def print_logo(console: Console) -> None:
|
|
102
|
+
"""Print the sinapsis logo using the brand gradient."""
|
|
103
|
+
text = Text()
|
|
104
|
+
|
|
105
|
+
width = max(len(row) for row in LOGO)
|
|
106
|
+
height = len(LOGO)
|
|
107
|
+
|
|
108
|
+
for y, row in enumerate(LOGO):
|
|
109
|
+
for x, character in enumerate(row):
|
|
110
|
+
if character != "X":
|
|
111
|
+
text.append(" ")
|
|
112
|
+
continue
|
|
113
|
+
|
|
114
|
+
# Normalize the block's position within the logo.
|
|
115
|
+
x_position = x / max(width - 1, 1)
|
|
116
|
+
y_position = y / max(height - 1, 1)
|
|
117
|
+
|
|
118
|
+
# Diagonal gradient:
|
|
119
|
+
#
|
|
120
|
+
# cyan / blue
|
|
121
|
+
# ↘
|
|
122
|
+
# indigo
|
|
123
|
+
# ↘
|
|
124
|
+
# violet / purple
|
|
125
|
+
#
|
|
126
|
+
position = (x_position + y_position) / 2
|
|
127
|
+
|
|
128
|
+
text.append("█", style=_gradient_color(position))
|
|
129
|
+
|
|
130
|
+
text.append("\n")
|
|
131
|
+
|
|
132
|
+
console.print(text, crop=False)
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def main() -> None:
|
|
136
|
+
"""Run the profile-aware CLI with optional ``--color`` presentation."""
|
|
137
|
+
arguments = list(sys.argv[1:])
|
|
138
|
+
use_color = "--color" in arguments
|
|
139
|
+
|
|
140
|
+
if use_color:
|
|
141
|
+
arguments = [argument for argument in arguments if argument != "--color"]
|
|
142
|
+
typer.rich_utils._get_rich_console = lambda *args, **kwargs: color_console
|
|
143
|
+
print_logo(color_console)
|
|
144
|
+
else:
|
|
145
|
+
typer.rich_utils._get_rich_console = lambda *args, **kwargs: plain_console
|
|
146
|
+
|
|
147
|
+
execution, remaining = resolve_invocation(arguments)
|
|
148
|
+
create_app(execution)(args=remaining, prog_name="sinapsis")
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
if __name__ == "__main__":
|
|
152
|
+
main()
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"""Shared job helpers for the Sinapsis CLI."""
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import typer
|
|
5
|
+
|
|
6
|
+
from sinapsis_cli.execution import ExecutionContext
|
|
7
|
+
from sinapsis_cli.state import (
|
|
8
|
+
JobRecord,
|
|
9
|
+
clear_jobs,
|
|
10
|
+
clear_state,
|
|
11
|
+
get_job,
|
|
12
|
+
get_last_job_id,
|
|
13
|
+
list_jobs,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def resolve_job_id(job_id: str | None, *, profile_name: str) -> str:
|
|
18
|
+
"""Resolve an explicit or profile-scoped remembered job ID.
|
|
19
|
+
|
|
20
|
+
Args:
|
|
21
|
+
job_id: Explicit job ID, or ``None`` to use the profile's latest job.
|
|
22
|
+
profile_name: Name of the profile whose job history should be used.
|
|
23
|
+
|
|
24
|
+
Returns:
|
|
25
|
+
The resolved job ID.
|
|
26
|
+
|
|
27
|
+
Raises:
|
|
28
|
+
typer.Exit: If no explicit or remembered job ID is available.
|
|
29
|
+
"""
|
|
30
|
+
if job_id is not None:
|
|
31
|
+
return job_id
|
|
32
|
+
|
|
33
|
+
resolved_job_id = get_last_job_id(profile_name)
|
|
34
|
+
|
|
35
|
+
if resolved_job_id is None:
|
|
36
|
+
typer.echo(f"No job ID was provided and profile {profile_name!r} has no previous job.", err=True)
|
|
37
|
+
raise typer.Exit(code=1)
|
|
38
|
+
|
|
39
|
+
return resolved_job_id
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def get_job_record(job_id: str, *, profile_name: str) -> JobRecord:
|
|
43
|
+
"""Return a job recorded for the selected profile or fail.
|
|
44
|
+
|
|
45
|
+
Args:
|
|
46
|
+
job_id: Job identifier to retrieve.
|
|
47
|
+
profile_name: Profile expected to own the job.
|
|
48
|
+
|
|
49
|
+
Returns:
|
|
50
|
+
The matching job record.
|
|
51
|
+
|
|
52
|
+
Raises:
|
|
53
|
+
typer.Exit: If the job is missing, unscoped, or belongs to another
|
|
54
|
+
profile.
|
|
55
|
+
"""
|
|
56
|
+
record = get_job(job_id)
|
|
57
|
+
|
|
58
|
+
if record is None:
|
|
59
|
+
typer.echo(f"Job {job_id!r} is not recorded in local CLI state.", err=True)
|
|
60
|
+
raise typer.Exit(code=1)
|
|
61
|
+
|
|
62
|
+
if record.profile is None:
|
|
63
|
+
typer.echo(
|
|
64
|
+
f"Job {job_id!r} predates profile-scoped history and could not be mapped safely to a profile.",
|
|
65
|
+
err=True,
|
|
66
|
+
)
|
|
67
|
+
raise typer.Exit(code=1)
|
|
68
|
+
|
|
69
|
+
if record.profile != profile_name:
|
|
70
|
+
typer.echo(f"Job {job_id!r} belongs to profile {record.profile!r}, not {profile_name!r}.", err=True)
|
|
71
|
+
raise typer.Exit(code=1)
|
|
72
|
+
|
|
73
|
+
return record
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def require_job_target(job_id: str, *, profile_name: str, default_target: str) -> str:
|
|
77
|
+
"""Resolve the API endpoint without requiring local job history.
|
|
78
|
+
|
|
79
|
+
A job submitted through this profile retains its recorded endpoint.
|
|
80
|
+
Scheduled, remote, or externally submitted jobs have no local record:
|
|
81
|
+
send explicit IDs to the selected profile's API, where the server
|
|
82
|
+
authorizes access. A record from another profile never chooses that
|
|
83
|
+
profile's endpoint implicitly.
|
|
84
|
+
"""
|
|
85
|
+
record = get_job(job_id)
|
|
86
|
+
if record is not None and record.profile == profile_name and record.target:
|
|
87
|
+
return record.target
|
|
88
|
+
return default_target
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def register_history_commands(app: typer.Typer, execution: ExecutionContext) -> None:
|
|
92
|
+
"""Register job-history commands shared by all execution backends.
|
|
93
|
+
|
|
94
|
+
Args:
|
|
95
|
+
app: Backend-specific jobs application.
|
|
96
|
+
execution: Resolved execution context for the current invocation.
|
|
97
|
+
"""
|
|
98
|
+
|
|
99
|
+
@app.command("list")
|
|
100
|
+
def list_command(
|
|
101
|
+
all_profiles: bool = typer.Option(
|
|
102
|
+
False, "--all-profiles", help="Include jobs submitted through every profile."
|
|
103
|
+
),
|
|
104
|
+
) -> None:
|
|
105
|
+
"""List jobs remembered by the CLI."""
|
|
106
|
+
profile_name = None if all_profiles else execution.profile_name
|
|
107
|
+
jobs = list_jobs(profile_name)
|
|
108
|
+
|
|
109
|
+
if not jobs:
|
|
110
|
+
typer.echo("No jobs have been recorded.")
|
|
111
|
+
return
|
|
112
|
+
|
|
113
|
+
last_job_id = get_last_job_id(execution.profile_name)
|
|
114
|
+
|
|
115
|
+
for job in jobs:
|
|
116
|
+
marker = "*" if job.job_id == last_job_id else " "
|
|
117
|
+
source = job.source or "-"
|
|
118
|
+
profile = job.profile or "legacy"
|
|
119
|
+
target = job.target or "-"
|
|
120
|
+
|
|
121
|
+
typer.echo(f"{marker} {job.job_id} {job.submitted_at} {profile} {target} {source}")
|
|
122
|
+
|
|
123
|
+
@app.command("clear")
|
|
124
|
+
def clear_command(
|
|
125
|
+
all_profiles: bool = typer.Option(False, "--all-profiles", help="Clear job history for every profile."),
|
|
126
|
+
) -> None:
|
|
127
|
+
"""Clear remembered job state."""
|
|
128
|
+
if all_profiles:
|
|
129
|
+
clear_state()
|
|
130
|
+
typer.echo("Job history cleared for all profiles.")
|
|
131
|
+
return
|
|
132
|
+
|
|
133
|
+
clear_jobs(execution.profile_name)
|
|
134
|
+
typer.echo(f"Job history cleared for profile {execution.profile_name!r}.")
|