130
try {
131
const content = await fileService.readFile(agent.uri);
133
>
const md = parseFrontMatter(raw);
134
>
if (!md) {
135
configs.push({
136
name: agent.name,
137
prompt: raw,
138
});
140
>
// Match `parseAgentFile`'s name derivation (trim + falsy fallback) so
141
>
// the SDK config name equals the `resolvedAgentName` resolved from the
142
>
// parsed plugin agent; otherwise a whitespace-padded frontmatter `name`
143
>
// would make the SDK reject the session-start `agent:` as not found.
144
>
const name = md.getStringValue('name')?.trim() || agent.name;
145
>
const description = md.getStringValue('description');
146
>
const tools = md.getStringArrayValue('tools');
147
>
const skills = md.getStringArrayValue('skills');
148
>
let infer = md.getBooleanValue('infer');
149
>
const disableModelInvocation = md.getBooleanValue('disable-model-invocation');
150
>
if (infer === undefined && disableModelInvocation === true) {
151
infer = false;
152
}
154
>
let model: string | undefined = md.getStringValue('model') ?? undefined;
155
>
const models = md.getStringArrayValue('model') ?? undefined;
156
>
if (!model && models && Array.isArray(models) && models.length > 0) {
157
model = models[0];
158
}
160
>
name,
161
>
...(description ? { description } : {}),
162
>
...(model ? { model } : {}),
163
>
tools: tools && tools.length > 0 ? tools : null,
164
>
...(skills !== undefined ? { skills } : {}),
165
>
...(infer !== undefined ? { infer } : {}),
166
>
prompt,
167
>
});
168
>
}
169
} catch {
170
// Skip agents whose file cannot be read