Skip to content

feat: Add Bitwarden secrets and Anthropic distill support#349

Open
Coke1120 wants to merge 5 commits intoCortexReach:masterfrom
Coke1120:feat/bitwarden-anthropic-distill
Open

feat: Add Bitwarden secrets and Anthropic distill support#349
Coke1120 wants to merge 5 commits intoCortexReach:masterfrom
Coke1120:feat/bitwarden-anthropic-distill

Conversation

@Coke1120
Copy link
Copy Markdown

Summary

  • Add Bitwarden secret resolver (src/secret-resolver.ts) for secure API key management via Bitwarden CLI or env vars
  • Add Anthropic LLM client (src/llm-client.ts) with distill/extraction support
  • Add CLI entry point (cli.ts) exposing distill functionality
  • Integrate secret resolution into lesson extract worker
  • Add tests for secret resolver, LLM API key client, and plugin manifest regression
  • Update plugin manifest and package dependencies

Test plan

  • Run test/secret-resolver.test.mjs — verify Bitwarden and env-var resolution paths
  • Run test/llm-api-key-client.test.mjs — verify Anthropic client key handling
  • Run test/plugin-manifest-regression.mjs — verify manifest schema unchanged
  • Smoke-test distill via examples/new-session-distill/ with a real session

Closes #348

🤖 Generated with Claude Code

Copy link
Copy Markdown
Collaborator

@AliceLJY AliceLJY left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

整体设计清晰,测试覆盖核心路径,两个特性 scope 控制得好 👍

Must Fix

1. resolveSecretValueSync 阻塞启动
execFileSync("bws", ...) 在插件 activate() 路径上会阻塞事件循环。如果 Bitwarden CLI 慢或网络抖动,会卡住整个 OpenClaw 启动。

建议:activate() 已经返回 Promise,改用 async 版本 resolveSecretValue。或者至少加个明确的 timeout 错误提示,让用户知道卡在哪。

2. Distill worker 重复了 Bitwarden 解析逻辑
lesson-extract-worker.mjs 里的 resolveMaybeBitwardenSecret()src/secret-resolver.ts 逻辑重复。Worker 是独立脚本可以理解,但至少加个注释标明两处必须同步更新,或抽成共享 ESM 模块。

Nice to have

  1. anthropicGenerateJson(worker)和 createAnthropicApiKeyClient(llm-client)独立构建 Anthropic 请求,后续可能分叉,建议加 TODO 注释
  2. 补一个 bws:// URL 解析的边缘 case 测试(无 hostname / 缺 secret ID)

修完 1-2 就可以合,辛苦了 🙏

Coke1120 and others added 4 commits March 26, 2026 22:18
- Change register() to async and replace all resolveSecretValueSync /
  resolveSecretValuesSync calls with their async counterparts so Bitwarden
  CLI invocations no longer block the event loop during plugin activation
- Add sync comment in lesson-extract-worker.mjs flagging the duplicate
  Bitwarden resolution logic that must stay in sync with src/secret-resolver.ts
- Add TODO comments in anthropicGenerateJson (worker) and
  createAnthropicApiKeyClient (llm-client) noting the two implementations
  may diverge and should eventually be unified
- Add three edge-case tests for malformed bws:// URLs (empty hostname,
  empty path after prefix strip)
- await plugin.register() in plugin-manifest-regression test to match the
  now-async register signature

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ister

After making register() async, all test callsites must await it or hook
registrations won't complete before assertions run.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…resolver tests

Resolves the package.json conflict between branch and master: keeps
secret-resolver.test.mjs (added in this branch) and adds
session-summary-before-reset.test.mjs (added on master).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Coke1120 Coke1120 requested a review from AliceLJY March 27, 2026 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Add Bitwarden secrets and Anthropic distill support

2 participants