resolve more conflicts and push

This commit is contained in:
2025-04-30 10:14:56 -03:00
parent aa936faf92
commit 59833f5d3f
6 changed files with 24 additions and 69 deletions

View File

@ -32,7 +32,8 @@
"lodash": "^4.17.21", "lodash": "^4.17.21",
"nodemon": "^3.1.0", "nodemon": "^3.1.0",
"seedrandom": "^3.0.5", "seedrandom": "^3.0.5",
"tail": "^2.2.6" "tail": "^2.2.6",
"uuid": "^11.1.0"
}, },
"peerDependencies": { "peerDependencies": {
"@_koii/namespace-wrapper": "^1.0.23" "@_koii/namespace-wrapper": "^1.0.23"

View File

@ -1,4 +1,4 @@
import { getOrcaClient } from "@_koii/task-manager/extensions";
import { namespaceWrapper, TASK_ID } from "@_koii/namespace-wrapper"; import { namespaceWrapper, TASK_ID } from "@_koii/namespace-wrapper";
import "dotenv/config"; import "dotenv/config";
import { status, middleServerUrl } from "../utils/constant"; import { status, middleServerUrl } from "../utils/constant";
@ -9,8 +9,6 @@ import { LogLevel } from "@_koii/namespace-wrapper/dist/types";
import { actionMessage } from "../utils/constant"; import { actionMessage } from "../utils/constant";
import { errorMessage } from "../utils/constant"; import { errorMessage } from "../utils/constant";
import { v4 as uuidv4 } from "uuid"; import { v4 as uuidv4 } from "uuid";
import { handleOrcaClientCreation, handleRequest } from "../utils/orcaHandler/orcaHandler";
dotenv.config(); dotenv.config();
export async function task(roundNumber: number): Promise<void> { export async function task(roundNumber: number): Promise<void> {
@ -24,7 +22,6 @@ export async function task(roundNumber: number): Promise<void> {
// Changed from 3 to 4 to have more time // Changed from 3 to 4 to have more time
if (roundNumber >= 4) { if (roundNumber >= 4) {
const triggerFetchAuditResult = await fetch(`${middleServerUrl}/summarizer/worker/update-audit-result`, { const triggerFetchAuditResult = await fetch(`${middleServerUrl}/summarizer/worker/update-audit-result`, {
const triggerFetchAuditResult = await fetch(`${middleServerUrl}/api/summarizer/trigger-fetch-audit-result`, {
method: "POST", method: "POST",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -37,14 +34,7 @@ export async function task(roundNumber: number): Promise<void> {
} }
console.log(`[TASK] EXECUTE TASK FOR ROUND ${roundNumber}`); console.log(`[TASK] EXECUTE TASK FOR ROUND ${roundNumber}`);
try { try {
let orcaClient; const orcaClient = await getOrcaClient();
try {
orcaClient = await handleOrcaClientCreation();
}catch{
await namespaceWrapper.logMessage(LogLevel.Error, errorMessage.NO_ORCA_CLIENT, actionMessage.NO_ORCA_CLIENT);
await namespaceWrapper.storeSet(`result-${roundNumber}`, status.NO_ORCA_CLIENT);
return;
}
// check if the env variable is valid // check if the env variable is valid
if (!process.env.ANTHROPIC_API_KEY) { if (!process.env.ANTHROPIC_API_KEY) {
await namespaceWrapper.logMessage( await namespaceWrapper.logMessage(
@ -93,7 +83,11 @@ export async function task(roundNumber: number): Promise<void> {
await namespaceWrapper.storeSet(`result-${roundNumber}`, status.GITHUB_CHECK_FAILED); await namespaceWrapper.storeSet(`result-${roundNumber}`, status.GITHUB_CHECK_FAILED);
return; return;
} }
if (!orcaClient) {
await namespaceWrapper.logMessage(LogLevel.Error, errorMessage.NO_ORCA_CLIENT, actionMessage.NO_ORCA_CLIENT);
await namespaceWrapper.storeSet(`result-${roundNumber}`, status.NO_ORCA_CLIENT);
return;
}
const stakingKeypair = await namespaceWrapper.getSubmitterAccount(); const stakingKeypair = await namespaceWrapper.getSubmitterAccount();
if (!stakingKeypair) { if (!stakingKeypair) {
@ -161,49 +155,16 @@ export async function task(roundNumber: number): Promise<void> {
}, },
body: JSON.stringify(jsonBody), body: JSON.stringify(jsonBody),
}); });
const repoSummaryResponse = await handleRequest({orcaClient, route: `repo_summary/${roundNumber}`, bodyJSON: jsonBody});
console.log("[TASK] repoSummaryResponse: ", repoSummaryResponse); console.log("[TASK] repoSummaryResponse: ", repoSummaryResponse);
if (repoSummaryResponse.status !== 200) { if (repoSummaryResponse.status !== 200) {
await namespaceWrapper.storeSet(`result-${roundNumber}`, status.ISSUE_SUMMARIZATION_FAILED); await namespaceWrapper.storeSet(`result-${roundNumber}`, status.ISSUE_SUMMARIZATION_FAILED);
console.log("[TASK] repoSummaryResponse.data.result.data ", repoSummaryResponse.data.result.data);
const payload = {
taskId: TASK_ID,
action: "add",
roundNumber: roundNumber,
prUrl: repoSummaryResponse.data.result.data.pr_url,
stakingKey: stakingKey
}
console.log("[TASK] Signing payload: ", payload);
if (repoSummaryResponse.status === 200) {
try{
const signature = await namespaceWrapper.payloadSigning(
payload,
stakingKeypair.secretKey,
);
console.log("[TASK] signature: ", signature);
const addPrToSummarizerTodoResponse = await fetch(`${middleServerUrl}/api/summarizer/add-pr-to-summarizer-todo`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ signature: signature, stakingKey: stakingKey }),
});
console.log("[TASK] addPrToSummarizerTodoResponse: ", addPrToSummarizerTodoResponse);
}catch(error){
await namespaceWrapper.storeSet(`result-${roundNumber}`, status.ISSUE_FAILED_TO_ADD_PR_TO_SUMMARIZER_TODO);
console.error("[TASK] Error adding PR to summarizer todo:", error);
}
await namespaceWrapper.storeSet(`result-${roundNumber}`, status.ISSUE_SUCCESSFULLY_SUMMARIZED);
} else {
await namespaceWrapper.storeSet(`result-${roundNumber}`, status.ISSUE_FAILED_TO_BE_SUMMARIZED);
} }
} catch (error) { } catch (error) {
await namespaceWrapper.storeSet(`result-${roundNumber}`, status.ISSUE_SUMMARIZATION_FAILED); await namespaceWrapper.storeSet(`result-${roundNumber}`, status.ISSUE_SUMMARIZATION_FAILED);
await namespaceWrapper.storeSet(`result-${roundNumber}`, status.ISSUE_FAILED_TO_BE_SUMMARIZED);
console.error("[TASK] EXECUTE TASK ERROR:", error); console.error("[TASK] EXECUTE TASK ERROR:", error);
} }
} catch (error) { } catch (error) {
await namespaceWrapper.storeSet(`result-${roundNumber}`, status.UNKNOWN_ERROR); await namespaceWrapper.storeSet(`result-${roundNumber}`, status.UNKNOWN_ERROR);
console.error("[TASK] EXECUTE TASK ERROR:", error); console.error("[TASK] EXECUTE TASK ERROR:", error);
} }
} }

View File

@ -1,5 +1,5 @@
import { storeFile } from "../utils/ipfs"; import { storeFile } from "../utils/ipfs";
import { handleOrcaClientCreation, handleRequest } from "../utils/orcaHandler/orcaHandler"; import { getOrcaClient } from "@_koii/task-manager/extensions";
import { namespaceWrapper, TASK_ID } from "@_koii/namespace-wrapper"; import { namespaceWrapper, TASK_ID } from "@_koii/namespace-wrapper";
import { status } from "../utils/constant"; import { status } from "../utils/constant";
export async function submission(roundNumber: number) : Promise<string | void> { export async function submission(roundNumber: number) : Promise<string | void> {
@ -13,14 +13,11 @@ export async function submission(roundNumber: number) : Promise<string | void> {
try { try {
console.log("[SUBMISSION] Initializing Orca client..."); console.log("[SUBMISSION] Initializing Orca client...");
let orcaClient; const orcaClient = await getOrcaClient();
try { if (!orcaClient) {
orcaClient = await handleOrcaClientCreation();
}catch{
console.error("[SUBMISSION] Failed to initialize Orca client"); console.error("[SUBMISSION] Failed to initialize Orca client");
return; return;
} }
console.log("[SUBMISSION] Orca client initialized successfully"); console.log("[SUBMISSION] Orca client initialized successfully");
console.log(`[SUBMISSION] Fetching task result for round ${roundNumber}...`); console.log(`[SUBMISSION] Fetching task result for round ${roundNumber}...`);
@ -37,7 +34,7 @@ export async function submission(roundNumber: number) : Promise<string | void> {
} }
console.log(`[SUBMISSION] Fetching submission data for round ${roundNumber}...`); console.log(`[SUBMISSION] Fetching submission data for round ${roundNumber}...`);
const result = await handleRequest({orcaClient, route: `submission/${roundNumber}`, bodyJSON: { taskId: TASK_ID, roundNumber }}); const result = await orcaClient.podCall(`submission/${roundNumber}`);
let submission; let submission;
console.log("[SUBMISSION] Submission result:", result.data); console.log("[SUBMISSION] Submission result:", result.data);
@ -102,4 +99,4 @@ export async function submission(roundNumber: number) : Promise<string | void> {
console.error("[SUBMISSION] Error during submission process:", error); console.error("[SUBMISSION] Error during submission process:", error);
throw error; throw error;
} }
} }

View File

@ -1,6 +1,6 @@
import { getOrcaClient } from "@_koii/task-manager/extensions";
import { middleServerUrl, status } from "../utils/constant"; import { middleServerUrl, status } from "../utils/constant";
import { submissionJSONSignatureDecode } from "../utils/submissionJSONSignatureDecode"; import { submissionJSONSignatureDecode } from "../utils/submissionJSONSignatureDecode";
import { handleOrcaClientCreation, handleRequest } from "../utils/orcaHandler/orcaHandler";
// import { status } from '../utils/constant' // import { status } from '../utils/constant'
export async function audit(cid: string, roundNumber: number, submitterKey: string): Promise<boolean | void> { export async function audit(cid: string, roundNumber: number, submitterKey: string): Promise<boolean | void> {
/** /**
@ -11,13 +11,11 @@ export async function audit(cid: string, roundNumber: number, submitterKey: stri
*/ */
try { try {
let orcaClient; const orcaClient = await getOrcaClient();
try { if (!orcaClient) {
orcaClient = await handleOrcaClientCreation(); // await namespaceWrapper.storeSet(`result-${roundNumber}`, status.NO_ORCA_CLIENT);
}catch{
return; return;
} }
// Check if the cid is one of the status // Check if the cid is one of the status
if (Object.values(status).includes(cid)) { if (Object.values(status).includes(cid)) {
// This returns a dummy true // This returns a dummy true
@ -82,4 +80,4 @@ export async function audit(cid: string, roundNumber: number, submitterKey: stri
// When Error---NO RETURN; // When Error---NO RETURN;
// return true; // return true;
} }
} }

View File

@ -64,7 +64,7 @@ export async function routes() {
console.log("[TASK] req.body", req.body); console.log("[TASK] req.body", req.body);
try { try {
if (success) { if (success) {
await namespaceWrapper.storeSet(`result-${roundNumber}`, status.ISSUE_SUMMARIZATION_SUCCEEDED); await namespaceWrapper.storeSet(`result-${roundNumber}`, status.ISSUE_SUCCESSFULLY_SUMMARIZED);
} else { } else {
await namespaceWrapper.storeSet(`result-${roundNumber}`, status.ISSUE_SUMMARIZATION_FAILED); await namespaceWrapper.storeSet(`result-${roundNumber}`, status.ISSUE_SUMMARIZATION_FAILED);
console.error("[TASK] Error summarizing repository:", message); console.error("[TASK] Error summarizing repository:", message);
@ -145,4 +145,4 @@ export async function routes() {
res.status(400).json({ error: "Failed to save PR" }); res.status(400).json({ error: "Failed to save PR" });
} }
}); });
} }

View File

@ -3,7 +3,7 @@ dotenv.config();
export const status = { export const status = {
ISSUE_SUMMARIZATION_FAILED: "Issue summarization failed", ISSUE_SUMMARIZATION_FAILED: "Issue summarization failed",
ISSUE_SUMMARIZATION_SUCCEEDED: "Issue successfully summarized", ISSUE_SUCCESSFULLY_SUMMARIZED: "Issue successfully summarized",
NO_ISSUES_PENDING_TO_BE_SUMMARIZED: "No issues pending to be summarized", NO_ISSUES_PENDING_TO_BE_SUMMARIZED: "No issues pending to be summarized",
ROUND_LESS_THAN_OR_EQUAL_TO_1: "Round <= 1", ROUND_LESS_THAN_OR_EQUAL_TO_1: "Round <= 1",
NO_ORCA_CLIENT: "No orca client", NO_ORCA_CLIENT: "No orca client",
@ -57,6 +57,4 @@ export const defaultBountyMarkdownFile =
export const customReward = 400 * 10 ** 9; // This should be in ROE! export const customReward = 400 * 10 ** 9; // This should be in ROE!
export const middleServerUrl = "https://ik8kcow8ksw8gwgoo0ggosko.dev.koii.network"; export const middleServerUrl = "https://ik8kcow8ksw8gwgoo0ggosko.dev.koii.network";
export const middleServerUrl = "https://builder247-prod.dev.koii.network"