feat: per-tool settings, persistent settings file, Codex and Antigravity sessions, tokens and hooks (#40 B, C1, C2, D)
Part B: Model Pricing, Hook Configuration and CLAUDE_HOME move from Settings → Dashboard to the Claude Code tab's AgentHub sub-tab (ClaudeAgentHubSettings.tsx); CODEX_HOME is editable in Codex → AgentHub. A home that is or contains the OS home is refused (EBADHOME). Settings persistence: dashboard-saved settings go to ~/.config/agenthub/settings.env (AGENTHUB_SETTINGS_FILE), outside the plugin cache an update wipes. Load order: real env > the checkout's .env > that file. The first CLAUDE_HOME change pins DASHBOARD_DATA_DIR so the DB stays put. C1: codex-usage.js reads Codex rollout journals into sessions (new column tool) and token_usage, tracked per file in codex_rollouts; forks deduped by total vector, sub-agent threads folded into the root; pricing-sync also prices OpenAI models; PricingSettings with a vendor filter. C2: codex-hooks.js installs AgentHub's hooks into $CODEX_HOME/hooks.json on a click, through a stable forwarder; Codex trust is never written. The hook route creates tool='codex' sessions and folds sub-agent hooks into the root. D: antigravity-usage.js reads agy's per-conversation SQLite files (tokens from ModelUsageStats) into tool='antigravity' sessions; antigravity-hooks.js installs the named hook `agenthub` (PreInvocation, PostToolUse, Stop — never PreToolUse) into ~/.gemini/config/hooks.json; Settings → Antigravity tab; Gemini pricing. Whole-change review fixes: sameOriginGuard on both home PUTs, routers.missing on a CLAUDE_HOME change, reset-pricing scope, GET /api/sessions?tool=, clear-data covering the new tables, Codex child-thread events moving no status, hooks owning status only while current, EFOREIGN for a forwarder that is not ours, agy quiet window and turn rules, AGENTHUB_SETTINGS_FILE honoured from .env. Docs, OpenAPI and the CLAUDE.md marker updated. Server 2141, client 779.
This commit is contained in:
@@ -11,7 +11,7 @@ const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
const { getSettingsPath } = require("../server/lib/claude-home");
|
||||
const SETTINGS_PATH = getSettingsPath();
|
||||
// Read per call, not at load: the dashboard's CLAUDE_HOME can change while it runs.
|
||||
const HOOK_HANDLER = path.resolve(__dirname, "hook-handler.js").replace(/\\/g, "/");
|
||||
|
||||
/**
|
||||
@@ -81,7 +81,7 @@ function containerRefusalMessage() {
|
||||
` The hook command would embed this handler path:`,
|
||||
` ${HOOK_HANDLER}`,
|
||||
` written into:`,
|
||||
` ${SETTINGS_PATH}`,
|
||||
` ${getSettingsPath()}`,
|
||||
"",
|
||||
" Claude Code runs on the HOST. When ~/.claude is bind-mounted, a",
|
||||
" container-internal handler path does not exist on the host, so every host",
|
||||
@@ -155,12 +155,12 @@ function installHooks(silent = false) {
|
||||
}
|
||||
|
||||
let settings = {};
|
||||
if (fs.existsSync(SETTINGS_PATH)) {
|
||||
if (fs.existsSync(getSettingsPath())) {
|
||||
try {
|
||||
const raw = fs.readFileSync(SETTINGS_PATH, "utf8");
|
||||
const raw = fs.readFileSync(getSettingsPath(), "utf8");
|
||||
settings = JSON.parse(raw);
|
||||
} catch (err) {
|
||||
if (!silent) console.error(`Failed to parse ${SETTINGS_PATH}:`, err.message);
|
||||
if (!silent) console.error(`Failed to parse ${getSettingsPath()}:`, err.message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -185,13 +185,13 @@ function installHooks(silent = false) {
|
||||
}
|
||||
}
|
||||
|
||||
const dir = path.dirname(SETTINGS_PATH);
|
||||
const dir = path.dirname(getSettingsPath());
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
fs.writeFileSync(SETTINGS_PATH, JSON.stringify(settings, null, 2) + "\n", "utf8");
|
||||
fs.writeFileSync(getSettingsPath(), JSON.stringify(settings, null, 2) + "\n", "utf8");
|
||||
|
||||
if (!silent) {
|
||||
console.log(`Hook handler: ${HOOK_HANDLER}`);
|
||||
console.log(`Settings file: ${SETTINGS_PATH}`);
|
||||
console.log(`Settings file: ${getSettingsPath()}`);
|
||||
console.log(`Installed: ${installed} new, updated: ${updated} existing`);
|
||||
console.log("Claude Code hooks configured. Start a new Claude Code session to begin tracking.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user