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:
@@ -11,4 +11,5 @@ export const API = {
|
|||||||
costs: `${API_PREFIX}/costs`,
|
costs: `${API_PREFIX}/costs`,
|
||||||
activity: `${API_PREFIX}/activity`,
|
activity: `${API_PREFIX}/activity`,
|
||||||
dashboard: `${API_PREFIX}/dashboard`,
|
dashboard: `${API_PREFIX}/dashboard`,
|
||||||
|
sidebarBadges: `${API_PREFIX}/sidebar-badges`,
|
||||||
} as const;
|
} as const;
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ export type {
|
|||||||
Agent,
|
Agent,
|
||||||
AgentPermissions,
|
AgentPermissions,
|
||||||
AgentKeyCreated,
|
AgentKeyCreated,
|
||||||
|
AgentConfigRevision,
|
||||||
Project,
|
Project,
|
||||||
Issue,
|
Issue,
|
||||||
IssueComment,
|
IssueComment,
|
||||||
@@ -46,6 +47,7 @@ export type {
|
|||||||
ApprovalComment,
|
ApprovalComment,
|
||||||
CostEvent,
|
CostEvent,
|
||||||
CostSummary,
|
CostSummary,
|
||||||
|
CostByAgent,
|
||||||
HeartbeatRun,
|
HeartbeatRun,
|
||||||
HeartbeatRunEvent,
|
HeartbeatRunEvent,
|
||||||
AgentRuntimeState,
|
AgentRuntimeState,
|
||||||
@@ -53,6 +55,7 @@ export type {
|
|||||||
LiveEvent,
|
LiveEvent,
|
||||||
DashboardSummary,
|
DashboardSummary,
|
||||||
ActivityEvent,
|
ActivityEvent,
|
||||||
|
SidebarBadges,
|
||||||
} from "./types/index.js";
|
} from "./types/index.js";
|
||||||
|
|
||||||
export {
|
export {
|
||||||
@@ -61,12 +64,14 @@ export {
|
|||||||
type CreateCompany,
|
type CreateCompany,
|
||||||
type UpdateCompany,
|
type UpdateCompany,
|
||||||
createAgentSchema,
|
createAgentSchema,
|
||||||
|
createAgentHireSchema,
|
||||||
updateAgentSchema,
|
updateAgentSchema,
|
||||||
createAgentKeySchema,
|
createAgentKeySchema,
|
||||||
wakeAgentSchema,
|
wakeAgentSchema,
|
||||||
agentPermissionsSchema,
|
agentPermissionsSchema,
|
||||||
updateAgentPermissionsSchema,
|
updateAgentPermissionsSchema,
|
||||||
type CreateAgent,
|
type CreateAgent,
|
||||||
|
type CreateAgentHire,
|
||||||
type UpdateAgent,
|
type UpdateAgent,
|
||||||
type CreateAgentKey,
|
type CreateAgentKey,
|
||||||
type WakeAgent,
|
type WakeAgent,
|
||||||
@@ -79,10 +84,12 @@ export {
|
|||||||
updateIssueSchema,
|
updateIssueSchema,
|
||||||
checkoutIssueSchema,
|
checkoutIssueSchema,
|
||||||
addIssueCommentSchema,
|
addIssueCommentSchema,
|
||||||
|
linkIssueApprovalSchema,
|
||||||
type CreateIssue,
|
type CreateIssue,
|
||||||
type UpdateIssue,
|
type UpdateIssue,
|
||||||
type CheckoutIssue,
|
type CheckoutIssue,
|
||||||
type AddIssueComment,
|
type AddIssueComment,
|
||||||
|
type LinkIssueApproval,
|
||||||
createGoalSchema,
|
createGoalSchema,
|
||||||
updateGoalSchema,
|
updateGoalSchema,
|
||||||
type CreateGoal,
|
type CreateGoal,
|
||||||
|
|||||||
@@ -35,3 +35,17 @@ export interface AgentKeyCreated {
|
|||||||
token: string;
|
token: string;
|
||||||
createdAt: Date;
|
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;
|
||||||
|
}
|
||||||
|
|||||||
@@ -17,7 +17,16 @@ export interface CostEvent {
|
|||||||
|
|
||||||
export interface CostSummary {
|
export interface CostSummary {
|
||||||
companyId: string;
|
companyId: string;
|
||||||
monthSpendCents: number;
|
spendCents: number;
|
||||||
monthBudgetCents: number;
|
budgetCents: number;
|
||||||
monthUtilizationPercent: number;
|
utilizationPercent: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CostByAgent {
|
||||||
|
agentId: string;
|
||||||
|
agentName: string | null;
|
||||||
|
agentStatus: string | null;
|
||||||
|
costCents: number;
|
||||||
|
inputTokens: number;
|
||||||
|
outputTokens: number;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
export type { Company } from "./company.js";
|
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 { Project } from "./project.js";
|
||||||
export type { Issue, IssueComment, IssueAncestor } from "./issue.js";
|
export type { Issue, IssueComment, IssueAncestor } from "./issue.js";
|
||||||
export type { Goal } from "./goal.js";
|
export type { Goal } from "./goal.js";
|
||||||
export type { Approval, ApprovalComment } from "./approval.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 {
|
export type {
|
||||||
HeartbeatRun,
|
HeartbeatRun,
|
||||||
HeartbeatRunEvent,
|
HeartbeatRunEvent,
|
||||||
@@ -14,3 +14,4 @@ export type {
|
|||||||
export type { LiveEvent } from "./live.js";
|
export type { LiveEvent } from "./live.js";
|
||||||
export type { DashboardSummary } from "./dashboard.js";
|
export type { DashboardSummary } from "./dashboard.js";
|
||||||
export type { ActivityEvent } from "./activity.js";
|
export type { ActivityEvent } from "./activity.js";
|
||||||
|
export type { SidebarBadges } from "./sidebar-badges.js";
|
||||||
|
|||||||
4
packages/shared/src/types/sidebar-badges.ts
Normal file
4
packages/shared/src/types/sidebar-badges.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
export interface SidebarBadges {
|
||||||
|
inbox: number;
|
||||||
|
approvals: number;
|
||||||
|
}
|
||||||
@@ -25,9 +25,18 @@ export const createAgentSchema = z.object({
|
|||||||
|
|
||||||
export type CreateAgent = z.infer<typeof createAgentSchema>;
|
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
|
export const updateAgentSchema = createAgentSchema
|
||||||
|
.omit({ permissions: true })
|
||||||
.partial()
|
.partial()
|
||||||
.extend({
|
.extend({
|
||||||
|
permissions: z.never().optional(),
|
||||||
status: z.enum(AGENT_STATUSES).optional(),
|
status: z.enum(AGENT_STATUSES).optional(),
|
||||||
spentMonthlyCents: z.number().int().nonnegative().optional(),
|
spentMonthlyCents: z.number().int().nonnegative().optional(),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ export const createApprovalSchema = z.object({
|
|||||||
type: z.enum(APPROVAL_TYPES),
|
type: z.enum(APPROVAL_TYPES),
|
||||||
requestedByAgentId: z.string().uuid().optional().nullable(),
|
requestedByAgentId: z.string().uuid().optional().nullable(),
|
||||||
payload: z.record(z.unknown()),
|
payload: z.record(z.unknown()),
|
||||||
|
issueIds: z.array(z.string().uuid()).optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export type CreateApproval = z.infer<typeof createApprovalSchema>;
|
export type CreateApproval = z.infer<typeof createApprovalSchema>;
|
||||||
|
|||||||
@@ -7,12 +7,14 @@ export {
|
|||||||
|
|
||||||
export {
|
export {
|
||||||
createAgentSchema,
|
createAgentSchema,
|
||||||
|
createAgentHireSchema,
|
||||||
updateAgentSchema,
|
updateAgentSchema,
|
||||||
createAgentKeySchema,
|
createAgentKeySchema,
|
||||||
wakeAgentSchema,
|
wakeAgentSchema,
|
||||||
agentPermissionsSchema,
|
agentPermissionsSchema,
|
||||||
updateAgentPermissionsSchema,
|
updateAgentPermissionsSchema,
|
||||||
type CreateAgent,
|
type CreateAgent,
|
||||||
|
type CreateAgentHire,
|
||||||
type UpdateAgent,
|
type UpdateAgent,
|
||||||
type CreateAgentKey,
|
type CreateAgentKey,
|
||||||
type WakeAgent,
|
type WakeAgent,
|
||||||
@@ -31,10 +33,12 @@ export {
|
|||||||
updateIssueSchema,
|
updateIssueSchema,
|
||||||
checkoutIssueSchema,
|
checkoutIssueSchema,
|
||||||
addIssueCommentSchema,
|
addIssueCommentSchema,
|
||||||
|
linkIssueApprovalSchema,
|
||||||
type CreateIssue,
|
type CreateIssue,
|
||||||
type UpdateIssue,
|
type UpdateIssue,
|
||||||
type CheckoutIssue,
|
type CheckoutIssue,
|
||||||
type AddIssueComment,
|
type AddIssueComment,
|
||||||
|
type LinkIssueApproval,
|
||||||
} from "./issue.js";
|
} from "./issue.js";
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
|||||||
@@ -35,3 +35,9 @@ export const addIssueCommentSchema = z.object({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export type AddIssueComment = z.infer<typeof addIssueCommentSchema>;
|
export type AddIssueComment = z.infer<typeof addIssueCommentSchema>;
|
||||||
|
|
||||||
|
export const linkIssueApprovalSchema = z.object({
|
||||||
|
approvalId: z.string().uuid(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export type LinkIssueApproval = z.infer<typeof linkIssueApprovalSchema>;
|
||||||
|
|||||||
Reference in New Issue
Block a user