Spaces:
Running

File size: 1,317 Bytes
e99df76
691dc7c
2415446
8e438ab
2415446
abe1c43
691dc7c
 
 
 
2415446
691dc7c
 
2415446
691dc7c
2415446
8e438ab
691dc7c
8e438ab
 
691dc7c
 
 
 
 
 
 
 
 
8e438ab
2415446
 
8e438ab
 
 
691dc7c
 
8e438ab
 
2415446
 
8e438ab
 
691dc7c
8e438ab
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"""Installed Codex launcher and external-client credential handoff."""

import sys
from collections.abc import Sequence

from free_claude_code.config.loader import get_settings
from free_claude_code.harnesses.codex import (
    CODEX_INSTALL_HINT,
    PRINT_PROXY_AUTH_TOKEN_FLAG,
    prepare_codex_launch,
)
from free_claude_code.harnesses.launch import PreparedLaunch
from free_claude_code.harnesses.resources import LaunchResources

from .runner import HarnessSpec, LaunchContext, launch_harness


def _configure(
    ctx: LaunchContext, args: list[str], files: LaunchResources
) -> PreparedLaunch:
    catalog = ctx.require_catalog()
    return prepare_codex_launch(
        binary_path=ctx.binary_path,
        proxy_root_url=ctx.proxy_root_url,
        model=ctx.settings.model,
        models=catalog.models,
        base_env=ctx.base_env,
        args=args,
        files=files,
    )


SPEC = HarnessSpec(
    binary_name="codex",
    display_name="Codex CLI",
    install_hint=CODEX_INSTALL_HINT,
    configure=_configure,
    catalog_view="responses",
)


def launch(argv: Sequence[str] | None = None) -> None:
    args = list(sys.argv[1:] if argv is None else argv)
    if args == [PRINT_PROXY_AUTH_TOKEN_FLAG]:
        print(get_settings().proxy_auth_token)
        return
    launch_harness(SPEC, args)