mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-09 18:29:39 +00:00
feat: tfcode
This commit is contained in:
@@ -64,11 +64,20 @@ const TFCODE_CONFIG_DIR = ".tfcode"
|
||||
const TFCODE_TOOLS_FILE = "tools.json"
|
||||
|
||||
function getPythonSyncPath(): string {
|
||||
const possible = [
|
||||
// Check embedded python path first (for npm distribution)
|
||||
const embedded = [
|
||||
path.join(__dirname, "..", "..", "..", "..", "python"), // packages/tfcode/python
|
||||
path.join(__dirname, "..", "..", "..", "python"), // dist/python
|
||||
]
|
||||
for (const p of embedded) {
|
||||
if (existsSync(p)) return p
|
||||
}
|
||||
// Fallback to development paths
|
||||
const dev = [
|
||||
path.join(__dirname, "..", "..", "..", "..", "tf-sync", "src", "tf_sync"),
|
||||
path.join(process.cwd(), "packages", "tf-sync", "src", "tf_sync"),
|
||||
]
|
||||
for (const p of possible) {
|
||||
for (const p of dev) {
|
||||
if (existsSync(p)) return p
|
||||
}
|
||||
return "tf_sync"
|
||||
@@ -76,6 +85,7 @@ function getPythonSyncPath(): string {
|
||||
|
||||
async function runPythonSync(method: string, args: Record<string, unknown> = {}): Promise<unknown> {
|
||||
const credentials = await loadCredentials()
|
||||
const pythonPath = getPythonSyncPath()
|
||||
|
||||
const pythonCode = `
|
||||
import json
|
||||
@@ -83,6 +93,8 @@ import sys
|
||||
import os
|
||||
|
||||
try:
|
||||
# Add embedded tf_sync module path
|
||||
sys.path.insert(0, "${pythonPath.replace(/\\/g, "/")}")
|
||||
from tf_sync.config import load_config, validate_credentials
|
||||
from tf_sync.tools import sync_tools, sync_tools_by_type, ToolType
|
||||
from tf_sync.mcp import sync_mcp_servers
|
||||
|
||||
Reference in New Issue
Block a user