fix(build): corrigir erros de importação no build de produção
- PatternDetector e SkillEmergence: corrigir alias @/db → caminho relativo correto (../../../db) - PatternDetector e SkillEmergence: corrigir @/shared/schema → ../../../shared/schema - server/openclaw: substituir arcadiaSkills (inexistente) por skills do schema - SkillEmergence: substituir axios (não instalado) por fetch nativo (Node 20) - server/skills/routes.ts: adicionar export registerSkillRoutes() esperado por routes.ts O build estava quebrado desde a Fase 4 (OpenClaw). Esses erros impediam o Coolify de gerar o container com o Design Studio na sidebar. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
e4bc9fa24b
commit
0a357a4617
|
|
@ -8,8 +8,8 @@
|
||||||
* Fase 4: OpenClaw Embutido
|
* Fase 4: OpenClaw Embutido
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { db } from "@/db";
|
import { db } from "../../../db";
|
||||||
import { detectedPatterns, skillSuggestions } from "@/shared/schema";
|
import { detectedPatterns, skillSuggestions } from "../../../shared/schema";
|
||||||
import { eq, and, gte } from "drizzle-orm";
|
import { eq, and, gte } from "drizzle-orm";
|
||||||
import { EventEmitter } from "events";
|
import { EventEmitter } from "events";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,8 @@
|
||||||
* Fase 4: OpenClaw Embutido
|
* Fase 4: OpenClaw Embutido
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { db } from "@/db";
|
import { db } from "../../../db";
|
||||||
import { skills } from "@/shared/schema";
|
import { skills } from "../../../shared/schema";
|
||||||
import axios, { AxiosError } from "axios";
|
|
||||||
|
|
||||||
interface SkillSuggestion {
|
interface SkillSuggestion {
|
||||||
id: string;
|
id: string;
|
||||||
|
|
@ -155,9 +154,18 @@ Código:
|
||||||
*/
|
*/
|
||||||
private async callBlackboard(prompt: string, suggestion: SkillSuggestion): Promise<BlackboardResponse> {
|
private async callBlackboard(prompt: string, suggestion: SkillSuggestion): Promise<BlackboardResponse> {
|
||||||
try {
|
try {
|
||||||
const response = await axios.post(
|
const controller = new AbortController();
|
||||||
|
const timeout = setTimeout(() => controller.abort(), 30000);
|
||||||
|
|
||||||
|
const response = await fetch(
|
||||||
`${this.blackboardUrl}/generate-skill`,
|
`${this.blackboardUrl}/generate-skill`,
|
||||||
{
|
{
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-Key": this.apiKey,
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
prompt,
|
prompt,
|
||||||
skill_name: suggestion.suggested_skill_name,
|
skill_name: suggestion.suggested_skill_name,
|
||||||
context: {
|
context: {
|
||||||
|
|
@ -165,35 +173,29 @@ Código:
|
||||||
confidence: suggestion.confidence,
|
confidence: suggestion.confidence,
|
||||||
metadata: suggestion.pattern.metadata,
|
metadata: suggestion.pattern.metadata,
|
||||||
},
|
},
|
||||||
},
|
}),
|
||||||
{
|
signal: controller.signal,
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-API-Key": this.apiKey,
|
|
||||||
},
|
|
||||||
timeout: 30000, // 30 segundos timeout
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
clearTimeout(timeout);
|
||||||
|
|
||||||
|
const data = await response.json() as any;
|
||||||
|
|
||||||
console.log("[SkillEmergence] Resposta do Blackboard recebida");
|
console.log("[SkillEmergence] Resposta do Blackboard recebida");
|
||||||
|
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
code: response.data.code,
|
code: data.code,
|
||||||
language: response.data.language || "typescript",
|
language: data.language || "typescript",
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const axiosError = error as AxiosError<any>;
|
const err = error as Error;
|
||||||
|
|
||||||
console.error("[SkillEmergence] Erro ao chamar Blackboard:", {
|
console.error("[SkillEmergence] Erro ao chamar Blackboard:", err.message);
|
||||||
status: axiosError.response?.status,
|
|
||||||
data: axiosError.response?.data,
|
|
||||||
message: axiosError.message,
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
error: axiosError.message,
|
error: err.message,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import crypto from "crypto";
|
||||||
import OpenAI from "openai";
|
import OpenAI from "openai";
|
||||||
import { db } from "../../db/index";
|
import { db } from "../../db/index";
|
||||||
import {
|
import {
|
||||||
arcadiaSkills,
|
skills as arcadiaSkills,
|
||||||
skillExecutions,
|
skillExecutions,
|
||||||
detectedPatterns,
|
detectedPatterns,
|
||||||
skillSuggestions,
|
skillSuggestions,
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
import type { Express, Request, Response } from "express";
|
import type { Express, Request, Response } from "express";
|
||||||
import { db } from "../../db/index";
|
import { db } from "../../db/index";
|
||||||
import { arcadiaSkills, detectedPatterns, skillSuggestions } from "@shared/schema";
|
import { skills as arcadiaSkills, detectedPatterns, skillSuggestions } from "@shared/schema";
|
||||||
import { eq, and, desc } from "drizzle-orm";
|
import { eq, and, desc } from "drizzle-orm";
|
||||||
|
|
||||||
export function registerOpenClawRoutes(app: Express): void {
|
export function registerOpenClawRoutes(app: Express): void {
|
||||||
|
|
|
||||||
|
|
@ -111,3 +111,7 @@ router.get("/:id/executions", async (req, res) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
|
||||||
|
export function registerSkillRoutes(app: any): void {
|
||||||
|
app.use("/api/skills", router);
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue