45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
import type { CreateConfigValues } from "../components/AgentConfigForm";
|
|
import { buildNewAgentRuntimeConfig } from "./new-agent-runtime-config";
|
|
import type { AgentPermissions } from "@paperclipai/shared";
|
|
|
|
export function buildNewAgentHirePayload(input: {
|
|
name: string;
|
|
effectiveRole: string;
|
|
title?: string;
|
|
reportsTo?: string | null;
|
|
selectedSkillKeys?: string[];
|
|
configValues: CreateConfigValues;
|
|
adapterConfig: Record<string, unknown>;
|
|
permissions?: Partial<AgentPermissions>;
|
|
}) {
|
|
const {
|
|
name,
|
|
effectiveRole,
|
|
title,
|
|
reportsTo,
|
|
selectedSkillKeys = [],
|
|
configValues,
|
|
adapterConfig,
|
|
permissions,
|
|
} = input;
|
|
|
|
return {
|
|
name: name.trim(),
|
|
role: effectiveRole,
|
|
...(title?.trim() ? { title: title.trim() } : {}),
|
|
...(reportsTo ? { reportsTo } : {}),
|
|
...(selectedSkillKeys.length > 0 ? { desiredSkills: selectedSkillKeys } : {}),
|
|
adapterType: configValues.adapterType,
|
|
defaultEnvironmentId: configValues.defaultEnvironmentId ?? null,
|
|
adapterConfig,
|
|
runtimeConfig: buildNewAgentRuntimeConfig({
|
|
heartbeatEnabled: configValues.heartbeatEnabled,
|
|
intervalSec: configValues.intervalSec,
|
|
cheapModel: configValues.cheapModel,
|
|
cheapModelEnabled: configValues.cheapModelEnabled,
|
|
}),
|
|
budgetMonthlyCents: 0,
|
|
...(permissions ? { permissions } : {}),
|
|
};
|
|
}
|