aisc-cli 0.1.8__tar.gz → 0.1.10__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 (106) hide show
  1. {aisc_cli-0.1.8/src/aisc_cli.egg-info → aisc_cli-0.1.10}/PKG-INFO +2 -2
  2. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/README.md +1 -1
  3. aisc_cli-0.1.10/src/aisc/VERSION +1 -0
  4. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/application/bundle_fetch.py +144 -3
  5. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/application/cc_switch_resolver.py +34 -13
  6. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/application/conversation.py +73 -36
  7. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/application/docker_lifecycle.py +1536 -1240
  8. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/application/doctor.py +3 -0
  9. aisc_cli-0.1.10/src/aisc/application/extensions.py +348 -0
  10. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/application/tool_versions.py +2 -1
  11. aisc_cli-0.1.10/src/aisc/application/update_health.py +94 -0
  12. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/cli/commands/artifact.py +4 -1
  13. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/cli/commands/build.py +140 -5
  14. aisc_cli-0.1.10/src/aisc/cli/commands/extensions.py +277 -0
  15. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/cli/main.py +246 -1
  16. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/domain/cc_switch_release.py +2 -2
  17. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/domain/models.py +9 -1
  18. {aisc_cli-0.1.8 → aisc_cli-0.1.10/src/aisc_cli.egg-info}/PKG-INFO +2 -2
  19. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc_cli.egg-info/SOURCES.txt +3 -0
  20. aisc_cli-0.1.8/src/aisc/VERSION +0 -1
  21. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/LICENSE +0 -0
  22. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/MANIFEST.in +0 -0
  23. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/pyproject.toml +0 -0
  24. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/setup.cfg +0 -0
  25. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/__init__.py +0 -0
  26. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/__main__.py +0 -0
  27. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/adapters/__init__.py +0 -0
  28. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/adapters/config_reader.py +0 -0
  29. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/adapters/container_registry.py +0 -0
  30. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/adapters/data_root_store.py +0 -0
  31. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/adapters/docker_.py +0 -0
  32. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/adapters/docker_gateway.py +0 -0
  33. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/adapters/docker_sdk_backed.py +0 -0
  34. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/adapters/maintenance_lock.py +0 -0
  35. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/adapters/state_file.py +0 -0
  36. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/adapters/system.py +0 -0
  37. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/adapters/windows_config_reader.py +0 -0
  38. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/adapters/workspace_lease_store.py +0 -0
  39. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/application/__init__.py +0 -0
  40. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/application/artifact.py +0 -0
  41. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/application/cc_switch_provider.py +0 -0
  42. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/application/config_service.py +0 -0
  43. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/application/data_migration.py +0 -0
  44. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/application/data_root.py +0 -0
  45. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/application/legacy_scan.py +0 -0
  46. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/application/network_subscription.py +0 -0
  47. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/application/profile_service.py +0 -0
  48. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/application/provider.py +0 -0
  49. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/application/repair.py +0 -0
  50. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/application/resources.py +0 -0
  51. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/application/runtime.py +0 -0
  52. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/application/session.py +0 -0
  53. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/application/toolchain.py +0 -0
  54. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/application/update.py +0 -0
  55. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/application/usage.py +0 -0
  56. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/application/version.py +0 -0
  57. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/application/web_gateway.py +0 -0
  58. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/application/work_collection.py +0 -0
  59. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/application/worklog.py +0 -0
  60. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/application/workspace_reconcile.py +0 -0
  61. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/applog.py +0 -0
  62. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/cli/__init__.py +0 -0
  63. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/cli/build_progress_parser.py +0 -0
  64. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/cli/commands/__init__.py +0 -0
  65. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/cli/commands/agents.py +0 -0
  66. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/cli/commands/bundle.py +0 -0
  67. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/cli/commands/cc_switch.py +0 -0
  68. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/cli/commands/config.py +0 -0
  69. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/cli/commands/container.py +0 -0
  70. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/cli/commands/conversation.py +0 -0
  71. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/cli/commands/data_root.py +0 -0
  72. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/cli/commands/logs.py +0 -0
  73. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/cli/commands/network.py +0 -0
  74. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/cli/commands/profile.py +0 -0
  75. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/cli/commands/provider.py +0 -0
  76. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/cli/commands/run.py +0 -0
  77. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/cli/commands/runs.py +0 -0
  78. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/cli/commands/runtime.py +0 -0
  79. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/cli/commands/serve.py +0 -0
  80. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/cli/commands/serve_fs.py +0 -0
  81. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/cli/commands/session.py +0 -0
  82. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/cli/commands/update.py +0 -0
  83. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/cli/commands/usage.py +0 -0
  84. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/cli/commands/wizard.py +0 -0
  85. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/cli/commands/work_record.py +0 -0
  86. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/cli/commands/worklog.py +0 -0
  87. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/cli/commands/workspaces.py +0 -0
  88. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/cli/help_i18n.py +0 -0
  89. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/cli/output.py +0 -0
  90. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/cli/tutorial.py +0 -0
  91. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/domain/__init__.py +0 -0
  92. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/domain/artifacts.py +0 -0
  93. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/domain/config.py +0 -0
  94. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/domain/data_migration.py +0 -0
  95. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/domain/data_root.py +0 -0
  96. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/domain/docker_ownership.py +0 -0
  97. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/domain/gateway.py +0 -0
  98. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/domain/toolchain.py +0 -0
  99. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/domain/web_services.py +0 -0
  100. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/domain/workspace_lease.py +0 -0
  101. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/schemas/__init__.py +0 -0
  102. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc/schemas/config_schema.py +0 -0
  103. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc_cli.egg-info/dependency_links.txt +0 -0
  104. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc_cli.egg-info/entry_points.txt +0 -0
  105. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc_cli.egg-info/requires.txt +0 -0
  106. {aisc_cli-0.1.8 → aisc_cli-0.1.10}/src/aisc_cli.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aisc-cli
3
- Version: 0.1.8
3
+ Version: 0.1.10
4
4
  Summary: AISC CLI — Super Claude workstation management
5
5
  Author: AISC contributors
6
6
  License-Expression: MIT
@@ -116,7 +116,7 @@ AISC 尚未代码签名。SmartScreen 提示时,请先确认文件来自项目
116
116
  - **多工作区**:最多同时打开 3 个工作区,页签条切换;关闭即自动停止并清理对应容器。顶栏「关闭工作区」可随时回到选择页重选(清理运行环境,窗口保留)。
117
117
  - **彻底忘记工作区**:工作区历史右键 -> 彻底忘记,单事务清理 AISC 数据根内该工作区的状态与记录(容器先停止删除,失败自动回滚);你磁盘上的原始文件永不被触碰。
118
118
  - **诊断**:任何页面可打开诊断对话框(环境检查、最近日志、导出诊断包)。
119
- - **应用自更新**:设置页「检查更新」直接升级——下载带可视化进度条,确认后静默安装并**自动重启**新版(升级链含镜像重建,最长约 30 分钟)。
119
+ - **应用自更新**:Windows 设置页「检查更新」→「下载更新」,校验完成后点击「退出更新」并确认,资源管理器选中安装包、正常打开安装向导后 Workbench 退出;可按向导完成更新。下载完成本身不会退出,取消或启动失败仍保留应用。其他平台按提示手动安装。
120
120
 
121
121
  ### Provider 模板清单
122
122
 
@@ -85,7 +85,7 @@ AISC 尚未代码签名。SmartScreen 提示时,请先确认文件来自项目
85
85
  - **多工作区**:最多同时打开 3 个工作区,页签条切换;关闭即自动停止并清理对应容器。顶栏「关闭工作区」可随时回到选择页重选(清理运行环境,窗口保留)。
86
86
  - **彻底忘记工作区**:工作区历史右键 -> 彻底忘记,单事务清理 AISC 数据根内该工作区的状态与记录(容器先停止删除,失败自动回滚);你磁盘上的原始文件永不被触碰。
87
87
  - **诊断**:任何页面可打开诊断对话框(环境检查、最近日志、导出诊断包)。
88
- - **应用自更新**:设置页「检查更新」直接升级——下载带可视化进度条,确认后静默安装并**自动重启**新版(升级链含镜像重建,最长约 30 分钟)。
88
+ - **应用自更新**:Windows 设置页「检查更新」→「下载更新」,校验完成后点击「退出更新」并确认,资源管理器选中安装包、正常打开安装向导后 Workbench 退出;可按向导完成更新。下载完成本身不会退出,取消或启动失败仍保留应用。其他平台按提示手动安装。
89
89
 
90
90
  ### Provider 模板清单
91
91
 
@@ -0,0 +1 @@
1
+ 0.1.10
@@ -23,6 +23,7 @@ Two halves:
23
23
  from __future__ import annotations
24
24
 
25
25
  import hashlib
26
+ import gzip
26
27
  import json
27
28
  import os
28
29
  import re
@@ -35,6 +36,7 @@ import time
35
36
  import urllib.error
36
37
  import urllib.request
37
38
  import zipfile
39
+ import zlib
38
40
  from pathlib import Path
39
41
  from typing import Any, Callable, Dict, List, Optional, Sequence, Set, Tuple
40
42
 
@@ -350,6 +352,8 @@ def verify_staged_bundle(bundle_root: Path) -> List[str]:
350
352
  else:
351
353
  errors.append("container/Dockerfile missing")
352
354
  errors.extend(_verify_vendor_checksums(bundle_root))
355
+ errors.extend(_verify_npm_presets(bundle_root))
356
+ errors.extend(_verify_yazi_payload(bundle_root))
353
357
  errors.extend(_audit_forbidden(bundle_root))
354
358
  if not (bundle_root / "container" / "_bundle" / "plugins").exists():
355
359
  errors.append("container/_bundle/plugins missing")
@@ -358,6 +362,140 @@ def verify_staged_bundle(bundle_root: Path) -> List[str]:
358
362
  return errors
359
363
 
360
364
 
365
+ def _verify_npm_presets(bundle_root: Path) -> List[str]:
366
+ """Check ignored native payloads too: filenames alone cannot prove pairing.
367
+
368
+ Companions may be absent (the pinned online fallback remains supported),
369
+ but every payload included in a bundle must match its factory main package.
370
+ """
371
+ from aisc.application.tool_versions import _parse_env_file
372
+
373
+ pins = _parse_env_file(bundle_root / "config" / "versions.env")
374
+ dl = bundle_root / "container" / "downloads"
375
+ errors: List[str] = []
376
+
377
+ def metadata(path: Path) -> dict:
378
+ # tarfile can stop at the tar EOF before gzip validates its trailer.
379
+ # Drain the compression stream so truncated/CRC-damaged companions
380
+ # cannot pass merely because their package.json is still readable.
381
+ with gzip.open(path, "rb") as compressed:
382
+ while compressed.read(1024 * 1024):
383
+ pass
384
+ with tarfile.open(path, "r:gz") as archive:
385
+ member = archive.getmember("package/package.json")
386
+ if not member.isfile() or member.size > 1024 * 1024:
387
+ raise ValueError("invalid package metadata member")
388
+ stream = archive.extractfile(member)
389
+ if stream is None:
390
+ raise ValueError("missing package metadata")
391
+ data = json.load(stream)
392
+ if not isinstance(data, dict):
393
+ raise ValueError("package metadata must be an object")
394
+ return data
395
+
396
+ for prefix, name, key in (("codex", "@openai/codex", "CODEX_VERSION"),
397
+ ("claude-code", "@anthropic-ai/claude-code", "CLAUDE_CODE_VERSION")):
398
+ payloads = list(dl.glob(f"{prefix}-*.tgz"))
399
+ if not payloads:
400
+ continue
401
+ version = pins.get(key, "")
402
+ main = dl / f"{prefix}-{version}.tgz"
403
+ try:
404
+ meta = metadata(main)
405
+ if (meta.get("name"), meta.get("version")) != (name, version):
406
+ raise ValueError("main metadata differs from factory pin")
407
+ allowed = {main.name: (name, version)}
408
+ optional = meta.get("optionalDependencies") or {}
409
+ for arch in ("x64", "arm64"):
410
+ dependency = f"{name}-linux-{arch}"
411
+ spec = optional.get(dependency)
412
+ if not isinstance(spec, str) or not spec:
413
+ continue
414
+ if spec.startswith("npm:"):
415
+ package_name, _, package_version = spec[4:].rpartition("@")
416
+ else:
417
+ package_name, package_version = dependency, spec
418
+ allowed[f"{prefix}-linux-{arch}-{package_version}.tgz"] = (package_name, package_version)
419
+ for path in payloads:
420
+ expected = allowed.get(path.name)
421
+ if expected is None:
422
+ errors.append(f"npm preset stale or unexpected: {path.name}")
423
+ continue
424
+ actual = meta if path == main else metadata(path)
425
+ if (actual.get("name"), actual.get("version")) != expected:
426
+ errors.append(f"npm preset metadata mismatch: {path.name}")
427
+ except (OSError, EOFError, zlib.error, tarfile.TarError, KeyError, ValueError, AttributeError) as exc:
428
+ errors.append(f"npm preset {prefix} invalid: {exc}")
429
+ return errors
430
+
431
+
432
+ def _verify_yazi_payload(bundle_root: Path) -> List[str]:
433
+ """Require exactly one officially pinned yazi payload for the target arch."""
434
+ from aisc.application.tool_versions import _parse_env_file
435
+
436
+ pins = _parse_env_file(bundle_root / "config" / "versions.env")
437
+ version = str(pins.get("YAZI_VERSION", "")).removeprefix("v").strip()
438
+ expected = {
439
+ f"yazi-{arch}-unknown-linux-musl-v{version}.zip": (
440
+ str(pins.get(hash_key, "")).strip().lower(),
441
+ str(pins.get(size_key, "")).strip(),
442
+ arch,
443
+ )
444
+ for arch, hash_key, size_key in (
445
+ ("x86_64", "YAZI_X86_64_SHA256", "YAZI_X86_64_BYTES"),
446
+ ("aarch64", "YAZI_ARM64_SHA256", "YAZI_ARM64_BYTES"),
447
+ )
448
+ }
449
+ errors: List[str] = []
450
+ if not version or not re.fullmatch(r"[0-9]+\.[0-9]+\.[0-9]+", version):
451
+ errors.append("yazi payload version pin invalid")
452
+ return errors
453
+ for name, (digest, size, _arch) in expected.items():
454
+ if not re.fullmatch(r"[0-9a-f]{64}", digest):
455
+ errors.append(f"yazi payload digest pin invalid: {name}")
456
+ if not size.isdigit():
457
+ errors.append(f"yazi payload size pin invalid: {name}")
458
+ if errors:
459
+ return errors
460
+
461
+ downloads = bundle_root / "container" / "downloads"
462
+ found = {
463
+ path.name
464
+ for path in downloads.glob("yazi-*.zip")
465
+ if path.is_file()
466
+ }
467
+ targets = sorted(found & expected.keys())
468
+ if len(targets) != 1:
469
+ errors.append(
470
+ "bundle target yazi payload missing"
471
+ if not targets
472
+ else "bundle must contain exactly one target-architecture yazi payload"
473
+ )
474
+ if len(targets) > 1:
475
+ errors.append(f"duplicate target yazi payloads: {', '.join(targets)}")
476
+ for name in sorted(found - expected.keys()):
477
+ errors.append(f"unexpected yazi payload: {name}")
478
+ for name in targets:
479
+ path = downloads / name
480
+ digest, size, _arch = expected[name]
481
+ actual_digest = _sha256_file(path)
482
+ if actual_digest != digest:
483
+ errors.append(
484
+ f"yazi payload hash mismatch: {name}: expected {digest[:16]}..., "
485
+ f"got {actual_digest[:16]}..."
486
+ )
487
+ try:
488
+ actual_size = str(path.stat().st_size)
489
+ except OSError as exc:
490
+ errors.append(f"yazi payload unreadable: {name}: {exc}")
491
+ continue
492
+ if actual_size != size:
493
+ errors.append(
494
+ f"yazi payload size mismatch: {name}: expected {size}, got {actual_size}"
495
+ )
496
+ return errors
497
+
498
+
361
499
  def _audit_forbidden(bundle_root: Path) -> List[str]:
362
500
  es = []
363
501
  for dp, dns, fns in os.walk(str(bundle_root)):
@@ -452,10 +590,13 @@ def bundle_compatible(bundle_root: Path, cli_version: str) -> Tuple[bool, str]:
452
590
  mp = bundle_root / "manifest.json"
453
591
  try:
454
592
  m = json.loads(mp.read_text(encoding="utf-8"))
455
- except (OSError, json.JSONDecodeError) as exc:
593
+ except (OSError, UnicodeError, json.JSONDecodeError) as exc:
456
594
  return False, f"manifest unreadable: {exc}"
457
- if m.get("schema_version") != 1:
458
- return False, f"manifest schema_version={m.get('schema_version')!r}, expected 1"
595
+ if not isinstance(m, dict):
596
+ return False, "manifest must be a JSON object"
597
+ schema = m.get("schema_version")
598
+ if type(schema) is not int or schema != 1:
599
+ return False, f"manifest schema_version={schema!r}, expected integer 1"
459
600
  compat = m.get("compatible_cli_versions")
460
601
  if not isinstance(compat, list) or not all(isinstance(v, str) for v in compat):
461
602
  return False, "manifest compatible_cli_versions malformed"
@@ -48,6 +48,10 @@ from aisc.domain.cc_switch_release import (
48
48
 
49
49
 
50
50
  DEFAULT_API_BASE = "https://api.github.com"
51
+ #: ghfast.top rejects API paths with 403; gh-proxy.com has been verified to
52
+ #: proxy GitHub's JSON API. Only supplement the default base — an explicit
53
+ #: corporate/test base must remain the sole source of truth.
54
+ DEFAULT_API_MIRROR_PREFIX = "https://gh-proxy.com/"
51
55
  DEFAULT_TIMEOUT_S = 15.0
52
56
  DEFAULT_TTL_S = 600.0
53
57
  DEFAULT_PER_PAGE = 50
@@ -134,6 +138,9 @@ class CcSwitchResolver:
134
138
  self._transport = transport
135
139
  self._cache_dir = Path(cache_dir) if cache_dir is not None else None
136
140
  self._api_base = (api_base or os.environ.get("AISC_GH_API_BASE") or DEFAULT_API_BASE).rstrip("/")
141
+ self._api_bases = [self._api_base]
142
+ if self._api_base == DEFAULT_API_BASE:
143
+ self._api_bases.append(f"{DEFAULT_API_MIRROR_PREFIX}{DEFAULT_API_BASE}")
137
144
  self._token = token or os.environ.get("AISC_GH_API_TOKEN") or ""
138
145
  self._timeout = timeout
139
146
  self._ttl_s = ttl_s
@@ -201,9 +208,9 @@ class CcSwitchResolver:
201
208
 
202
209
  # --- GitHub API ----------------------------------------------------------
203
210
 
204
- def _fetch_page(self, page: int) -> Tuple[List[Dict[str, Any]], bool]:
211
+ def _fetch_page(self, page: int, api_base: str) -> Tuple[List[Dict[str, Any]], bool]:
205
212
  url = (
206
- f"{self._api_base}/repos/{UPSTREAM_REPO}/releases"
213
+ f"{api_base}/repos/{UPSTREAM_REPO}/releases"
207
214
  f"?per_page={DEFAULT_PER_PAGE}&page={page}"
208
215
  )
209
216
  headers: Dict[str, str] = {"Accept": "application/vnd.github+json"}
@@ -235,17 +242,31 @@ class CcSwitchResolver:
235
242
  return body, len(body) < DEFAULT_PER_PAGE
236
243
 
237
244
  def _fetch_releases(self) -> List[Dict[str, Any]]:
238
- all_releases: List[Dict[str, Any]] = []
239
- for page in range(1, DEFAULT_MAX_PAGES + 1):
240
- page_releases, last = self._fetch_page(page)
241
- all_releases.extend(page_releases)
242
- if last or not page_releases:
243
- break
244
- else:
245
- # Exhausted pagination without finding a terminal page; keep what
246
- # we have — selection fails closed if the target isn't in range.
247
- pass
248
- return all_releases
245
+ last_error: Optional[ResolveError] = None
246
+ for api_base in self._api_bases:
247
+ try:
248
+ all_releases: List[Dict[str, Any]] = []
249
+ for page in range(1, DEFAULT_MAX_PAGES + 1):
250
+ page_releases, last = self._fetch_page(page, api_base)
251
+ all_releases.extend(page_releases)
252
+ if last or not page_releases:
253
+ break
254
+ else:
255
+ # Exhausted pagination without finding a terminal page;
256
+ # keep what we have — selection fails closed if the target
257
+ # isn't in range.
258
+ pass
259
+ return all_releases
260
+ except ResolveError as exc:
261
+ if exc.code not in (
262
+ CC_SWITCH_ERROR_NETWORK,
263
+ CC_SWITCH_ERROR_RATE_LIMITED,
264
+ ):
265
+ raise
266
+ last_error = exc
267
+ raise last_error or ResolveError(
268
+ CC_SWITCH_ERROR_NETWORK, "github api unavailable"
269
+ )
249
270
 
250
271
  # --- cache ---------------------------------------------------------------
251
272
 
@@ -9,9 +9,10 @@ filename carries the id).
9
9
  Oversized files (>10MB) are never fully parsed: a streaming head scan of
10
10
  the first 200 parseable lines yields title/time, ``message_count`` stays
11
11
  ``null`` and the entry is annotated ``file_too_large``. Malformed JSON
12
- lines are skipped; a file with at least one parseable user message but
13
- some corrupt lines is annotated ``malformed`` and kept, ``resumable:
14
- false``. Entries with zero parseable user messages are excluded.
12
+ lines are skipped. R4: scan limits and a damaged tail do not disable native
13
+ provider resume for a file with parseable user messages. The reader reports
14
+ malformed/omitted entries; provider files stay untouched. Entries with zero
15
+ parseable user messages are excluded.
15
16
 
16
17
  D-5 (decisions.md): conversation ids are provider-native — Codex uses
17
18
  time-ordered UUIDv7 in the wild (see the frozen T0 codex fixtures), so id
@@ -22,6 +23,7 @@ still rejected (the check's stated intent).
22
23
  from __future__ import annotations
23
24
 
24
25
  import json
26
+ from collections import deque
25
27
  import os
26
28
  import re
27
29
  from dataclasses import dataclass
@@ -303,16 +305,9 @@ def _summarize(agent: str, conv_id: str, file_size: int,
303
305
  excluded from the list (zero parseable user messages)."""
304
306
  if scan.user_messages == 0:
305
307
  return None
306
- resumable = True
307
- reason: Optional[str] = None
308
308
  message_count: Optional[int] = scan.user_messages
309
309
  if file_size > MAX_JSONL_BYTES:
310
- resumable = False
311
- reason = "file_too_large"
312
310
  message_count = None # head scan only — a full count was not taken
313
- elif scan.malformed_seen:
314
- resumable = False
315
- reason = "malformed"
316
311
  entry: Dict[str, Any] = {
317
312
  "conversation_id": conv_id,
318
313
  "agent": agent,
@@ -321,11 +316,11 @@ def _summarize(agent: str, conv_id: str, file_size: int,
321
316
  "last_at": scan.last_ts,
322
317
  "message_count": message_count,
323
318
  "file_size": file_size,
324
- "resumable": resumable,
319
+ # The list's parser budget is not a provider resume limit. A partial
320
+ # final write after a crash must not grey out the Resume action.
321
+ "resumable": True,
325
322
  "parent_thread_id": scan.parent_thread_id,
326
323
  }
327
- if not resumable:
328
- entry["unavailable_reason"] = reason
329
324
  return entry
330
325
 
331
326
 
@@ -574,9 +569,9 @@ def rename_conversation(workspace: str, conversation_id: str, agent: str,
574
569
  # ---------------------------------------------------------------------------
575
570
 
576
571
  CONVERSATION_READ_SCHEMA = "aisc.conversation-read/v1"
577
- _READ_TEXT_CAP = 8000 # per user/assistant message (chars)
578
- _READ_REASONING_CAP = 4000
579
- _READ_TOOL_CAP = 4000 # per tool_use input / tool_result output
572
+ _READ_TEXT_CAP = 256_000 # preserve complete long-form Markdown answers
573
+ _READ_REASONING_CAP = 32_000
574
+ _READ_TOOL_CAP = 32_000
580
575
  _READ_MAX_MESSAGES = 4000 # hard bound on the rendered stream
581
576
 
582
577
 
@@ -635,6 +630,29 @@ def _read_summary_text(summary: Any) -> Optional[str]:
635
630
  return None
636
631
 
637
632
 
633
+ def _read_attachment(block: Dict[str, Any]) -> Dict[str, Any]:
634
+ """Keep non-text objects visible without interpreting executable content."""
635
+ bt = str(block.get("type", "attachment"))
636
+ kind = "image" if "image" in bt else "audio" if "audio" in bt else "video" if "video" in bt else "file"
637
+ source = block.get("source")
638
+ source = source if isinstance(source, dict) else {}
639
+ url = block.get("image_url") or block.get("file_url") or block.get("url") or source.get("url") or block.get("path")
640
+ if isinstance(url, dict):
641
+ url = url.get("url")
642
+ mime = source.get("media_type") or block.get("mime_type")
643
+ if source.get("type") == "base64" and isinstance(source.get("data"), str) and isinstance(mime, str):
644
+ url = f"data:{mime};base64,{source['data']}"
645
+ attachment: Dict[str, Any] = {
646
+ "kind": kind,
647
+ "name": _read_cap(block.get("filename") or block.get("title") or block.get("name") or bt, 256),
648
+ }
649
+ if isinstance(url, str) and len(url) <= 12_000_000:
650
+ attachment["url"] = url
651
+ else:
652
+ attachment["detail"] = _read_cap(_read_as_text(block), _READ_TOOL_CAP)
653
+ return attachment
654
+
655
+
638
656
  def _read_entries_codex(obj: Dict[str, Any]) -> List[Dict[str, Any]]:
639
657
  """One codex rollout line → zero or more rendered entries. Rendered:
640
658
  user/assistant messages, reasoning summaries, function calls/results.
@@ -649,39 +667,44 @@ def _read_entries_codex(obj: Dict[str, Any]) -> List[Dict[str, Any]]:
649
667
  kind = payload.get("type")
650
668
  if kind == "message":
651
669
  role = payload.get("role")
652
- if role == "user":
653
- text = _read_join_text(payload.get("content"), "input_text")
654
- if not text or not text.strip():
655
- return []
656
- if _CONTEXT_TITLE_RE.match(text.lstrip()):
657
- return []
658
- return [{"role": "user", "kind": "message", "text": text, "ts": ts}]
659
- if role == "assistant":
660
- text = _read_join_text(payload.get("content"), "output_text")
661
- if not text or not text.strip():
662
- return []
663
- return [{"role": "assistant", "kind": "message", "text": text, "ts": ts}]
664
- return []
670
+ if role not in ("user", "assistant"):
671
+ return []
672
+ content = payload.get("content")
673
+ text = _read_join_text(content, "input_text" if role == "user" else "output_text") or ""
674
+ if role == "user" and _CONTEXT_TITLE_RE.match(text.lstrip()):
675
+ return []
676
+ attachments = [_read_attachment(b) for b in content if isinstance(b, dict) and b.get("type") not in ("input_text", "output_text")] if isinstance(content, list) else []
677
+ if not text.strip() and not attachments:
678
+ return []
679
+ entry = {"role": role, "kind": "message", "text": text, "ts": ts}
680
+ if attachments:
681
+ entry["attachments"] = attachments
682
+ if isinstance(payload.get("phase"), str):
683
+ entry["phase"] = payload["phase"]
684
+ return [entry]
665
685
  if kind == "reasoning":
666
686
  text = _read_summary_text(payload.get("summary"))
667
687
  if not text:
668
688
  return []
669
689
  return [{"role": "assistant", "kind": "reasoning", "text": text, "ts": ts}]
670
- if kind == "function_call":
690
+ if kind in ("function_call", "custom_tool_call", "local_shell_call", "web_search_call"):
671
691
  name = payload.get("name")
672
692
  call_id = payload.get("call_id")
673
693
  return [{
674
694
  "role": "assistant", "kind": "tool_use",
675
695
  "name": name if isinstance(name, str) else "tool",
676
- "text": _read_as_text(payload.get("arguments")),
696
+ "text": _read_as_text(payload.get("arguments", payload.get("input", payload.get("action")))),
677
697
  "call_id": call_id if isinstance(call_id, str) else None,
678
698
  "ts": ts,
679
699
  }]
680
- if kind == "function_call_output":
700
+ if kind in ("function_call_output", "custom_tool_call_output"):
681
701
  call_id = payload.get("call_id")
702
+ output = payload.get("output")
703
+ attachments = [_read_attachment(b) for b in output if isinstance(b, dict) and b.get("type") not in ("text", "input_text", "output_text")] if isinstance(output, list) else []
682
704
  return [{
683
705
  "role": "tool", "kind": "tool_result",
684
- "text": _read_as_text(payload.get("output")),
706
+ "text": _read_join_text(output, "text") if isinstance(output, list) else _read_as_text(output),
707
+ "attachments": attachments,
685
708
  "call_id": call_id if isinstance(call_id, str) else None,
686
709
  "ts": ts,
687
710
  }]
@@ -738,13 +761,23 @@ def _read_entries_claude(obj: Dict[str, Any]) -> List[Dict[str, Any]]:
738
761
  elif bt == "tool_result":
739
762
  inner = block.get("content")
740
763
  text = inner if isinstance(inner, str) else _read_join_text(inner, "text")
764
+ attachments = [_read_attachment(b) for b in inner if isinstance(b, dict) and b.get("type") != "text"] if isinstance(inner, list) else []
741
765
  call_id = block.get("tool_use_id")
742
766
  out.append({
743
767
  "role": "tool", "kind": "tool_result",
744
768
  "text": text,
769
+ "attachments": attachments,
745
770
  "call_id": call_id if isinstance(call_id, str) else None,
746
771
  "ts": ts,
747
772
  })
773
+ elif bt != "redacted_thinking":
774
+ # Image-only user entries must remain a user turn too.
775
+ attachment = _read_attachment(block)
776
+ if out and out[-1]["kind"] == "message":
777
+ out[-1].setdefault("attachments", []).append(attachment)
778
+ else:
779
+ out.append({"role": role, "kind": "message", "text": "", "ts": ts,
780
+ "attachments": [attachment]})
748
781
  return out
749
782
 
750
783
 
@@ -785,7 +818,8 @@ def read_conversation(workspace: str, conversation_id: str, agent: str,
785
818
  error_code=ERROR_UNRESUMABLE,
786
819
  )
787
820
  extract = _READ_EXTRACTORS[agent]
788
- entries: List[Dict[str, Any]] = []
821
+ entries: deque[Dict[str, Any]] = deque(maxlen=_READ_MAX_MESSAGES)
822
+ omitted_entries = 0
789
823
  malformed_lines = 0
790
824
  try:
791
825
  fh = path.open("r", encoding="utf-8", errors="replace")
@@ -808,8 +842,8 @@ def read_conversation(workspace: str, conversation_id: str, agent: str,
808
842
  if not isinstance(obj, dict):
809
843
  continue
810
844
  for entry in extract(obj):
811
- if len(entries) >= _READ_MAX_MESSAGES:
812
- break # stream bound; the tail window still pages correctly
845
+ if len(entries) == _READ_MAX_MESSAGES:
846
+ omitted_entries += 1
813
847
  entries.append(entry)
814
848
  # Pair tool results into their calls (nearest preceding unmatched match);
815
849
  # unpaired results stay standalone so nothing is silently dropped.
@@ -821,6 +855,8 @@ def read_conversation(workspace: str, conversation_id: str, agent: str,
821
855
  call = open_calls.get(entry["call_id"])
822
856
  if call is not None and "result" not in call:
823
857
  call["result"] = entry.pop("text")
858
+ if entry.get("attachments"):
859
+ call["result_attachments"] = entry["attachments"]
824
860
  entry["consumed"] = True
825
861
  rendered = [e for e in entries if not e.get("consumed")]
826
862
  for i, entry in enumerate(rendered):
@@ -854,4 +890,5 @@ def read_conversation(workspace: str, conversation_id: str, agent: str,
854
890
  "messages": rendered[start:end],
855
891
  "malformed_lines": malformed_lines,
856
892
  "degraded_reason": "malformed" if malformed_lines else None,
893
+ "omitted_entries": omitted_entries,
857
894
  }