Complete budget-removal half-deletions: source typecheck green (Sam & Claude)
Hermes's branch left dangling/half-deleted budget refs that broke the build. Finished them: telegram.ts (orphaned intent-branch body), controlplane-pages.ts (orphaned budgetPolicyState fragment + budgetCard + AGENT_BUDGET_* import), controlplane-api.ts (renderTenantHome caller + getBudget fetch). tsc --noEmit now passes. STILL RED (Hermes to close — their deleted budget code's tests): controlplane-api.test.ts parse error (brace imbalance ~line 235 from the -123 trim); controlplane-heartbeat.test.ts behavioral 'woke:false for telegram wake, no task' (now true — intended budget-free behavior vs regression is Hermes's call). Pre-existing env reds (setup/cms, explanation-grounder) unchanged. NOT merged. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> --- Build: pass | Tests: FAIL — 19 failed
This commit is contained in:
parent
9286324830
commit
7ca8c87941
3 changed files with 2 additions and 46 deletions
|
|
@ -571,7 +571,6 @@ export class TelegramChannel implements Channel {
|
|||
if (intent === 'disk') await handleDiskCommand(ctx, chatJid);
|
||||
else if (intent === 'publish')
|
||||
await handlePublishReportCommand(ctx, chatJid);
|
||||
await handleBudgetReportCommand(ctx, chatJid);
|
||||
else if (intent === 'tasks') await handleTasksCommand(ctx, chatJid);
|
||||
else if (intent === 'tests')
|
||||
await handleTestReportCommand(ctx, chatJid);
|
||||
|
|
|
|||
|
|
@ -128,8 +128,7 @@ export function createControlplaneApiHandler(
|
|||
: null;
|
||||
if (tenant && req.method === 'GET' && pathname === '/') {
|
||||
recordTenantSurfaceMetric(hostSurface);
|
||||
const tenantBudget = await getBudget(pool, tenant.id);
|
||||
htmlResponse(res, 200, renderTenantHome(registry, tenant, tenantBudget));
|
||||
htmlResponse(res, 200, renderTenantHome(registry, tenant));
|
||||
return;
|
||||
}
|
||||
recordSurface404Metric(hostSurface);
|
||||
|
|
|
|||
|
|
@ -1,8 +1,4 @@
|
|||
import {
|
||||
AGENT_BUDGET_LOW_PCT,
|
||||
AGENT_BUDGET_PAUSE_PCT,
|
||||
CMS_WEBROOT,
|
||||
} from './config.js';
|
||||
import { CMS_WEBROOT } from './config.js';
|
||||
import { getOperatorDashboardUrl } from './controlplane-links.js';
|
||||
import { escapeHtml } from './controlplane-api-responses.js';
|
||||
import { formatDisplayDate } from './display-date.js';
|
||||
|
|
@ -22,21 +18,6 @@ function formatInteger(value: number): string {
|
|||
return new Intl.NumberFormat('en-US').format(value);
|
||||
}
|
||||
|
||||
budget: Budget,
|
||||
): 'normal' | 'low_budget' | 'paused' {
|
||||
const remainingPct =
|
||||
budget.daily_tokens > 0
|
||||
? Math.round((Math.max(0, budget.remaining) / budget.daily_tokens) * 100)
|
||||
: 0;
|
||||
if (budget.hard_limit_exceeded || remainingPct <= AGENT_BUDGET_PAUSE_PCT) {
|
||||
return 'paused';
|
||||
}
|
||||
if (remainingPct <= AGENT_BUDGET_LOW_PCT) {
|
||||
return 'low_budget';
|
||||
}
|
||||
return 'normal';
|
||||
}
|
||||
|
||||
function renderSurfaceShell(opts: {
|
||||
title: string;
|
||||
eyebrow: string;
|
||||
|
|
@ -423,28 +404,6 @@ export function renderTenantHome(
|
|||
const internalSiteCount = tenant.sites.filter((site) => site.exposure === 'internal').length;
|
||||
const publicSiteCount = tenant.sites.filter((site) => site.exposure === 'public').length;
|
||||
const disabledSiteCount = tenant.sites.filter((site) => site.exposure === 'disabled').length;
|
||||
const budgetCard = budget
|
||||
? (() => {
|
||||
const stateClass = state === 'normal' ? 'status' : 'status warn';
|
||||
const resetAt = formatDisplayDate(budget.reset_at, {
|
||||
includeTime: true,
|
||||
includeSeconds: false,
|
||||
});
|
||||
return `
|
||||
<section class="card">
|
||||
<p><span class="${stateClass}">${escapeHtml(state)}</span></p>
|
||||
<p class="metric">Tenant orchestrator budget for the current daily window.</p>
|
||||
<p><strong>Daily limit:</strong> <code>${escapeHtml(formatInteger(budget.daily_tokens))}</code></p>
|
||||
<p><strong>Spent today:</strong> <code>${escapeHtml(formatInteger(budget.spent_today))}</code></p>
|
||||
<p><strong>Remaining:</strong> <code>${escapeHtml(formatInteger(Math.max(0, budget.remaining)))}</code></p>
|
||||
<p><strong>Reset at:</strong> <code>${escapeHtml(resetAt)}</code></p>
|
||||
</section>`;
|
||||
})()
|
||||
: `
|
||||
<section class="card">
|
||||
<p><span class="status warn">not configured</span></p>
|
||||
<p>No tenant-scoped orchestrator budget was found for <code>${escapeHtml(tenant.id)}</code> in the controlplane budget table yet.</p>
|
||||
</section>`;
|
||||
const siteCards =
|
||||
tenant.sites.length > 0
|
||||
? tenant.sites
|
||||
|
|
@ -524,7 +483,6 @@ export function renderTenantHome(
|
|||
<li><a href="http://${escapeHtml(codeHost)}">Code service</a> <code>${escapeHtml(codeHost)}</code></li>
|
||||
</ul>
|
||||
</section>
|
||||
${budgetCard}
|
||||
`,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue