mirror of
https://github.com/bendtherules/ask262.git
synced 2026-08-18 13:21:55 +00:00
refactor(agent-tools): replace partIndex/totalParts with childrenSectionIds in getSectionContent
The getSectionContent tool schema and implementation now use `childrenSectionIds` (array of strings) instead of the previous pagination fields `partIndex` and `totalParts`. Updated Zod schema, output types, data handling, and returned objects accordingly. This change simplifies section handling by focusing on child section relationships rather than pagination.
This commit is contained in:
@@ -20,8 +20,7 @@ const sectionDataSchema = z.object({
|
|||||||
found: z.boolean(),
|
found: z.boolean(),
|
||||||
error: z.string().optional(),
|
error: z.string().optional(),
|
||||||
sectionTitle: z.string().optional(),
|
sectionTitle: z.string().optional(),
|
||||||
partIndex: z.number().optional(),
|
childrensectionids: z.array(z.string()).optional(),
|
||||||
totalParts: z.number().optional(),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const getSectionContentOutputSchema = z.object({
|
const getSectionContentOutputSchema = z.object({
|
||||||
@@ -87,8 +86,7 @@ export function createGetSectionContentTool(table: Table) {
|
|||||||
{
|
{
|
||||||
content: string[];
|
content: string[];
|
||||||
title?: string;
|
title?: string;
|
||||||
partIndex?: number;
|
childrenSectionIds?: string[];
|
||||||
totalParts?: number;
|
|
||||||
}
|
}
|
||||||
>();
|
>();
|
||||||
const queue: string[] = [...sectionIds];
|
const queue: string[] = [...sectionIds];
|
||||||
@@ -121,18 +119,18 @@ export function createGetSectionContentTool(table: Table) {
|
|||||||
totalparts?: number;
|
totalparts?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (typedResult.text) {
|
|
||||||
// Get or create section data
|
// Get or create section data
|
||||||
let section = sectionsData.get(currentId);
|
let section = sectionsData.get(currentId);
|
||||||
if (!section) {
|
if (!section) {
|
||||||
section = {
|
section = {
|
||||||
content: [],
|
content: [],
|
||||||
title: typedResult.sectiontitle,
|
title: typedResult.sectiontitle,
|
||||||
partIndex: typedResult.partindex ?? undefined,
|
childrenSectionIds: typedResult.childrensectionids,
|
||||||
totalParts: typedResult.totalparts ?? undefined,
|
|
||||||
};
|
};
|
||||||
sectionsData.set(currentId, section);
|
sectionsData.set(currentId, section);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typedResult.text) {
|
||||||
section.content.push(typedResult.text);
|
section.content.push(typedResult.text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,8 +155,7 @@ export function createGetSectionContentTool(table: Table) {
|
|||||||
content: data.content.join("\n\n"),
|
content: data.content.join("\n\n"),
|
||||||
found: true,
|
found: true,
|
||||||
sectionTitle: data.title,
|
sectionTitle: data.title,
|
||||||
partIndex: data.partIndex,
|
childrensectionids: data.childrenSectionIds,
|
||||||
totalParts: data.totalParts,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user