This commit is contained in:
2026-02-27 22:10:46 -05:00
parent fcd60c908b
commit a84ea40d16
11 changed files with 82 additions and 3 deletions

2
scripts/tool_call.bat Normal file
View File

@@ -0,0 +1,2 @@
@echo off
uv run python "%~dp0tool_call.py" %*

2
scripts/tool_call.cmd Normal file
View File

@@ -0,0 +1,2 @@
@echo off
uv run python scripts\tool_call.py %*

56
scripts/tool_call.cpp Normal file
View File

@@ -0,0 +1,56 @@
#include <iostream>
#include <string>
#include <vector>
#include <windows.h>
#include <process.h>
int main(int argc, char* argv[]) {
if (argc < 2) {
std::cerr << "No tool name provided" << std::endl;
return 1;
}
std::string tool_name = argv[1];
// Construct the command: uv run python scripts/tool_call.py <tool_name>
std::string command = "uv run python scripts/tool_call.py " + tool_name;
// Use CreateProcess to run the command and handle pipes
STARTUPINFOA si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
si.dwFlags = STARTF_USESTDHANDLES;
si.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
si.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
si.hStdError = GetStdHandle(STD_ERROR_HANDLE);
ZeroMemory(&pi, sizeof(pi));
// Create the process
if (!CreateProcessA(
NULL,
(char*)command.c_str(),
NULL,
NULL,
TRUE,
0,
NULL,
NULL,
&si,
&pi
)) {
std::cerr << "CreateProcess failed (" << GetLastError() << ")" << std::endl;
return 1;
}
// Wait for the process to finish
WaitForSingleObject(pi.hProcess, INFINITE);
DWORD exit_code;
GetExitCodeProcess(pi.hProcess, &exit_code);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
return exit_code;
}

BIN
scripts/tool_call.exe Normal file

Binary file not shown.

3
scripts/tool_call.ps1 Normal file
View File

@@ -0,0 +1,3 @@
$toolName = $args[0]
$inputData = $input | Out-String
$inputData | uv run python "$PSScriptRoot/tool_call.py" $toolName

View File

@@ -1,6 +1,11 @@
import sys
import json
import os
import io
# Force UTF-8 for stdout/stderr to avoid encoding issues on Windows
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8')
# Add project root to sys.path
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))

View File

@@ -37,6 +37,11 @@ def main():
}
})
# Rename 'parameters' to 'parametersJsonSchema' for Gemini CLI
for spec in specs:
if "parameters" in spec:
spec["parametersJsonSchema"] = spec.pop("parameters")
# Output as JSON array of FunctionDeclarations
print(json.dumps(specs, indent=2))