-
Notifications
You must be signed in to change notification settings - Fork 5
feat(codex): complete the Codex sign-in from chat with /login #66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2793888
97b4ea6
0ee85d2
f3175fd
d41289a
470b0c6
7721f10
9961147
13cafa6
caac95f
f8bdcd1
c454c94
1011006
9095cff
70b3934
5be334e
bb406e9
8a26494
b303855
dffcb50
1520853
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,16 @@ AI_BACKEND=claude # claude | codex | openai-compatible | |
| # CODEX_HOME/auth.json (persisted in the codex_home volume) or CODEX_ACCESS_TOKEN. | ||
| # Keep CODEX_API_KEY empty in subscription mode: startup fails if it is set, so a | ||
| # subscription deploy cannot accidentally switch to usage-based API billing. | ||
| # | ||
| # First sign-in needs no shell on the host: the bot starts unauthorized and an | ||
| # allow-listed user sends /login IN A DIRECT MESSAGE (the reply carries a one-time | ||
| # code, so starting a sign-in is refused in group chats). Runs are blocked until | ||
| # it completes. CODEX_REQUIRE_AUTH=false only removes the block — without | ||
| # auth.json or CODEX_ACCESS_TOKEN runs then fail inside the Codex CLI instead. | ||
| # CODEX_HOME must stay non-empty: with an empty value startup still fails, since | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MINOR: Утверждение про CODEX_HOME неверно при CODEX_REQUIRE_AUTH=false
...(truncated) |
||
| # there would be nowhere to persist the login. | ||
| # Full flow, and who ends up owning the Codex account: | ||
| # docs/codex-integration-plan.md#subscription-setup | ||
| CODEX_AUTH_MODE=subscription # subscription | billing | ||
| CODEX_BIN=codex | ||
| CODEX_HOME=/home/claude/.codex | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,8 @@ import ( | |
| "strings" | ||
|
|
||
| "github.com/go-telegram/bot/models" | ||
|
|
||
| "github.com/duckbugio/flock/core/chat" | ||
| ) | ||
|
|
||
| // CommandName returns the slash command addressed at the start of msg, | ||
|
|
@@ -82,22 +84,14 @@ func StripCommandMention(text, botUsername string) string { | |
| return token[:at] + rest | ||
| } | ||
|
|
||
| // HelpText is the static usage message replied to an allowed user who sends | ||
| // /help. It lists the slash commands the adapter understands. It is an | ||
| // engineering artifact (professional English, no duck flavor) and never reaches | ||
| // the Claude Runner. | ||
| const HelpText = "Flock Telegram assistant — available commands:\n\n" + | ||
| "/help — show this message\n" + | ||
| "/new — start a fresh session (forget the current conversation)\n" + | ||
| "/stop — stop the run currently in progress\n" + | ||
| "/schedule — manage scheduled jobs (when enabled)\n" + | ||
| "/goal <criterion> — arm a goal an independent evaluator re-checks after every run " + | ||
| "(/goal off to disarm)\n\n" + | ||
| "Send any other message to run it through the assistant." | ||
| // helpTitle names the transport; everything below it is shared with the VK | ||
| // adapter (chat.HelpBody), so the two cannot drift apart. | ||
| const helpTitle = "Flock Telegram assistant — available commands:\n\n" | ||
|
|
||
| // HelpText renders the usage message replied to an allowed user who sends /help. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NIT: Условие показа /login не учитывает CODEX_ACCESS_TOKEN
|
||
| // It is a thin alias over the shared render, so this adapter owns only its title. | ||
| func HelpText(login chat.LoginVisibility) string { return chat.HelpText(helpTitle, login) } | ||
|
|
||
| // WelcomeText is the static usage message replied to an allowed user who sends | ||
| // /start. It is a short greeting prepended to the command help so a brand-new | ||
| // user immediately sees what the bot does and how to use it. Like HelpText it is | ||
| // an engineering artifact (plain English, no duck flavor) and never reaches the | ||
| // Claude Runner — the duck greeting comes from the model on a real message. | ||
| const WelcomeText = "Hi! I'm the Flock assistant.\n\n" + HelpText | ||
| // WelcomeText is the reply to /start: the shared greeting prepended to the help, | ||
| // so a brand-new user immediately sees what the bot does and how to use it. | ||
| func WelcomeText(login chat.LoginVisibility) string { return chat.WelcomeText(helpTitle, login) } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,15 @@ CLAUDE_MAX_COST_PER_REQUEST={{ claude_max_cost_per_request }} | |
|
|
||
| # === CODEX AUTH === | ||
| # subscription: use persisted {{ codex_home }}/auth.json or CODEX_ACCESS_TOKEN. | ||
| # With neither, the bot starts unauthorized and an allow-listed user completes | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MINOR: env.j2 не упоминает требование личного сообщения, в отличие от .env.example
|
||
| # the one-time sign-in from the chat with /login IN A DIRECT MESSAGE. Runs are | ||
| # blocked until it lands. CODEX_REQUIRE_AUTH=false only removes the block — | ||
| # without auth.json or CODEX_ACCESS_TOKEN runs then fail inside the Codex CLI | ||
| # instead. | ||
| # CODEX_HOME must stay non-empty: with an empty value startup still fails, | ||
| # since there would be nowhere to persist the login. | ||
| # Full flow, and who ends up owning the Codex account: | ||
| # docs/codex-integration-plan.md#subscription-setup | ||
| # billing: requires CODEX_API_KEY and CODEX_BILLING_ACK=true. | ||
| CODEX_BIN={{ codex_bin }} | ||
| CODEX_MODEL={{ codex_model }} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,19 @@ | ||
| package vk | ||
|
|
||
| // HelpText is the static usage message for the VK adapter. It mirrors the | ||
| // Telegram adapter's HelpText and lists VK's command surface: VK has no native | ||
| // slash-command UI, so these are plain text commands the receiver intercepts. It | ||
| // is an engineering artifact (professional English, no duck flavor). | ||
| const HelpText = "Flock VK assistant — available commands:\n\n" + | ||
| "/help — show this message\n" + | ||
| "/new — start a fresh session (forget the current conversation)\n" + | ||
| "/stop — stop the run currently in progress\n" + | ||
| "/schedule — manage scheduled jobs (when enabled)\n" + | ||
| "/goal <criterion> — arm a goal an independent evaluator re-checks after every run " + | ||
| "(/goal off to disarm)\n\n" + | ||
| "Send any other message to run it through the assistant." | ||
| import "github.com/duckbugio/flock/core/chat" | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MINOR: «Не могут разойтись» — но это две независимые копии строки
...(truncated) |
||
| // helpTitle names the transport; everything below it is shared with the Telegram | ||
| // adapter (chat.HelpBody), so the two cannot drift apart. VK has no native | ||
| // slash-command UI, so these are plain text commands the receiver intercepts. | ||
| const helpTitle = "Flock VK assistant — available commands:\n\n" | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NIT: Doc-комментарий ссылается на несуществующий параметр withLogin
|
||
| // helpText renders the usage message. It is a thin alias over the shared render, | ||
| // so this adapter owns only its title. Unexported like welcomeText beside it: | ||
| // nothing outside this package renders VK's help. | ||
| func helpText(login chat.LoginVisibility) string { return chat.HelpText(helpTitle, login) } | ||
|
|
||
| // welcomeText is the reply to /start, mirroring the Telegram adapter. | ||
| func welcomeText(login chat.LoginVisibility) string { return chat.WelcomeText(helpTitle, login) } | ||
|
|
||
| // goalUsageText is the /goal usage reply, mirroring the Telegram adapter. | ||
| const goalUsageText = "Usage:\n" + | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MINOR: Новый блок про /login не упоминает единственный случай, когда старт всё ещё падает
CODEX_HOME=(а в env.j2 этоCODEX_HOME={{ codex_home }}, то есть пустая ansible-переменная отрендерится в пустое значение), получит crash-loop вместо обещанного «стартует и ждёт /login». Ровно этот блок текста и читают, когда так делают.# CODEX_HOME must stay non-empty: with an empty value startup still fails, since there would be nowhere to persist the login.Продублировать её же в adapters/telegram/deploy/roles/claude_tg_bot/templates/env.j2 рядом со строками про CODEX_REQUIRE_AUTH.