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:
@@ -36,7 +36,7 @@ const routers = require("./ai-routers");
|
||||
const { patchSettings } = require("./cc-mutate");
|
||||
const { excludeFromGit } = require("./git-exclude");
|
||||
const { getCodexHome } = require("./codex-home");
|
||||
const { lanesByRouter, setRouterProfile } = require("./lanes");
|
||||
const { lanesByRouter, listLanes, setRouterProfile } = require("./lanes");
|
||||
|
||||
/**
|
||||
* The env var Codex is told to read the router key from. One fixed name rather
|
||||
@@ -255,6 +255,43 @@ function reapplyToLanes(profileName) {
|
||||
return { updated, failed };
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-write the router layer of every codex lane on a router, into the CURRENT
|
||||
* `$CODEX_HOME`. Called after CODEX_HOME moves: the layer `codex -p <name>`
|
||||
* loads lives there, so without this every such lane would fail to start.
|
||||
* Per-lane best effort, like `reapplyToLanes`.
|
||||
*
|
||||
* @returns {{updated:number, failed:string[]}}
|
||||
*/
|
||||
function reapplyCodexLayers() {
|
||||
const failed = [];
|
||||
let updated = 0;
|
||||
for (const lane of listLanes()) {
|
||||
if (lane.tool !== "codex" || !lane.router_profile || lane.router_profile === "native") continue;
|
||||
try {
|
||||
applyRouterToLane(lane, lane.router_profile);
|
||||
updated += 1;
|
||||
} catch (e) {
|
||||
failed.push(`${lane.id} (${lane.title || lane.cwd}): ${e.code || e.message}`);
|
||||
}
|
||||
}
|
||||
return { updated, failed };
|
||||
}
|
||||
|
||||
/**
|
||||
* The lanes naming an AI Router profile the store no longer has — after
|
||||
* CLAUDE_HOME moved (the store is `<CLAUDE_HOME>/agenthub-routers/`), such a
|
||||
* lane starts on its base configuration (`readOrNull`), so the move says so.
|
||||
* @returns {string[]} `"<id> (<title>): <profile>"` per lane.
|
||||
*/
|
||||
function lanesWithMissingRouter() {
|
||||
return listLanes()
|
||||
.filter(
|
||||
(l) => l.router_profile && l.router_profile !== "native" && !readOrNull(l.router_profile)
|
||||
)
|
||||
.map((l) => `${l.id} (${l.title || l.cwd}): ${l.router_profile}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Detach `profileName` from every lane using it, and delete the Codex layer
|
||||
* file it wrote.
|
||||
@@ -291,8 +328,10 @@ function detachFromLanes(profileName) {
|
||||
module.exports = {
|
||||
applyRouterToLane,
|
||||
reapplyToLanes,
|
||||
reapplyCodexLayers,
|
||||
detachFromLanes,
|
||||
routerArgvForSpawn,
|
||||
routerEnvForSpawn,
|
||||
lanesWithMissingRouter,
|
||||
CODEX_KEY_ENV,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user