2026-02-16 13:31:47 -06:00
|
|
|
import { z } from "zod";
|
Expand data model with companies, approvals, costs, and heartbeats
Add new DB schemas: companies, agent_api_keys, approvals, cost_events,
heartbeat_runs, issue_comments. Add corresponding shared types and
validators. Update existing schemas (agents, goals, issues, projects)
with new fields for company association, budgets, and richer metadata.
Generate initial Drizzle migration. Update seed data.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 09:07:22 -06:00
|
|
|
import {
|
|
|
|
|
AGENT_ADAPTER_TYPES,
|
2026-02-25 08:39:11 -06:00
|
|
|
AGENT_ICON_NAMES,
|
Expand data model with companies, approvals, costs, and heartbeats
Add new DB schemas: companies, agent_api_keys, approvals, cost_events,
heartbeat_runs, issue_comments. Add corresponding shared types and
validators. Update existing schemas (agents, goals, issues, projects)
with new fields for company association, budgets, and richer metadata.
Generate initial Drizzle migration. Update seed data.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 09:07:22 -06:00
|
|
|
AGENT_ROLES,
|
|
|
|
|
AGENT_STATUSES,
|
|
|
|
|
} from "../constants.js";
|
2026-02-19 15:43:43 -06:00
|
|
|
import { envConfigSchema } from "./secret.js";
|
2026-02-16 13:31:47 -06:00
|
|
|
|
2026-02-19 09:10:38 -06:00
|
|
|
export const agentPermissionsSchema = z.object({
|
|
|
|
|
canCreateAgents: z.boolean().optional().default(false),
|
|
|
|
|
});
|
|
|
|
|
|
2026-02-19 15:43:43 -06:00
|
|
|
const adapterConfigSchema = z.record(z.unknown()).superRefine((value, ctx) => {
|
|
|
|
|
const envValue = value.env;
|
|
|
|
|
if (envValue === undefined) return;
|
|
|
|
|
const parsed = envConfigSchema.safeParse(envValue);
|
|
|
|
|
if (!parsed.success) {
|
|
|
|
|
ctx.addIssue({
|
|
|
|
|
code: z.ZodIssueCode.custom,
|
|
|
|
|
message: "adapterConfig.env must be a map of valid env bindings",
|
|
|
|
|
path: ["env"],
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2026-02-16 13:31:47 -06:00
|
|
|
export const createAgentSchema = z.object({
|
|
|
|
|
name: z.string().min(1),
|
Expand data model with companies, approvals, costs, and heartbeats
Add new DB schemas: companies, agent_api_keys, approvals, cost_events,
heartbeat_runs, issue_comments. Add corresponding shared types and
validators. Update existing schemas (agents, goals, issues, projects)
with new fields for company association, budgets, and richer metadata.
Generate initial Drizzle migration. Update seed data.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 09:07:22 -06:00
|
|
|
role: z.enum(AGENT_ROLES).optional().default("general"),
|
|
|
|
|
title: z.string().optional().nullable(),
|
2026-02-25 08:39:11 -06:00
|
|
|
icon: z.enum(AGENT_ICON_NAMES).optional().nullable(),
|
2026-02-16 13:31:47 -06:00
|
|
|
reportsTo: z.string().uuid().optional().nullable(),
|
Expand data model with companies, approvals, costs, and heartbeats
Add new DB schemas: companies, agent_api_keys, approvals, cost_events,
heartbeat_runs, issue_comments. Add corresponding shared types and
validators. Update existing schemas (agents, goals, issues, projects)
with new fields for company association, budgets, and richer metadata.
Generate initial Drizzle migration. Update seed data.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 09:07:22 -06:00
|
|
|
capabilities: z.string().optional().nullable(),
|
|
|
|
|
adapterType: z.enum(AGENT_ADAPTER_TYPES).optional().default("process"),
|
2026-02-19 15:43:43 -06:00
|
|
|
adapterConfig: adapterConfigSchema.optional().default({}),
|
2026-02-17 12:24:38 -06:00
|
|
|
runtimeConfig: z.record(z.unknown()).optional().default({}),
|
Expand data model with companies, approvals, costs, and heartbeats
Add new DB schemas: companies, agent_api_keys, approvals, cost_events,
heartbeat_runs, issue_comments. Add corresponding shared types and
validators. Update existing schemas (agents, goals, issues, projects)
with new fields for company association, budgets, and richer metadata.
Generate initial Drizzle migration. Update seed data.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 09:07:22 -06:00
|
|
|
budgetMonthlyCents: z.number().int().nonnegative().optional().default(0),
|
2026-02-19 09:10:38 -06:00
|
|
|
permissions: agentPermissionsSchema.optional(),
|
2026-02-16 13:31:47 -06:00
|
|
|
metadata: z.record(z.unknown()).optional().nullable(),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export type CreateAgent = z.infer<typeof createAgentSchema>;
|
|
|
|
|
|
2026-02-19 13:02:25 -06:00
|
|
|
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>;
|
|
|
|
|
|
2026-02-16 13:31:47 -06:00
|
|
|
export const updateAgentSchema = createAgentSchema
|
2026-02-19 13:02:25 -06:00
|
|
|
.omit({ permissions: true })
|
2026-02-16 13:31:47 -06:00
|
|
|
.partial()
|
|
|
|
|
.extend({
|
2026-02-19 13:02:25 -06:00
|
|
|
permissions: z.never().optional(),
|
2026-02-16 13:31:47 -06:00
|
|
|
status: z.enum(AGENT_STATUSES).optional(),
|
Expand data model with companies, approvals, costs, and heartbeats
Add new DB schemas: companies, agent_api_keys, approvals, cost_events,
heartbeat_runs, issue_comments. Add corresponding shared types and
validators. Update existing schemas (agents, goals, issues, projects)
with new fields for company association, budgets, and richer metadata.
Generate initial Drizzle migration. Update seed data.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 09:07:22 -06:00
|
|
|
spentMonthlyCents: z.number().int().nonnegative().optional(),
|
2026-02-16 13:31:47 -06:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export type UpdateAgent = z.infer<typeof updateAgentSchema>;
|
Expand data model with companies, approvals, costs, and heartbeats
Add new DB schemas: companies, agent_api_keys, approvals, cost_events,
heartbeat_runs, issue_comments. Add corresponding shared types and
validators. Update existing schemas (agents, goals, issues, projects)
with new fields for company association, budgets, and richer metadata.
Generate initial Drizzle migration. Update seed data.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 09:07:22 -06:00
|
|
|
|
2026-03-02 14:21:24 -06:00
|
|
|
export const updateAgentInstructionsPathSchema = z.object({
|
|
|
|
|
path: z.string().trim().min(1).nullable(),
|
|
|
|
|
adapterConfigKey: z.string().trim().min(1).optional(),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export type UpdateAgentInstructionsPath = z.infer<typeof updateAgentInstructionsPathSchema>;
|
|
|
|
|
|
Expand data model with companies, approvals, costs, and heartbeats
Add new DB schemas: companies, agent_api_keys, approvals, cost_events,
heartbeat_runs, issue_comments. Add corresponding shared types and
validators. Update existing schemas (agents, goals, issues, projects)
with new fields for company association, budgets, and richer metadata.
Generate initial Drizzle migration. Update seed data.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 09:07:22 -06:00
|
|
|
export const createAgentKeySchema = z.object({
|
|
|
|
|
name: z.string().min(1).default("default"),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export type CreateAgentKey = z.infer<typeof createAgentKeySchema>;
|
2026-02-17 12:24:38 -06:00
|
|
|
|
|
|
|
|
export const wakeAgentSchema = z.object({
|
|
|
|
|
source: z.enum(["timer", "assignment", "on_demand", "automation"]).optional().default("on_demand"),
|
|
|
|
|
triggerDetail: z.enum(["manual", "ping", "callback", "system"]).optional(),
|
|
|
|
|
reason: z.string().optional().nullable(),
|
|
|
|
|
payload: z.record(z.unknown()).optional().nullable(),
|
|
|
|
|
idempotencyKey: z.string().optional().nullable(),
|
2026-03-13 14:53:30 -05:00
|
|
|
forceFreshSession: z.preprocess(
|
|
|
|
|
(value) => (value === null ? undefined : value),
|
|
|
|
|
z.boolean().optional().default(false),
|
|
|
|
|
),
|
2026-02-17 12:24:38 -06:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export type WakeAgent = z.infer<typeof wakeAgentSchema>;
|
2026-02-19 09:10:38 -06:00
|
|
|
|
2026-02-19 14:01:40 -06:00
|
|
|
export const resetAgentSessionSchema = z.object({
|
|
|
|
|
taskKey: z.string().min(1).optional().nullable(),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export type ResetAgentSession = z.infer<typeof resetAgentSessionSchema>;
|
|
|
|
|
|
2026-02-20 12:50:23 -06:00
|
|
|
export const testAdapterEnvironmentSchema = z.object({
|
|
|
|
|
adapterConfig: adapterConfigSchema.optional().default({}),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export type TestAdapterEnvironment = z.infer<typeof testAdapterEnvironmentSchema>;
|
|
|
|
|
|
2026-02-19 09:10:38 -06:00
|
|
|
export const updateAgentPermissionsSchema = z.object({
|
|
|
|
|
canCreateAgents: z.boolean(),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export type UpdateAgentPermissions = z.infer<typeof updateAgentPermissionsSchema>;
|