Implement local agent JWT authentication for adapters

Add HS256 JWT-based authentication for local adapters (claude_local, codex_local)
so agents authenticate automatically without manual API key configuration. The
server mints short-lived JWTs per heartbeat run and injects them as PAPERCLIP_API_KEY.
The auth middleware verifies JWTs alongside existing static API keys.

Includes: CLI onboard/doctor JWT secret management, env command for deployment,
config path resolution from ancestor directories, dotenv loading on server startup,
event payload secret redaction, multi-status issue filtering, and adapter transcript
parsing for thinking/user message kinds.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Forgotten
2026-02-18 16:46:45 -06:00
parent 406f13220d
commit fe6a8687c1
28 changed files with 921 additions and 49 deletions

View File

@@ -0,0 +1,40 @@
import {
ensureAgentJwtSecret,
readAgentJwtSecretFromEnv,
readAgentJwtSecretFromEnvFile,
resolveAgentJwtEnvFile,
} from "../config/env.js";
import type { CheckResult } from "./index.js";
export function agentJwtSecretCheck(): CheckResult {
if (readAgentJwtSecretFromEnv()) {
return {
name: "Agent JWT secret",
status: "pass",
message: "PAPERCLIP_AGENT_JWT_SECRET is set in environment",
};
}
const envPath = resolveAgentJwtEnvFile();
const fileSecret = readAgentJwtSecretFromEnvFile(envPath);
if (fileSecret) {
return {
name: "Agent JWT secret",
status: "warn",
message: `PAPERCLIP_AGENT_JWT_SECRET is present in ${envPath} but not loaded into environment`,
repairHint: `Set the value from ${envPath} in your shell before starting the Paperclip server`,
};
}
return {
name: "Agent JWT secret",
status: "fail",
message: `PAPERCLIP_AGENT_JWT_SECRET missing from environment and ${envPath}`,
canRepair: true,
repair: () => {
ensureAgentJwtSecret();
},
repairHint: `Run with --repair to create ${envPath} containing PAPERCLIP_AGENT_JWT_SECRET`,
};
}

View File

@@ -7,6 +7,7 @@ export interface CheckResult {
repairHint?: string;
}
export { agentJwtSecretCheck } from "./agent-jwt-secret-check.js";
export { configCheck } from "./config-check.js";
export { databaseCheck } from "./database-check.js";
export { llmCheck } from "./llm-check.js";