Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 295d65e4ef | |||
| 0f5d484151 |
@@ -8,7 +8,6 @@ on:
|
|||||||
- '**.py'
|
- '**.py'
|
||||||
- '.pylintrc'
|
- '.pylintrc'
|
||||||
- 'pyrightconfig.json'
|
- 'pyrightconfig.json'
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
update-badges:
|
update-badges:
|
||||||
|
|||||||
@@ -419,8 +419,7 @@ disable=raw-checker-failed,
|
|||||||
too-many-instance-attributes,
|
too-many-instance-attributes,
|
||||||
duplicate-code,
|
duplicate-code,
|
||||||
import-outside-toplevel,
|
import-outside-toplevel,
|
||||||
too-few-public-methods,
|
too-few-public-methods
|
||||||
unnecessary-ellipsis
|
|
||||||
|
|
||||||
# Enable the message, report, category or checker with the given id(s). You can
|
# Enable the message, report, category or checker with the given id(s). You can
|
||||||
# either give multiple identifier separated by comma (,) or put this option
|
# either give multiple identifier separated by comma (,) or put this option
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ follow-up tracked separately)."""
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import fcntl
|
import fcntl
|
||||||
|
import io
|
||||||
import signal
|
import signal
|
||||||
import struct
|
import struct
|
||||||
import subprocess
|
import subprocess
|
||||||
@@ -68,7 +69,11 @@ def _read_winsize() -> tuple[int, int] | None:
|
|||||||
- tmux respawn-pane: tmux sets all three to the pane's PTY.
|
- tmux respawn-pane: tmux sets all three to the pane's PTY.
|
||||||
- non-TTY (someone piped stdin in tests): none are; the
|
- non-TTY (someone piped stdin in tests): none are; the
|
||||||
sync just no-ops, which is the right behavior."""
|
sync just no-ops, which is the right behavior."""
|
||||||
for fd in (sys.stdin.fileno(), sys.stdout.fileno(), sys.stderr.fileno()):
|
for default_fd, stream in enumerate((sys.stdin, sys.stdout, sys.stderr)):
|
||||||
|
try:
|
||||||
|
fd = stream.fileno()
|
||||||
|
except (AttributeError, io.UnsupportedOperation, OSError):
|
||||||
|
fd = default_fd
|
||||||
try:
|
try:
|
||||||
data = fcntl.ioctl(fd, termios.TIOCGWINSZ, b"\x00" * 8)
|
data = fcntl.ioctl(fd, termios.TIOCGWINSZ, b"\x00" * 8)
|
||||||
except OSError:
|
except OSError:
|
||||||
|
|||||||
@@ -42,7 +42,8 @@ def filter_select(
|
|||||||
# Use os.dup() to duplicate the fd so the original file object
|
# Use os.dup() to duplicate the fd so the original file object
|
||||||
# and FileIO in _run_picker each manage independent copies,
|
# and FileIO in _run_picker each manage independent copies,
|
||||||
# preventing double-close errors.
|
# preventing double-close errors.
|
||||||
fd_dup = os.dup(tty_fd.fileno())
|
import os as _os
|
||||||
|
fd_dup = _os.dup(tty_fd.fileno())
|
||||||
return _run_picker(items, title=title, tty_fd=fd_dup)
|
return _run_picker(items, title=title, tty_fd=fd_dup)
|
||||||
finally:
|
finally:
|
||||||
tty_fd.close()
|
tty_fd.close()
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ from ...agent_provider import (
|
|||||||
AgentProvisionFile,
|
AgentProvisionFile,
|
||||||
AgentProvisionPlan,
|
AgentProvisionPlan,
|
||||||
)
|
)
|
||||||
from ...codex_auth import codex_host_access_token, write_codex_dummy_auth_file
|
from .codex_auth import codex_host_access_token, write_codex_dummy_auth_file
|
||||||
from ...egress import CODEX_HOST_CREDENTIAL_TOKEN_REF, EgressRoute
|
from ...egress import CODEX_HOST_CREDENTIAL_TOKEN_REF, EgressRoute
|
||||||
from ...log import die, info, warn
|
from ...log import die, info, warn
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ from datetime import datetime, timezone
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import cast
|
from typing import cast
|
||||||
|
|
||||||
from .log import die
|
from bot_bottle.log import die
|
||||||
from .util import expand_tilde
|
from bot_bottle.util import expand_tilde
|
||||||
|
|
||||||
|
|
||||||
def codex_auth_path(host_env: dict[str, str] | None = None) -> Path:
|
def codex_auth_path(host_env: dict[str, str] | None = None) -> Path:
|
||||||
@@ -153,7 +153,9 @@ def _dummy_jwt_from_host(
|
|||||||
return _dummy_jwt(now, exp_ts=exp_ts)
|
return _dummy_jwt(now, exp_ts=exp_ts)
|
||||||
if not isinstance(payload, dict):
|
if not isinstance(payload, dict):
|
||||||
return _dummy_jwt(now, exp_ts=exp_ts)
|
return _dummy_jwt(now, exp_ts=exp_ts)
|
||||||
return _encode_dummy_jwt(_redact_jwt_payload(cast(dict[str, object], payload), now=now, exp_ts=exp_ts))
|
return _encode_dummy_jwt(
|
||||||
|
_redact_jwt_payload(cast(dict[str, object], payload), now=now, exp_ts=exp_ts)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def _encode_dummy_jwt(payload: dict[str, object]) -> str:
|
def _encode_dummy_jwt(payload: dict[str, object]) -> str:
|
||||||
@@ -161,7 +161,7 @@ class Agent:
|
|||||||
git_raw = d.get("git-gate")
|
git_raw = d.get("git-gate")
|
||||||
if git_raw is not None:
|
if git_raw is not None:
|
||||||
gd = as_json_object(git_raw, f"agent '{name}' git-gate")
|
gd = as_json_object(git_raw, f"agent '{name}' git-gate")
|
||||||
for k in gd:
|
for k in gd.keys():
|
||||||
if k != "user":
|
if k != "user":
|
||||||
raise ManifestError(
|
raise ManifestError(
|
||||||
f"agent '{name}' git-gate.{k} is not allowed at the "
|
f"agent '{name}' git-gate.{k} is not allowed at the "
|
||||||
|
|||||||
@@ -246,7 +246,7 @@ class GitUser:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def from_dict(cls, bottle_name: str, raw: object) -> "GitUser":
|
def from_dict(cls, bottle_name: str, raw: object) -> "GitUser":
|
||||||
d = as_json_object(raw, f"bottle '{bottle_name}' git-gate.user")
|
d = as_json_object(raw, f"bottle '{bottle_name}' git-gate.user")
|
||||||
for k in d:
|
for k in d.keys():
|
||||||
if k not in {"name", "email"}:
|
if k not in {"name", "email"}:
|
||||||
raise ManifestError(
|
raise ManifestError(
|
||||||
f"bottle '{bottle_name}' git-gate.user has unknown key {k!r}; "
|
f"bottle '{bottle_name}' git-gate.user has unknown key {k!r}; "
|
||||||
@@ -281,7 +281,7 @@ def parse_git_gate_config(
|
|||||||
raw: object,
|
raw: object,
|
||||||
) -> tuple[tuple[GitEntry, ...], GitUser]:
|
) -> tuple[tuple[GitEntry, ...], GitUser]:
|
||||||
d = as_json_object(raw, f"bottle '{bottle_name}' git-gate")
|
d = as_json_object(raw, f"bottle '{bottle_name}' git-gate")
|
||||||
for k in d:
|
for k in d.keys():
|
||||||
if k not in {"user", "repos"}:
|
if k not in {"user", "repos"}:
|
||||||
raise ManifestError(
|
raise ManifestError(
|
||||||
f"bottle '{bottle_name}' git-gate has unknown key {k!r}; "
|
f"bottle '{bottle_name}' git-gate has unknown key {k!r}; "
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import unittest
|
|||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from bot_bottle.codex_auth import (
|
from bot_bottle.contrib.codex.codex_auth import (
|
||||||
codex_auth_path,
|
codex_auth_path,
|
||||||
codex_dummy_auth_json,
|
codex_dummy_auth_json,
|
||||||
codex_host_access_token,
|
codex_host_access_token,
|
||||||
|
|||||||
Reference in New Issue
Block a user