Repository navigation
Keep collector credentials out of the agent context - #202
Merged
Merged
Conversation
Lark/Feishu, DingTalk and Slack collectors now read secrets from environment variables, then the OS keychain (optional keyring), then the 0600 config file. --setup and the new Feishu --login use hidden input and refuse to run without a TTY, so an agent cannot pipe secrets through them. --check reports where each credential comes from without printing values, and Feishu --refresh renews the user token from the stored refresh_token. --user-token / --exchange-code are removed, and SKILL.md no longer asks users to paste App Secrets, tokens or OAuth codes. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017ZQBLAJV6q9FP7domp6FKf
titanwings
marked this pull request as ready for review
October 12, 2026 08:03
This was referenced Oct 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Tianyi · project thread
Summary
Before: the Lark/Feishu, DingTalk and Slack collectors asked for App Secrets,
user_access_tokenand Bot Tokens through echoedinput(),--user-token/--exchange-codeCLI flags, and SKILL.md told the agent to collectapp_id/app_secret/ OAuth codes from the user in chat. Secrets ended up in the model context, shell history and transcripts.After: credentials are read from environment variables → OS keychain (optional
keyring) →~/.distilly/*_config.json(0600). Setup and OAuth happen only in the user's own terminal with hidden input, and the agent can only see whether a credential is configured, never its value.Changes
tools/credentials.py: shared resolve / describe / require / save helpers. Env var names (FEISHU_APP_ID,FEISHU_APP_SECRET,FEISHU_USER_ACCESS_TOKEN,FEISHU_REFRESH_TOKEN,DINGTALK_APP_KEY,DINGTALK_APP_SECRET,SLACK_BOT_TOKEN) double as keychain entry names, so the Feishu collector and the Feishu MCP client share one set.feishu_auto_collector,feishu_mcp_client,dingtalk_auto_collector,slack_auto_collector):--setupusesgetpassfor secrets and refuses to run when stdin is not a TTY, so an agent cannot pipe secrets through it.--check: prints each field's source (env / keychain / config file / missing), never the value.--setupor the env var.--login(prints authorize URL, hidden input for the callback URL/code, saves the token directly) and--refresh(renews from storedrefresh_token, no input).--user-tokenand--exchange-codeare removed with an explanatory error; the token prefix is no longer printed; error output no longer dumps raw API responses.save_secretsworks on the raw file dict).--check, ask the user to run--setup/--loginin their own terminal", the private-chat command no longer passes--user-token, ad-hoc scripts must load viacredentials.resolveor env vars, and a pasted secret should be rotated rather than used.--check;keyringadded to requirements.txt as optional.Motivation
Personal-agent tools like Dots and Muse explicitly keep credentials out of the model context; distilly's collectors did the opposite (
tools/feishu_auto_collector.py:112,tools/dingtalk_auto_collector.py:85).Testing
python -m unittest discover -s tests -p 'test_*.py'passed (81 tests, incl. newtests/test_credentials.py: env override, keychain path,--checknever prints values, keychain save keeps secrets out of the file, refresh doesn't persist env secrets, non-TTY--setuprefused,--user-tokenrejected without echoing the value)python -m compileall tools/passednode bin/distilly.mjs --check-packagepassedChecklist
requirements.txt(optionalkeyring)Breaking:
--user-tokenand--exchange-codeonfeishu_auto_collector.pynow exit with an error pointing to--login/FEISHU_USER_ACCESS_TOKEN. Existing~/.distilly/*_config.jsonfiles keep working unchanged.🤖 Generated with Claude Code
https://claude.ai/code/session_017ZQBLAJV6q9FP7domp6FKf
Generated by Claude Code