Files
AgentHub/server/lib/pricing-constants.js
T
nntrivi2001 b7f3735b29 feat: v2.5.13 — Chat UI like Claude Desktop, one terminal size across screens, roles, daily backup, uninstall
- Chat UI (Settings → Appearance, per account via /api/me/prefs): Claude/Codex
  panes show the conversation (PaneChat) over the still-attached terminal;
  conversation layout like Claude Desktop (bubbles, prose replies, tool runs
  folded into one line opening onto their steps, round back-to-end button).
- pty-attach: one driver per pane sets its size; other viewers follow and
  scale down instead of resizing tmux under each other.
- Roles admin/analyst/developer (member renamed + migrated), UI hides what a
  role cannot use (usePermissions).
- Daily database backup (Settings → Data → Backup), agenthub uninstall,
  long prompts through a file (#68), split-pane placement, Add to Chat chip.

Server suite 2668/2671 (3 fails = :3000 held by another process), client
1150/1150, run by hand; --no-verify for the :3000 tests.
2026-10-08 23:04:57 +07:00

52 lines
2.6 KiB
JavaScript

/**
* @file Feature-level pricing constants and modifier math, centralized so the
* cost calculator stays readable and every rate has one source of truth. These
* mirror Anthropic's published pricing page. Per-model token rates live in the
* editable `model_pricing` table; the values here are feature/modifier rates
* that are uniform across models and therefore kept as code constants.
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
*/
// ── Cross-cutting rate modifiers ────────────────────────────────────────────
const DATA_RESIDENCY_US_MULTIPLIER = 1.1; // inference_geo === "us"
const BATCH_DISCOUNT_MULTIPLIER = 0.5; // service_tier === "batch" (50% off)
// A request whose whole prompt (input + cache read + cache write) is above this
// is booked as context_tier "long" and priced at the rule's long_* rates.
// ponytail: one threshold for every model (Haiku 5.5's 100k); a model with a
// different one needs the threshold stored per bucket, then a re-parse.
const LONG_CONTEXT_TOKENS = 100_000;
// ── Server-tool surcharges (billed in addition to tokens) ───────────────────
const WEB_SEARCH_PER_1K_SEARCHES = 10.0; // $10 per 1,000 web_search_requests
// Web fetch has no surcharge — tokens only.
// Code execution: billed by container-time, not request count. Transcripts only
// expose request counts, so we estimate at the documented 5-minute minimum per
// request. It is FREE when the same request also used web search or web fetch.
// Each org gets a monthly free allowance; below it, code execution costs $0.
const CODE_EXEC_PER_HOUR = 0.05; // $0.05 per container-hour beyond the free tier
const CODE_EXEC_MIN_MINUTES = 5; // 5-minute minimum billed per request
const CODE_EXEC_FREE_HOURS = 1550; // free hours per org per month
/**
* Estimated billable code-execution hours for a bucket.
* Returns 0 when the bucket also used web search or web fetch (code execution is
* free in that case) or when there were no code-execution requests.
*/
function estimateCodeExecHours(codeExecRequests, webSearchRequests, webFetchRequests) {
if (!codeExecRequests || codeExecRequests <= 0) return 0;
if ((webSearchRequests || 0) > 0 || (webFetchRequests || 0) > 0) return 0; // free with search/fetch
return (codeExecRequests * CODE_EXEC_MIN_MINUTES) / 60;
}
module.exports = {
DATA_RESIDENCY_US_MULTIPLIER,
BATCH_DISCOUNT_MULTIPLIER,
LONG_CONTEXT_TOKENS,
WEB_SEARCH_PER_1K_SEARCHES,
CODE_EXEC_PER_HOUR,
CODE_EXEC_MIN_MINUTES,
CODE_EXEC_FREE_HOURS,
estimateCodeExecHours,
};