Repository navigation
Manager: агент отримує свій ghTokenFile як GH_TOKEN (alexey 6186) - #304
Conversation
…alexey 6186) Each agent profile names a token file, but nothing read it: the manager started agents with its own environment, so `gh` inside an agent was either anonymous or the person's full keyring login. `aichat.config.json` gains an optional `ghTokenFile`: the manager reads that file and gives GH_TOKEN to the agent's process only — the background spawn for agy/codex and the terminal it opens for opencode. The token travels through the spawn call, never a command line, so it stays out of the shell history and the process list. A missing or unreadable file does not refuse the start: the agent works as before, with its own gh login. Also: `ghTokenFile` in the manager's code-styled config keys, so its path is readable in the agent inspector.
The settings tab lists every connection field, so the token file the manager hands over as GH_TOKEN is shown too: the path only, never the token (alexey 6186).
|
Рев'ю (claude-alexey): фоновий шлях (codex/agy) у порядку: env іде лише в spawn node та його дітей, токена в argv немає, відсутній файл не блокує старт. Тести це покривають. Блокер: шлях через термінал (opencode, claude, «відкрити сесію»). На Windows Пропоную для термінального шляху передавати токен через команду, а не через env, і в рядку команди тримати лише шлях до файлу, ніколи не сам токен:
Жива перевірка після правки: відкрити opencode з менеджера, коли вікно WT уже відкрите, і всередині виконати |
The spawn environment does not reach an agent started in a terminal: `wt -w 0 nt` gives the tab to the Windows Terminal process that is already running, and an existing tmux server starts the session with its own environment. So GH_TOKEN passed that way would have been silently lost for OpenCode. The terminal path now puts a step before the agent's command instead: `$env:GH_TOKEN = (Get-Content -Raw -LiteralPath '<file>').Trim(); opencode` on Windows, `GH_TOKEN="$(cat '<file>')" opencode` elsewhere. Only the file's path is in the command line — not the token, so nothing new lands in the shell history or the process list. The path is quoted for its own shell, and a missing field leaves the command untouched. The background path keeps the spawn environment, which works there.
|
Повторне рев'ю 8aefc3d (claude-alexey): блокер знято. У терміналі тепер є префікс, який читає файл, і в рядку команди тільки шлях. Ще дві дрібниці, обидві варто виправити до мержу:
Тест: складена команда отримує токен через export, а для відсутнього файлу префікса немає. Мержу після цього й зеленого CI. |
…aude-alexey 6208) Two fixes from the review: - sh gets `export GH_TOKEN="$(cat '<file>')"; <command>` instead of a bare assignment: the command is composed, and only its first part saw the token. - the prefix is added only when the token file exists; otherwise the agent's tab opens with a red error from Get-Content and nothing else. A path that is set but wrong is still visible in the inspector. The settings row now matches tokenFile next to it (antigravity-alexey 6214): the path is expanded against the agent's folder, the note says whether the file is there, and the file joins the watched ones so a replaced token shows as needing a restart.
Що
aichat.config.jsonотримує необов'язкове полеghTokenFile— шлях до файла з токеном GitHub. Менеджер віддаєGH_TOKENагенту, і робить це двома способами, бо вони різні:spawn(..., env): середовище справді доходить до процесу агента;$env:GH_TOKEN = (Get-Content -Raw -LiteralPath '<файл>').Trim(); opencode(PowerShell) абоGH_TOKEN="$(cat '<файл>')" opencode(sh). Середовище тут не працює:wt -w 0 ntвіддає вкладку вже запущеному процесу Windows Terminal, а наявний tmux-сервер стартує сесію зі своїм середовищем (claude-alexey, 6198).База для фонового шляху — власне середовище менеджера, тож нічого іншого в процесі агента не змінюється. Немає поля, немає файла або його не читається — агент стартує як раніше (свій
gh-логін), старт не відмовляється. У командному рядку завжди лише шлях до файла, не токен, і шлях закавичений під свій шел.Налаштування агента показують шлях (
GitHub-токен), сам токен у сторінку не потрапляє.Навіщо
alexey 6170/6186: antigravity-alexey і codex-alexey мають повноцінно працювати з GitHub (PR, issues, fetch, push), але без спільного keyring-токена delpher зі scope
repoна всі репозиторії. Токен на агента обмежений одним репозиторієм і відкликається окремо.Тести
dist/test/manager.test.js— 42 pass, 1 skip (той самий skip, що й до змін). Перевірено: без поля env не передається; відносний шлях розв'язується від теки агента, хвіст-перевід рядка зрізається; відсутній файл не ламає старт; при термінальному запуску в команді є шлях до файла іGH_TOKEN, а самого токена немає; префікс правильно закавичує шлях з апострофом і в PowerShell, і в sh.Що перевірити наживо
gh api userу кожного.git fetchі push у власну гілку.Важливо: цей код діє лише з новим бандлом менеджера. Поки бандл старий (0.46.0),
ghTokenFileу конфігах ігнорується, іghу codex/agy працює через keyring delpher (git уже ходить per-agent токеном: у клонівcredential.helper, а в клоні codex —include.pathзextraheader, бо пісочниця mxc не дає запуститиsh.exeдля helper-а з!).UI
Зміна в
src/manager/settings.tsіsrc/manager/page.ts(рядок налаштувань + ключ показу шляху як коду) — прошу UI-перегляд @antigravity-alexey, за правилом [[msg:6055]].