Skip to content

Latest commit

 

History

History
242 lines (186 loc) · 12.7 KB

plugin-install.md

File metadata and controls

242 lines (186 loc) · 12.7 KB

Plugin Installation

AgentGuard plugins stream agent lifecycle events into Timeplus. They need nothing but a reachable Timeplus Enterprise with the AgentGuard app installed — the app creates database ag, the agentguard_hook_events stream the plugins write to, and an OTLP/HTTP input (default port 4318).

There is no installer script and no AgentGuard server to point at: each plugin is installed with its package manager and configured with environment variables (Claude Code, Hermes, Codex) or plugin config (OpenClaw).

Agent-guided install: the skills/agentguard skill walks an agent through everything below — it collects the values, installs the package, and patches the config files.

Prerequisites

Agent Required tools
Claude Code node >= 18, npm
OpenClaw node >= 18, OpenClaw >= 2026.4.0 with an initialised openclaw.json (openclaw onboard)
Hermes Python >= 3.10, pip
Codex Python >= 3.10, pip

Choosing the ingest API

Situation AGENTGUARD_INGEST_API AGENTGUARD_TIMEPLUS_URL
timeplusd's HTTP port is reachable from the agent host (single host / Docker) timeplusd (default) http://<host>:3218
Only the Timeplus web console / REST API is exposed (Kubernetes, behind an ingress) rest http://<host>:8000 or the console's HTTPS URL

Both modes use the same Timeplus username/password (Basic auth) and send the same payload; only the URL path differs.

API key (REST API only)

From Timeplus REST API 3.5.4, the Claude Code plugin (0.10.0 or later) and the Codex plugin on its hooks export (0.5.0 or later) can authenticate with an API key instead of a username and password, so no password is kept on the agent host:

export AGENTGUARD_INGEST_API=rest
export AGENTGUARD_TIMEPLUS_URL=http://<host>:8000
export AGENTGUARD_API_KEY=tpk_...
  • Create the key as the Timeplus user the events should be written as, with the ingest scope. It can be limited to the stream ag.agentguard_hook_events.
  • With a key set, the username and password are not sent.
  • timeplusd (port 3218) does not accept a key: in timeplusd mode the key is ignored and the username and password are used. Setting a key does not change the ingest mode.
  • A key stops working when it is revoked or expires, or when its owner changes their password; ingest then fails with 401 and a new key is needed.
  • The OpenClaw and Hermes plugins, and the OTel channel (port 4318), do not take a key.

Claude Code

  1. Install the hook binary:

    npm install -g @timeplus/agentguard-claudecode-plugin
  2. Merge the following into ~/.claude/settings.json (keep any existing env / hooks entries):

    {
      "env": {
        "AGENTGUARD_AGENT_ID": "<your-hostname>",
        "AGENTGUARD_DEPLOYMENT_ID": "local",
        "AGENTGUARD_DEPLOYMENT_NAME": "Local Dev",
        "AGENTGUARD_TIMEPLUS_URL": "http://localhost:3218",
        "AGENTGUARD_INGEST_API": "timeplusd",
        "AGENTGUARD_DATABASE": "ag",
        "AGENTGUARD_STREAM": "agentguard_hook_events",
        "AGENTGUARD_USERNAME": "<timeplus user>",
        "AGENTGUARD_PASSWORD": "<timeplus password>",
        "AGENTGUARD_HOLDS_ENABLED": "false"
      },
      "hooks": {
        "PreToolUse":   [{ "matcher": "*", "hooks": [{ "type": "command", "command": "agentguard-hook", "timeout": 600000 }] }],
        "SessionStart": [{ "matcher": "*", "hooks": [{ "type": "command", "command": "agentguard-hook", "async": true }] }],
        "PostToolUse":  [{ "matcher": "*", "hooks": [{ "type": "command", "command": "agentguard-hook", "async": true }] }]
      }
    }

    Register the same async entry for SessionEnd, UserPromptSubmit, PostToolUseFailure, SubagentStart, SubagentStop, Stop, PermissionDenied, InstructionsLoaded, PreCompact, PostCompact, PermissionRequest, Notification, StopFailure, TaskCreated, TaskCompleted, PostModelSwitch, and ConfigChange. The full snippet is in hooks.json and the skill.

  3. Optional — OTel metrics (tokens, cost, latency). Add to the same env block, pointing at the app's OTLP input:

    "CLAUDE_CODE_ENABLE_TELEMETRY": "1",
    "OTEL_METRICS_EXPORTER": "otlp",
    "OTEL_LOGS_EXPORTER": "otlp",
    "OTEL_EXPORTER_OTLP_PROTOCOL": "http/protobuf",
    "OTEL_EXPORTER_OTLP_ENDPOINT": "http://<timeplus-host>:4318"

    See agents/claudecode/otel_timeplus.md for details.

  4. Quit and reopen Claude Code so the hooks take effect.

Working from a checkout of this repo instead? cd agents/claudecode && make install builds the plugin and writes the hooks, AGENTGUARD_*, and OTel variables into ~/.claude/settings.json in one step (make unconfigure unconfigure-otel removes them).

OpenClaw

  1. Install the plugin:

    openclaw plugins install @timeplus/agentguard-openclaw-plugin
  2. Add the plugin entry to .openclaw/openclaw.json (back the file up first):

    {
      "plugins": {
        "entries": {
          "agentguard": {
            "enabled": true,
            "config": {
              "timeplusUrl": "http://localhost:3218",
              "ingestApi": "timeplusd",
              "database": "ag",
              "stream": "agentguard_hook_events",
              "username": "<timeplus user>",
              "password": "<timeplus password>",
              "deploymentId": "local",
              "deploymentName": "Local Dev",
              "flushMs": 2000,
              "batchSize": 50,
              "holdsEnabled": false
            }
          }
        }
      }
    }

    When OpenClaw runs in Docker and Timeplus on the host, use http://host.docker.internal:3218.

  3. Restart: openclaw gateway restart.

OTel export for OpenClaw uses its diagnostics-otel plugin — see agents/openclaw/otel_timeplus.md. The plugin README covers the manual / Docker install.

Hermes

pip install agentguard-hermes-plugin
agentguard-hermes install          # copies the plugin into ~/.hermes/plugins/agentguard/
hermes plugins enable agentguard

Then export the configuration in your shell profile and restart Hermes:

export AGENTGUARD_TIMEPLUS_URL=http://localhost:3218
export AGENTGUARD_USERNAME=<timeplus user>
export AGENTGUARD_PASSWORD=<timeplus password>
export AGENTGUARD_DATABASE=ag
export AGENTGUARD_AGENT_ID=$(hostname)
export AGENTGUARD_DEPLOYMENT_ID=local
export AGENTGUARD_DEPLOYMENT_NAME="Local Dev"

Codex

Status: early. By default the Codex plugin exports OTel spans instead of writing agentguard_hook_events; from 0.3.0 it can write agentguard_hook_events instead (step 3). It covers all 14 Codex lifecycle hooks (from 0.2.0; earlier versions covered five). See the plugin README for the span reference and for upgrading a five-hook configuration, and the implementation TODO for the open items.

  1. Install the plugin (the Python SDK, timeplus-agentguard, comes with it as a dependency):

    pip install timeplus-agentguard-codex-plugin
  2. Merge agents/codex/agentguard-plugin/hooks.json into ~/.codex/hooks.json (or the equivalent [hooks] table in ~/.codex/config.toml), keeping any existing entries.

  3. Export the configuration. Hooks run in a fresh process, so environment variables are the usual way to configure the plugin; the --agent-id, --deployment-id, --deployment-name and --endpoint flags override them per hook.

    export AGENTGUARD_AGENT_ID=$(hostname)
    export AGENTGUARD_DEPLOYMENT_ID=local
    export AGENTGUARD_DEPLOYMENT_NAME="Local Dev"
    export OTEL_EXPORTER_OTLP_ENDPOINT=http://<timeplus-host>:4318

    To write agentguard_hook_events instead of exporting spans (for example when port 4318 is not reachable), select the hook-event export and give it the same settings as the other plugins. OTEL_EXPORTER_OTLP_ENDPOINT is then not used:

    export AGENTGUARD_CODEX_EXPORT=hooks
    export AGENTGUARD_TIMEPLUS_URL=http://<timeplus-host>:3218
    export AGENTGUARD_USERNAME=<timeplus-user>
    export AGENTGUARD_PASSWORD=<timeplus-password>
    # export AGENTGUARD_INGEST_API=rest   # with AGENTGUARD_TIMEPLUS_URL on port 8000

    The two exports are alternatives: the plugin uses exactly one, and an unknown AGENTGUARD_CODEX_EXPORT value falls back to otel. The app does not yet turn Codex hook-event rows into CIM events and metrics (timeplus-io/apps#71).

    Optional, on either export: each model request carries the response the model gave (text cut to 4,000 characters, the tool calls it asked for, the reasoning settings), read from the session transcript (plugin 0.4.0 or later). Set AGENTGUARD_LLM_CONTENT=false to leave the text out, or AGENTGUARD_LLM_CONTENT_CHARS=<n> to change the cut.

  4. Start Codex and run /hooks once to review and trust the AgentGuard entries. Codex skips new or changed hooks until you do, so repeat this after adding events on an upgrade.

With the default export, Codex spans go to the app's OTLP/HTTP input (port 4318), not to agentguard_hook_events, so the Verify query below does not apply. (With AGENTGUARD_CODEX_EXPORT=hooks it does: look for agent_type = 'codex'.) Check the default export with:

SELECT _tp_time, span_name, span_attributes['session.id'] AS session_id
FROM table(ag.otel_traces)
WHERE service_name = 'codex'
ORDER BY _tp_time DESC
LIMIT 10;

Verify

SELECT agent_type, hook_name, agent_id, tool_name, event_time
FROM table(ag.agentguard_hook_events)
ORDER BY event_time DESC
LIMIT 10;

Rows should appear within a few seconds of agent activity. If nothing arrives, check the URL/port for the chosen ingest mode, the credentials, and that the AgentGuard app is installed (the ag database exists). Plugins fail silently by design so they never block the agent.

Configuration reference

Variable OpenClaw config key Default Purpose
AGENTGUARD_TIMEPLUS_URL timeplusUrl http://localhost:3218 Timeplus base URL (see ingest API)
AGENTGUARD_INGEST_API ingestApi timeplusd timeplusd or rest
AGENTGUARD_WORKSPACE workspace default REST API workspace id; default is correct for self-hosted
AGENTGUARD_DATABASE database ag Database owning the AgentGuard streams (the app's db_name)
AGENTGUARD_STREAM stream agentguard_hook_events Target stream
AGENTGUARD_USERNAME username proton Timeplus username
AGENTGUARD_PASSWORD password (empty) Timeplus password
AGENTGUARD_API_KEY — (empty) Claude Code, Codex (hooks export): API key sent in place of the username and password; rest mode only (see API key)
AGENTGUARD_AGENT_ID — hostname Identifies this agent instance (Claude Code, Hermes, Codex)
AGENTGUARD_DEPLOYMENT_ID deploymentId default / local Logical deployment group
AGENTGUARD_DEPLOYMENT_NAME deploymentName Human-readable deployment label
AGENTGUARD_CODEX_EXPORT — otel Codex: otel (spans to the OTLP input) or hooks (rows in agentguard_hook_events, using the Timeplus URL, ingest API and credentials above)
OTEL_EXPORTER_OTLP_ENDPOINT — http://localhost:4318 Codex: OTLP/HTTP endpoint for span export (otel export only)
AGENTGUARD_FLUSH_MS / AGENTGUARD_BATCH_SIZE flushMs / batchSize 2000 / 50 OpenClaw batching
AGENTGUARD_TRANSCRIPT_MESSAGES / AGENTGUARD_TRANSCRIPT_CONTENT_CHARS — 50 / 10000 Claude Code context-event truncation
AGENTGUARD_LLM_CONTENT / AGENTGUARD_LLM_CONTENT_CHARS — true / 4000 Claude Code: send the response text of each model request on its llm_call row, cut to this many characters. false sends the length only
AGENTGUARD_STATE_DIR — <tmp>/agentguard-claudecode Claude Code: where the plugin keeps what it already sent for each sub-agent

Legacy hold settings

AGENTGUARD_HOLDS_ENABLED (holdsEnabled), AGENTGUARD_URL (agentguardUrl), and AGENTGUARD_HOLDS_FAIL_POLICY (holdFailPolicy) drive the synchronous tool-call hold path, which called the retired standalone AgentGuard server. The Timeplus app has no hold capability — keep holds disabled (the default) and leave the other two unset.