resolve more conflicts and push
This commit is contained in:
@ -32,7 +32,8 @@
|
||||
"lodash": "^4.17.21",
|
||||
"nodemon": "^3.1.0",
|
||||
"seedrandom": "^3.0.5",
|
||||
"tail": "^2.2.6"
|
||||
"tail": "^2.2.6",
|
||||
"uuid": "^11.1.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@_koii/namespace-wrapper": "^1.0.23"
|
||||
|
@ -1,4 +1,4 @@
|
||||
|
||||
import { getOrcaClient } from "@_koii/task-manager/extensions";
|
||||
import { namespaceWrapper, TASK_ID } from "@_koii/namespace-wrapper";
|
||||
import "dotenv/config";
|
||||
import { status, middleServerUrl } from "../utils/constant";
|
||||
@ -9,8 +9,6 @@ import { LogLevel } from "@_koii/namespace-wrapper/dist/types";
|
||||
import { actionMessage } from "../utils/constant";
|
||||
import { errorMessage } from "../utils/constant";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import { handleOrcaClientCreation, handleRequest } from "../utils/orcaHandler/orcaHandler";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
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
|
||||
if (roundNumber >= 4) {
|
||||
const triggerFetchAuditResult = await fetch(`${middleServerUrl}/summarizer/worker/update-audit-result`, {
|
||||
const triggerFetchAuditResult = await fetch(`${middleServerUrl}/api/summarizer/trigger-fetch-audit-result`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
@ -37,14 +34,7 @@ export async function task(roundNumber: number): Promise<void> {
|
||||
}
|
||||
console.log(`[TASK] EXECUTE TASK FOR ROUND ${roundNumber}`);
|
||||
try {
|
||||
let orcaClient;
|
||||
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;
|
||||
}
|
||||
const orcaClient = await getOrcaClient();
|
||||
// check if the env variable is valid
|
||||
if (!process.env.ANTHROPIC_API_KEY) {
|
||||
await namespaceWrapper.logMessage(
|
||||
@ -93,7 +83,11 @@ export async function task(roundNumber: number): Promise<void> {
|
||||
await namespaceWrapper.storeSet(`result-${roundNumber}`, status.GITHUB_CHECK_FAILED);
|
||||
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();
|
||||
if (!stakingKeypair) {
|
||||
@ -161,49 +155,16 @@ export async function task(roundNumber: number): Promise<void> {
|
||||
},
|
||||
body: JSON.stringify(jsonBody),
|
||||
});
|
||||
const repoSummaryResponse = await handleRequest({orcaClient, route: `repo_summary/${roundNumber}`, bodyJSON: jsonBody});
|
||||
console.log("[TASK] repoSummaryResponse: ", repoSummaryResponse);
|
||||
if (repoSummaryResponse.status !== 200) {
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
} catch (error) {
|
||||
await namespaceWrapper.storeSet(`result-${roundNumber}`, status.UNKNOWN_ERROR);
|
||||
console.error("[TASK] EXECUTE TASK ERROR:", error);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
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 { status } from "../utils/constant";
|
||||
export async function submission(roundNumber: number) : Promise<string | void> {
|
||||
@ -13,14 +13,11 @@ export async function submission(roundNumber: number) : Promise<string | void> {
|
||||
|
||||
try {
|
||||
console.log("[SUBMISSION] Initializing Orca client...");
|
||||
let orcaClient;
|
||||
try {
|
||||
orcaClient = await handleOrcaClientCreation();
|
||||
}catch{
|
||||
const orcaClient = await getOrcaClient();
|
||||
if (!orcaClient) {
|
||||
console.error("[SUBMISSION] Failed to initialize Orca client");
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("[SUBMISSION] Orca client initialized successfully");
|
||||
|
||||
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}...`);
|
||||
const result = await handleRequest({orcaClient, route: `submission/${roundNumber}`, bodyJSON: { taskId: TASK_ID, roundNumber }});
|
||||
const result = await orcaClient.podCall(`submission/${roundNumber}`);
|
||||
let submission;
|
||||
|
||||
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);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
import { getOrcaClient } from "@_koii/task-manager/extensions";
|
||||
import { middleServerUrl, status } from "../utils/constant";
|
||||
import { submissionJSONSignatureDecode } from "../utils/submissionJSONSignatureDecode";
|
||||
import { handleOrcaClientCreation, handleRequest } from "../utils/orcaHandler/orcaHandler";
|
||||
// import { status } from '../utils/constant'
|
||||
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 {
|
||||
let orcaClient;
|
||||
try {
|
||||
orcaClient = await handleOrcaClientCreation();
|
||||
}catch{
|
||||
const orcaClient = await getOrcaClient();
|
||||
if (!orcaClient) {
|
||||
// await namespaceWrapper.storeSet(`result-${roundNumber}`, status.NO_ORCA_CLIENT);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if the cid is one of the status
|
||||
if (Object.values(status).includes(cid)) {
|
||||
// This returns a dummy true
|
||||
@ -82,4 +80,4 @@ export async function audit(cid: string, roundNumber: number, submitterKey: stri
|
||||
// When Error---NO RETURN;
|
||||
// return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -64,7 +64,7 @@ export async function routes() {
|
||||
console.log("[TASK] req.body", req.body);
|
||||
try {
|
||||
if (success) {
|
||||
await namespaceWrapper.storeSet(`result-${roundNumber}`, status.ISSUE_SUMMARIZATION_SUCCEEDED);
|
||||
await namespaceWrapper.storeSet(`result-${roundNumber}`, status.ISSUE_SUCCESSFULLY_SUMMARIZED);
|
||||
} else {
|
||||
await namespaceWrapper.storeSet(`result-${roundNumber}`, status.ISSUE_SUMMARIZATION_FAILED);
|
||||
console.error("[TASK] Error summarizing repository:", message);
|
||||
@ -145,4 +145,4 @@ export async function routes() {
|
||||
res.status(400).json({ error: "Failed to save PR" });
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -3,7 +3,7 @@ dotenv.config();
|
||||
|
||||
export const status = {
|
||||
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",
|
||||
ROUND_LESS_THAN_OR_EQUAL_TO_1: "Round <= 1",
|
||||
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 middleServerUrl = "https://ik8kcow8ksw8gwgoo0ggosko.dev.koii.network";
|
||||
|
||||
export const middleServerUrl = "https://builder247-prod.dev.koii.network"
|
||||
export const middleServerUrl = "https://ik8kcow8ksw8gwgoo0ggosko.dev.koii.network";
|
Reference in New Issue
Block a user