Add shared types for agent hiring, config revisions, costs breakdown, and sidebar badges

Add AgentConfigRevision, CostByAgent, SidebarBadges types. Add createAgentHireSchema
with source issue linking and linkIssueApprovalSchema. Extend approval validator with
issueIds. Update cost summary to generic period naming. Add sidebar badges API path.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Forgotten
2026-02-19 13:02:25 -06:00
parent 778b39d3b5
commit db0b19bf9d
10 changed files with 61 additions and 5 deletions

View File

@@ -11,4 +11,5 @@ export const API = {
costs: `${API_PREFIX}/costs`,
activity: `${API_PREFIX}/activity`,
dashboard: `${API_PREFIX}/dashboard`,
sidebarBadges: `${API_PREFIX}/sidebar-badges`,
} as const;

View File

@@ -38,6 +38,7 @@ export type {
Agent,
AgentPermissions,
AgentKeyCreated,
AgentConfigRevision,
Project,
Issue,
IssueComment,
@@ -46,6 +47,7 @@ export type {
ApprovalComment,
CostEvent,
CostSummary,
CostByAgent,
HeartbeatRun,
HeartbeatRunEvent,
AgentRuntimeState,
@@ -53,6 +55,7 @@ export type {
LiveEvent,
DashboardSummary,
ActivityEvent,
SidebarBadges,
} from "./types/index.js";
export {
@@ -61,12 +64,14 @@ export {
type CreateCompany,
type UpdateCompany,
createAgentSchema,
createAgentHireSchema,
updateAgentSchema,
createAgentKeySchema,
wakeAgentSchema,
agentPermissionsSchema,
updateAgentPermissionsSchema,
type CreateAgent,
type CreateAgentHire,
type UpdateAgent,
type CreateAgentKey,
type WakeAgent,
@@ -79,10 +84,12 @@ export {
updateIssueSchema,
checkoutIssueSchema,
addIssueCommentSchema,
linkIssueApprovalSchema,
type CreateIssue,
type UpdateIssue,
type CheckoutIssue,
type AddIssueComment,
type LinkIssueApproval,
createGoalSchema,
updateGoalSchema,
type CreateGoal,

View File

@@ -35,3 +35,17 @@ export interface AgentKeyCreated {
token: string;
createdAt: Date;
}
export interface AgentConfigRevision {
id: string;
companyId: string;
agentId: string;
createdByAgentId: string | null;
createdByUserId: string | null;
source: string;
rolledBackFromRevisionId: string | null;
changedKeys: string[];
beforeConfig: Record<string, unknown>;
afterConfig: Record<string, unknown>;
createdAt: Date;
}

View File

@@ -17,7 +17,16 @@ export interface CostEvent {
export interface CostSummary {
companyId: string;
monthSpendCents: number;
monthBudgetCents: number;
monthUtilizationPercent: number;
spendCents: number;
budgetCents: number;
utilizationPercent: number;
}
export interface CostByAgent {
agentId: string;
agentName: string | null;
agentStatus: string | null;
costCents: number;
inputTokens: number;
outputTokens: number;
}

View File

@@ -1,10 +1,10 @@
export type { Company } from "./company.js";
export type { Agent, AgentKeyCreated } from "./agent.js";
export type { Agent, AgentPermissions, AgentKeyCreated, AgentConfigRevision } from "./agent.js";
export type { Project } from "./project.js";
export type { Issue, IssueComment, IssueAncestor } from "./issue.js";
export type { Goal } from "./goal.js";
export type { Approval, ApprovalComment } from "./approval.js";
export type { CostEvent, CostSummary } from "./cost.js";
export type { CostEvent, CostSummary, CostByAgent } from "./cost.js";
export type {
HeartbeatRun,
HeartbeatRunEvent,
@@ -14,3 +14,4 @@ export type {
export type { LiveEvent } from "./live.js";
export type { DashboardSummary } from "./dashboard.js";
export type { ActivityEvent } from "./activity.js";
export type { SidebarBadges } from "./sidebar-badges.js";

View File

@@ -0,0 +1,4 @@
export interface SidebarBadges {
inbox: number;
approvals: number;
}

View File

@@ -25,9 +25,18 @@ export const createAgentSchema = z.object({
export type CreateAgent = z.infer<typeof createAgentSchema>;
export const createAgentHireSchema = createAgentSchema.extend({
sourceIssueId: z.string().uuid().optional().nullable(),
sourceIssueIds: z.array(z.string().uuid()).optional(),
});
export type CreateAgentHire = z.infer<typeof createAgentHireSchema>;
export const updateAgentSchema = createAgentSchema
.omit({ permissions: true })
.partial()
.extend({
permissions: z.never().optional(),
status: z.enum(AGENT_STATUSES).optional(),
spentMonthlyCents: z.number().int().nonnegative().optional(),
});

View File

@@ -5,6 +5,7 @@ export const createApprovalSchema = z.object({
type: z.enum(APPROVAL_TYPES),
requestedByAgentId: z.string().uuid().optional().nullable(),
payload: z.record(z.unknown()),
issueIds: z.array(z.string().uuid()).optional(),
});
export type CreateApproval = z.infer<typeof createApprovalSchema>;

View File

@@ -7,12 +7,14 @@ export {
export {
createAgentSchema,
createAgentHireSchema,
updateAgentSchema,
createAgentKeySchema,
wakeAgentSchema,
agentPermissionsSchema,
updateAgentPermissionsSchema,
type CreateAgent,
type CreateAgentHire,
type UpdateAgent,
type CreateAgentKey,
type WakeAgent,
@@ -31,10 +33,12 @@ export {
updateIssueSchema,
checkoutIssueSchema,
addIssueCommentSchema,
linkIssueApprovalSchema,
type CreateIssue,
type UpdateIssue,
type CheckoutIssue,
type AddIssueComment,
type LinkIssueApproval,
} from "./issue.js";
export {

View File

@@ -35,3 +35,9 @@ export const addIssueCommentSchema = z.object({
});
export type AddIssueComment = z.infer<typeof addIssueCommentSchema>;
export const linkIssueApprovalSchema = z.object({
approvalId: z.string().uuid(),
});
export type LinkIssueApproval = z.infer<typeof linkIssueApprovalSchema>;