Skip to content

feat(claudecode, codex): authenticate ingest with a Timeplus API key - #339

Merged
gangtao merged 1 commit into
mainfrom
feat/api-key-ingest
Dec 1, 2026
Merged

gangtao merged 1 commit into
mainfrom
feat/api-key-ingest

Conversation

@gangtao

@gangtao gangtao commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Fixes #337
Fixes #338

What

From Timeplus REST API 3.5.4 a user can create scoped API keys and use one in place of a username and password. The Claude Code plugin and the Codex plugin (hooks export) now take AGENTGUARD_API_KEY, so no password has to be kept on the agent host.

  • With AGENTGUARD_INGEST_API=rest and a key set, the plugin sends X-Api-Key: <key> and no Authorization: Basic header. The username and password are not sent.
  • The key is used in rest mode only. In timeplusd mode (port 3218 takes no key) it is not sent, the username and password are used, and the plugin says on stderr that the key is ignored. A key does not change the ingest mode.
  • Without a key nothing changes.
  • The key is never printed. A 401 / 403 is reported on stderr like any ingest error and does not affect the agent.
  • Codex: the otel export does not use the key.

Changes

  • Claude Code: config.ts (apiKey), timeplus-client.ts (authHeaders, one warning per process). Version 0.10.0.
  • Codex: hookevents.py (IngestConfig.api_key, headers), cli.py (warning). Version 0.5.0.
  • agents/claudecode/Makefile: writes AGENTGUARD_INGEST_API (it could not select rest before) and AGENTGUARD_API_KEY when one is given; unconfigure removes both.
  • Docs: both plugin READMEs, docs/plugin-install.md, skills/agentguard/SKILL.md, root README.md, CLAUDE.md (the "no API keys" line).

Tested

  • Unit: Claude Code 157 tests, typecheck and build pass; Codex 127 tests pass.
  • Live, against a REST API server built from the 3.5.4 tag and a local Timeplus with the AgentGuard app, one hook per case, for each plugin; rows checked in ag.agentguard_hook_events:
Case Result
rest + key, with a wrong username/password also set row written
rest + key, no username/password row written
rest + key limited to another stream 403, no row, exit 0
rest + revoked key 401, no row, exit 0
rest + malformed key 401, no row, exit 0
rest, no key row written with Basic auth
timeplusd + key key ignored and reported, row written with Basic auth
rest + key on a 3.5.1 REST API (no key support) 401, no row, exit 0
  • Makefile configure / unconfigure run against a scratch settings file.

Not tested: an expired key, a key after its owner changed their password, a real Claude Code or Codex session with a key (the plugins were run with a hook payload on stdin), HTTPS.

Not in this PR

  • OpenClaw and Hermes still take the username and password only.
  • After merge: releases claudecode-plugin-v0.10.0 and codex-plugin-v0.5.0.

🤖 Generated with Claude Code

From Timeplus REST API 3.5.4 a user can create API keys and use one in
place of a username and password. Both plugins now take AGENTGUARD_API_KEY
and send it as X-Api-Key, so no password has to be kept on the agent host.

The key is used only with AGENTGUARD_INGEST_API=rest: timeplusd takes no
key. In timeplusd mode the key is not sent, the username and password are
used, and the plugin says so on stderr. A key does not change the ingest
mode. Without a key nothing changes.

Codex: applies to the hooks export; the otel export does not use it.
Claude Code Makefile: writes AGENTGUARD_INGEST_API, and the key when set.

Claude Code plugin 0.10.0, Codex plugin 0.5.0.

Fixes #337
Fixes #338

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@gangtao
gangtao merged commit fd037f2 into main Dec 1, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant