Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/lib/schemas/io/config-io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,12 @@ export class ConfigIO {
*/
async writeProjectSpec(data: AgentCoreProjectSpec): Promise<void> {
const filePath = this.pathResolver.getAgentConfigPath();
await this.validateAndWrite(filePath, 'AgentCore Project Config', AgentCoreProjectSpecSchema, data);
// TODO: extend this to all resource arrays so empty defaults never pollute agentcore.json
const cleaned = { ...data };
if (cleaned.configBundles?.length === 0) delete (cleaned as Record<string, unknown>).configBundles;
if (cleaned.abTests?.length === 0) delete (cleaned as Record<string, unknown>).abTests;
if (cleaned.httpGateways?.length === 0) delete (cleaned as Record<string, unknown>).httpGateways;
await this.validateAndWrite(filePath, 'AgentCore Project Config', AgentCoreProjectSpecSchema, cleaned);
}

/**
Expand Down
48 changes: 21 additions & 27 deletions src/schema/schemas/agentcore-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,39 +325,33 @@ export const AgentCoreProjectSpecSchema = z

configBundles: z
.array(ConfigBundleSchema)
.optional()
.superRefine((items, ctx) => {
if (items) {
uniqueBy(
(bundle: { name: string }) => bundle.name,
(name: string) => `Duplicate config bundle name: ${name}`
)(items, ctx);
}
}),
.default([])
.superRefine(
uniqueBy(
bundle => bundle.name,
name => `Duplicate config bundle name: ${name}`
)
),

abTests: z
.array(ABTestSchema)
.optional()
.superRefine((items, ctx) => {
if (items) {
uniqueBy(
(test: { name: string }) => test.name,
(name: string) => `Duplicate AB test name: ${name}`
)(items, ctx);
}
}),
.default([])
.superRefine(
uniqueBy(
test => test.name,
name => `Duplicate AB test name: ${name}`
)
),

httpGateways: z
.array(HttpGatewaySchema)
.optional()
.superRefine((items, ctx) => {
if (items) {
uniqueBy(
(gw: { name: string }) => gw.name,
(name: string) => `Duplicate HTTP gateway name: ${name}`
)(items, ctx);
}
}),
.default([])
.superRefine(
uniqueBy(
gw => gw.name,
name => `Duplicate HTTP gateway name: ${name}`
)
),
})
.strict()
.superRefine((spec, ctx) => {
Expand Down
Loading