Starting to modularize into separate cli / server packages. (#55)

* Starting to move a lot of code into packages/server

* More of the massive refactor, builds and runs, some issues though.

* Fixing outstanding issue with double messages.

* Fixing a minor UI issue.

* Fixing the build post-merge.

* Running formatting.

* Addressing comments.
This commit is contained in:
Evan Senter
2025-04-19 19:45:42 +01:00
committed by GitHub
parent 0c9e1ef61b
commit 3fce6cea27
46 changed files with 3946 additions and 3403 deletions
+19 -9
View File
@@ -25,27 +25,37 @@ class ToolRegistry {
}
/**
* Retrieves the list of tool schemas in the format required by Gemini.
* @returns A ToolListUnion containing the function declarations.
* Retrieves the list of tool schemas (FunctionDeclaration array).
* Extracts the declarations from the ToolListUnion structure.
* @returns An array of FunctionDeclarations.
*/
getToolSchemas(): ToolListUnion {
getFunctionDeclarations(): FunctionDeclaration[] {
const declarations: FunctionDeclaration[] = [];
this.tools.forEach((tool) => {
declarations.push(tool.schema);
});
return declarations;
}
// Return Gemini's expected format. Handle the case of no tools.
/**
* Deprecated/Internal? Retrieves schemas in the ToolListUnion format.
* Kept for reference, prefer getFunctionDeclarations.
*/
getToolSchemas(): ToolListUnion {
const declarations = this.getFunctionDeclarations();
if (declarations.length === 0) {
// Depending on the SDK version, you might need `undefined`, `[]`, or `[{ functionDeclarations: [] }]`
// Check the documentation for your @google/genai version.
// Let's assume an empty array works or signifies no tools.
return [];
// Or if it requires the structure:
// return [{ functionDeclarations: [] }];
}
return [{ functionDeclarations: declarations }];
}
/**
* Returns an array of all registered tool instances.
*/
getAllTools(): Tool[] {
return Array.from(this.tools.values());
}
/**
* Optional: Get a list of registered tool names.
*/