cdx-manager 0.6.5 → 0.7.1

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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # CDX Manager
2
2
 
3
- [![License](https://img.shields.io/badge/license-MIT-4C8BF5)](LICENSE) ![Version](https://img.shields.io/badge/version-v0.6.5-4C8BF5) ![Python](https://img.shields.io/badge/python-3.9%2B-3776AB?logo=python&logoColor=white)
3
+ [![License](https://img.shields.io/badge/license-MIT-4C8BF5)](LICENSE) ![Version](https://img.shields.io/badge/version-v0.7.1-4C8BF5) ![Python](https://img.shields.io/badge/python-3.9%2B-3776AB?logo=python&logoColor=white)
4
4
 
5
5
  **Run multiple Codex, Claude, Antigravity, and Ollama sessions from one terminal. Switch between accounts instantly.**
6
6
 
@@ -134,7 +134,7 @@ For a specific version:
134
134
 
135
135
  ```bash
136
136
  curl -fsSL https://raw.githubusercontent.com/AlexAgo83/cdx-manager/main/install.sh -o install.sh
137
- CDX_VERSION=v0.6.5 sh install.sh
137
+ CDX_VERSION=v0.7.1 sh install.sh
138
138
  ```
139
139
 
140
140
  From source:
@@ -263,6 +263,7 @@ cdx set work --power medium --permission full --fast off
263
263
  cdx set personal --power low --permission review
264
264
  cdx set --sessions all --permission auto
265
265
  cdx set --provider ollama --model llama3.2
266
+ cdx set work --priority 80
266
267
  cdx power all low
267
268
  cdx perm provider:claude review
268
269
  cdx model provider:ollama llama3.2
@@ -275,12 +276,13 @@ Those values are stored on the session and reapplied every time you run `cdx wor
275
276
  cdx unset work --power
276
277
  cdx unset --sessions work,personal --fast
277
278
  cdx unset --provider claude --permission
279
+ cdx unset work --priority
278
280
  cdx unset work --all
279
281
  cdx power all default
280
282
  cdx model provider:ollama default
281
283
  ```
282
284
 
283
- `--power` maps to Codex `model_reasoning_effort` and Claude `--effort`. `--permission` maps to provider-native permission flags. `--fast on` uses low effort when no explicit power is set.
285
+ `--power` maps to Codex `model_reasoning_effort` and Claude `--effort`. `--permission` maps to provider-native permission flags. `--fast on` uses low effort when no explicit power is set. `--priority` is a 0..100 selector preference used as a tie-breaker after readiness and availability.
284
286
 
285
287
  ### Launch History
286
288
 
@@ -317,8 +319,8 @@ cdx history --summary --from 2026-05-01 --to 2026-05-28
317
319
  | `cdx enable <name> [--json]` | Re-enable a disabled session |
318
320
  | `cdx config <name> [--json]` | Show persistent launch settings for a session |
319
321
  | `cdx power\|perm\|fast\|model <name\|all\|provider:PROVIDER\|a,b> <value\|default> [--json]` | Shortcut commands for setting or clearing one launch setting |
320
- | `cdx set <name>\|--sessions all\|a,b\|--provider PROVIDER [--power low\|medium\|high\|xhigh\|max] [--permission review\|default\|auto\|full] [--fast on\|off] [--model MODEL] [--json]` | Persist launch settings for one or more sessions |
321
- | `cdx unset <name>\|--sessions all\|a,b\|--provider PROVIDER (--power\|--permission\|--fast\|--model\|--all) [--json]` | Remove persisted launch settings and fall back to provider defaults |
322
+ | `cdx set <name>\|--sessions all\|a,b\|--provider PROVIDER [--power low\|medium\|high\|xhigh\|max] [--permission review\|default\|auto\|full] [--fast on\|off] [--model MODEL] [--priority 0..100] [--json]` | Persist launch settings for one or more sessions |
323
+ | `cdx unset <name>\|--sessions all\|a,b\|--provider PROVIDER (--power\|--permission\|--fast\|--model\|--priority\|--all) [--json]` | Remove persisted launch settings and fall back to provider defaults |
322
324
  | `cdx history [name] [--limit N] [--summary] [--since 7d\|today\|DATE] [--from DATE] [--to DATE] [--json]` | Show recent launch history or aggregate total launch time per assistant, optionally filtered by period |
323
325
  | `cdx last [--json]` | Launch the most recent existing session from launch history |
324
326
  | `cdx context show\|path\|init\|edit\|clear\|set [text...] [--json]` | Manage the shared Markdown context for the current workspace |
@@ -334,6 +336,8 @@ cdx history --summary --from 2026-05-01 --to 2026-05-28
334
336
  | `cdx ready [--refresh] [--json]` | Schedule an OS notification for the next cooling-down assistant that becomes ready, then return immediately |
335
337
  | `cdx notify <name> --at-reset [--poll seconds] [--once] [--schedule] [--refresh] [--json]` | Wait for a session reset time or schedule an OS wake-up notification when due |
336
338
  | `cdx notify --next-ready [--poll seconds] [--once] [--schedule] [--refresh] [--json]` | Wait until the recommended session is usable, or schedule the next known reset notification |
339
+ | `cdx select --provider PROVIDER [--min-reasoning-effort low\|medium\|high] [--min-power low\|medium\|high] [--require-ready] [--refresh] --json` | Select a suitable session for headless automation |
340
+ | `cdx run [session] --cwd PATH (--prompt-file PATH\|--prompt TEXT) [--provider PROVIDER] [--model MODEL] [--reasoning-effort low\|medium\|high] [--power low\|medium\|high] [--permission MODE] [--timeout-seconds N] --json` | Run one headless task and return a stable JSON result |
337
341
  | `cdx status [--json] [--refresh]` | Show token usage table for all sessions; JSON returns a versioned payload with structured warnings |
338
342
  | `cdx status --small [--refresh]` / `cdx status -s [--refresh]` | Show compact token usage table without provider, blocking quota, credits, and updated columns |
339
343
  | `cdx status <name> [--json] [--refresh]` | Show detailed usage breakdown for one session |
@@ -371,6 +375,8 @@ Commands with machine-readable output:
371
375
  - `cdx update --json`
372
376
  - `cdx ready --json`
373
377
  - `cdx notify ... --json`
378
+ - `cdx select ... --json`
379
+ - `cdx run ... --json`
374
380
 
375
381
  Success payloads follow a shared envelope:
376
382
 
@@ -387,7 +393,7 @@ Success payloads follow a shared envelope:
387
393
  }
388
394
  ```
389
395
 
390
- Errors use a shared stderr JSON envelope whenever `--json` is present:
396
+ Most commands use a shared stderr JSON envelope for errors whenever `--json` is present:
391
397
 
392
398
  ```json
393
399
  {
@@ -401,10 +407,44 @@ Errors use a shared stderr JSON envelope whenever `--json` is present:
401
407
  }
402
408
  ```
403
409
 
404
- `status --json` and similar commands also use the same envelope and place non-fatal issues in `warnings` instead of mixing plain-text diagnostics into `stderr`.
410
+ `status --json` and similar commands also use the same envelope and place non-fatal issues in `warnings` instead of mixing plain-text diagnostics into `stderr`. `cdx run --json` is the exception: it always writes one final JSON payload to stdout, including cdx-side and provider-start errors, so supervisors can parse a single result stream while provider stdout and stderr are captured to files.
405
411
 
406
412
  This makes `cdx-manager` usable from editor plugins, scripts, and desktop apps without scraping human-readable terminal output.
407
413
 
414
+ ### Headless Runs
415
+
416
+ `cdx run` is designed for supervisors such as Orchestia. In `--json` mode, stdout contains only the final JSON payload; provider stdout and stderr are captured to files.
417
+
418
+ ```bash
419
+ cdx run codex-work \
420
+ --cwd /path/to/workspace \
421
+ --prompt-file task_prompt.md \
422
+ --model gpt-5.3-codex \
423
+ --reasoning-effort low \
424
+ --permission workspace-write \
425
+ --timeout-seconds 1800 \
426
+ --json
427
+ ```
428
+
429
+ Use provider-based auto-selection when the caller wants cdx-manager to pick the account:
430
+
431
+ ```bash
432
+ cdx run \
433
+ --provider codex \
434
+ --cwd /path/to/workspace \
435
+ --prompt "Summarize the repo status." \
436
+ --reasoning-effort low \
437
+ --json
438
+ ```
439
+
440
+ The result includes `launcher: "cdx"`, `run_id`, selected `session`, `provider`, `exit_code`, `duration_seconds`, absolute `transcript_path`, `stdout_path`, `stderr_path`, and normalized usage token fields. Codex headless runs use `codex exec --json`; Claude headless runs use `claude --print --output-format json`. Token counts are `null` when the provider does not expose a supported JSON or JSONL usage shape.
441
+
442
+ `cdx select` exposes the same session selection logic directly:
443
+
444
+ ```bash
445
+ cdx select --provider codex --min-reasoning-effort low --require-ready --json
446
+ ```
447
+
408
448
  ---
409
449
 
410
450
  ## Backup And Restore
@@ -0,0 +1,49 @@
1
+ # Changelog (`0.6.5 -> 0.7.0`)
2
+
3
+ Release date: 2026-05-29
4
+
5
+ ## Headless Automation
6
+
7
+ - Added `cdx run --json` as a headless execution contract for automation clients such as Orchestia.
8
+ - Added explicit session execution, provider-based auto-selection, inline prompt and prompt-file support, working-directory validation, timeout handling, and stable run metadata.
9
+ - Kept JSON mode stdout reserved for the final response so callers can parse command output without terminal UI noise.
10
+ - Returned structured cdx-side and provider-side error envelopes for missing provider CLIs, invalid launch inputs, provider start failures, disabled sessions, and reasoning validation errors.
11
+
12
+ ## Session Selection
13
+
14
+ - Added `cdx select --json` with deterministic ranking from provider match, readiness, cooldown, quota health, configured priority, reasoning capability, and session name.
15
+ - Reused the same selector from `cdx run --provider ...`.
16
+ - Added priority handling improvements, including configured-priority tie-breaking and clearing selection priority.
17
+ - Allowed ready selection for local providers where remote quota signals are not applicable.
18
+
19
+ ## Reasoning Effort
20
+
21
+ - Added provider-neutral `--reasoning-effort low|medium|high` handling.
22
+ - Kept `--power` as a compatibility alias and rejected conflicting values with cdx-sourced JSON errors.
23
+ - Mapped normalized effort into Codex launch options while leaving clear extension points for other providers.
24
+
25
+ ## Artifacts and Diagnostics
26
+
27
+ - Added transcript, stdout, and stderr artifact reporting for headless runs.
28
+ - Returned absolute artifact paths and normalized nullable token usage fields on success and failure responses.
29
+ - Hardened artifact and timeout tests to cover provider failures and unknown usage.
30
+
31
+ ## Documentation and Release Readiness
32
+
33
+ - Documented the Orchestia headless delivery, headless CLI options, selection reasons, and JSON error stream behavior.
34
+ - Completed Logics release-gate documentation with rollback coverage, project changelog, release notes, duplicate triage, and release gate artifacts.
35
+ - Carried forward the `v0.6.5` release checksum metadata so standalone installer integrity checks can resolve the previous release.
36
+
37
+ ## Release Metadata
38
+
39
+ - Updated package metadata, CLI version output, README badge, pinned installer example, and release changelog to `v0.7.0`.
40
+
41
+ ## Validation and Regression Evidence
42
+
43
+ - `python -m py_compile bin/cdx src/*.py test/test_*_py.py`
44
+ - `python -m unittest discover -s test -p 'test_*_py.py'`
45
+ - `npm run lint`
46
+ - `npm test`
47
+ - `npm pack --dry-run`
48
+ - `python -m build`
49
+ - `python -m twine check dist/*`
@@ -0,0 +1,41 @@
1
+ # Changelog (`0.7.0 -> 0.7.1`)
2
+
3
+ Release date: 2026-05-29
4
+
5
+ ## Headless Automation
6
+
7
+ - Switched `cdx run --json` Codex execution to the provider-native `codex exec --json` path so headless runs no longer depend on an interactive terminal launch mode.
8
+ - Switched Claude headless execution to `claude --print --output-format json` while preserving isolated auth homes, model selection, permission mode, and effort mapping.
9
+ - Preserved Codex unattended `auto` permission behavior in headless mode with an explicit `approval_policy="never"` config override.
10
+ - Kept provider stdout and stderr captured in artifact files while cdx stdout remains reserved for the final JSON payload.
11
+
12
+ ## JSON Contract
13
+
14
+ - Added top-level `launcher: "cdx"` to `cdx run --json` result payloads so subprocess callers can identify cdx-manager responses directly.
15
+ - Ensured `launcher: "cdx"` is also present when provider auto-selection cannot find a suitable session.
16
+ - Added conservative token usage extraction for supported Codex and Claude JSON or JSONL stdout artifact shapes.
17
+ - Preserved all-null token usage when artifacts are missing, malformed, unsupported, or do not expose trusted usage data.
18
+
19
+ ## Status Display
20
+
21
+ - Clamped Claude rate-limit percentage calculations to the `0..100` range so over-limit provider utilization cannot display negative remaining availability.
22
+ - Clamped cached status percentages defensively so already-persisted invalid values render as valid availability values.
23
+ - Colored fully depleted or invalid low availability as red and high availability above 80% as bright cyan.
24
+
25
+ ## Planning Docs
26
+
27
+ - Added and completed Logics request, backlog items, and tasks for Orchestia headless token usage and provider-native launch modes.
28
+
29
+ ## Release Metadata
30
+
31
+ - Updated package metadata, CLI version output, README badge, pinned installer example, and release changelog to `v0.7.1`.
32
+
33
+ ## Validation and Regression Evidence
34
+
35
+ - `python -m unittest discover -s test -p 'test_*_py.py'`
36
+ - `npm run lint`
37
+ - `npm test`
38
+ - `npm pack --dry-run`
39
+ - `python -m build`
40
+ - `python -m twine check dist/*`
41
+ - `python3 -m logics_manager lint --require-status`
@@ -24,6 +24,14 @@
24
24
  "v0.6.4": {
25
25
  "github_tarball_sha256": "f7c83dd1ae7506cf1ae6420e718a285f4dc96a10fb3a19e24cc17e79d75a46b4",
26
26
  "github_zip_sha256": "d602800cf6b54f1e0adea751cc6b686ab2fc4a224715ade94f761df2ff7da2af"
27
+ },
28
+ "v0.6.5": {
29
+ "github_tarball_sha256": "f2280917ea75b5ae1e99a99b011f09704d89b1a7ae42497f5093e6fff9f814d9",
30
+ "github_zip_sha256": "0b8491037310ed82cf44419d0de887bc0f768c6690c69153992fc4d5cda69676"
31
+ },
32
+ "v0.7.0": {
33
+ "github_tarball_sha256": "c80231884bf20c9ae74144a1ec16e0685c2fdac67d7d93a3c6219c5ac6fc14dd",
34
+ "github_zip_sha256": "0e6af29e59d3a93a07e07656d6c0c93803a674e65830ef33fa2322649b7139c2"
27
35
  }
28
36
  }
29
37
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cdx-manager",
3
- "version": "0.6.5",
3
+ "version": "0.7.1",
4
4
  "description": "Terminal session manager for Codex and Claude accounts.",
5
5
  "license": "MIT",
6
6
  "author": "Alexandre Agostini",
package/pyproject.toml CHANGED
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "cdx-manager"
7
- version = "0.6.5"
7
+ version = "0.7.1"
8
8
  description = "Terminal session manager for Codex and Claude accounts."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -87,6 +87,15 @@ def _format_reset_date(unix_seconds):
87
87
  return f"{MONTH_ABBR[dt.month - 1]} {dt.day} {str(dt.hour).zfill(2)}:{str(dt.minute).zfill(2)}"
88
88
 
89
89
 
90
+ def _remaining_from_utilization(value):
91
+ if value is None:
92
+ return None
93
+ try:
94
+ return max(0, min(100, round((1 - float(value)) * 100)))
95
+ except (TypeError, ValueError):
96
+ return None
97
+
98
+
90
99
  def _read_http_error_message(error):
91
100
  try:
92
101
  body = error.read().decode("utf-8", errors="replace")
@@ -159,8 +168,8 @@ def fetch_claude_rate_limit_headers(access_token):
159
168
  reset_at = reset_week_at or reset_5h_at
160
169
 
161
170
  return {
162
- "remaining_5h_pct": round((1 - utilization_5h) * 100) if utilization_5h is not None else None,
163
- "remaining_week_pct": round((1 - utilization_7d) * 100) if utilization_7d is not None else None,
171
+ "remaining_5h_pct": _remaining_from_utilization(utilization_5h),
172
+ "remaining_week_pct": _remaining_from_utilization(utilization_7d),
164
173
  "reset_5h_at": reset_5h_at,
165
174
  "reset_week_at": reset_week_at,
166
175
  "reset_at": reset_at,
package/src/cli.py CHANGED
@@ -28,6 +28,8 @@ from .cli_commands import (
28
28
  handle_remove,
29
29
  handle_repair,
30
30
  handle_rename,
31
+ handle_run,
32
+ handle_select,
31
33
  handle_status,
32
34
  handle_set,
33
35
  handle_unset,
@@ -55,7 +57,7 @@ from .status_view import (
55
57
  )
56
58
  from .update_check import check_for_update
57
59
 
58
- VERSION = "0.6.5"
60
+ VERSION = "0.7.1"
59
61
 
60
62
 
61
63
  # ---------------------------------------------------------------------------
@@ -72,11 +74,13 @@ def _print_help(use_color=False):
72
74
  f" {_style('cdx status [--json] [--refresh]', '36', use_color)}",
73
75
  f" {_style('cdx status --small|-s [--refresh]', '36', use_color)}",
74
76
  f" {_style('cdx status <name> [--json] [--refresh]', '36', use_color)}",
77
+ f" {_style('cdx select --provider PROVIDER [--min-reasoning-effort low|medium|high] [--min-power low|medium|high] [--require-ready] [--refresh] --json', '36', use_color)}",
78
+ f" {_style('cdx run [session] --cwd PATH (--prompt-file PATH|--prompt TEXT) [--provider PROVIDER] [--model MODEL] [--reasoning-effort low|medium|high] [--power low|medium|high] [--permission review|default|auto|full|workspace-write|read-only|danger-full-access] [--timeout-seconds N] --json', '36', use_color)}",
75
79
  f" {_style('cdx context show|path|init|edit|clear|set [text...] [--json]', '36', use_color)}",
76
80
  f" {_style('cdx config <name> [--json]', '36', use_color)}",
77
81
  f" {_style('cdx power|perm|fast|model <name|all|provider:PROVIDER|a,b> <value|default> [--json]', '36', use_color)}",
78
- f" {_style('cdx set <name>|--sessions all|a,b|--provider PROVIDER [--power low|medium|high|xhigh|max] [--permission review|default|auto|full] [--fast on|off] [--model MODEL] [--json]', '36', use_color)}",
79
- f" {_style('cdx unset <name>|--sessions all|a,b|--provider PROVIDER (--power|--permission|--fast|--model|--all) [--json]', '36', use_color)}",
82
+ f" {_style('cdx set <name>|--sessions all|a,b|--provider PROVIDER [--power low|medium|high|xhigh|max] [--permission review|default|auto|full] [--fast on|off] [--model MODEL] [--priority 0..100] [--json]', '36', use_color)}",
83
+ f" {_style('cdx unset <name>|--sessions all|a,b|--provider PROVIDER (--power|--permission|--fast|--model|--priority|--all) [--json]', '36', use_color)}",
80
84
  f" {_style('cdx history [name] [--limit N] [--summary] [--since 7d|today|DATE] [--from DATE] [--to DATE] [--json]', '36', use_color)}",
81
85
  f" {_style('cdx last [--json]', '36', use_color)}",
82
86
  f" {_style('cdx handoff <name> [--json]', '36', use_color)}",
@@ -228,12 +232,13 @@ def main(argv, options=None):
228
232
  "service": service,
229
233
  "signal_emitter": signal_emitter,
230
234
  "spawn": spawn,
235
+ "spawn_headless": options.get("spawn_headless"),
231
236
  "spawn_sync": spawn_sync,
232
237
  "stdin_is_tty": stdin_is_tty,
233
238
  "version": VERSION,
234
239
  "cwd": options.get("cwd") or os.getcwd(),
235
240
  "update_notice": _get_update_notice(service, env, options) if command not in (
236
- "add", "cp", "ren", "rename", "mv", "rmv", "clean", "doctor", "repair", "update", "ready", "notify", "context", "config", "set", "unset", "power", "perm", "fast", "model", "history", "handoff", "login", "logout", "disable", "enable", "export", "import", "help", "version"
241
+ "add", "cp", "ren", "rename", "mv", "rmv", "clean", "doctor", "repair", "update", "ready", "notify", "context", "config", "set", "unset", "power", "perm", "fast", "model", "history", "handoff", "login", "logout", "disable", "enable", "export", "import", "select", "run", "help", "version"
237
242
  ) else None,
238
243
  "use_color": use_color,
239
244
  }
@@ -309,6 +314,12 @@ def main(argv, options=None):
309
314
  if command == "status":
310
315
  return handle_status(rest, ctx)
311
316
 
317
+ if command == "select":
318
+ return handle_select(rest, ctx)
319
+
320
+ if command == "run":
321
+ return handle_run(rest, ctx)
322
+
312
323
  if command == "login":
313
324
  return handle_login(rest, ctx)
314
325