Initial upload to Gitea
This commit is contained in:
1 parent
78193254ad
commit
8478998cae
1485 files changed
+461025
-42348
No files matched your search
@@ -0,0 +1,21 @@
|
||||
"use strict";
|
||||
|
||||
const { RUN_TIMEOUT_MS } = require("./budgets");
|
||||
|
||||
const AI_AGENT_JOB_RUNTIME_CAP_MESSAGE = `ADPanel Agent job exceeded its ${Math.round(RUN_TIMEOUT_MS / 60000)} minute runtime cap.`;
|
||||
|
||||
class AiAgentJobDeadlineExceeded extends Error {
|
||||
constructor(message) {
|
||||
super(message);
|
||||
this.name = "AiAgentJobDeadlineExceeded";
|
||||
this.status = 504;
|
||||
}
|
||||
}
|
||||
|
||||
function assertAiAgentJobDeadline(req) {
|
||||
req?.aiAgentChatSignal?.throwIfAborted();
|
||||
const deadlineMs = Number(req?.aiAgentJobDeadlineMs || 0);
|
||||
if (deadlineMs && Date.now() >= deadlineMs) throw new AiAgentJobDeadlineExceeded(AI_AGENT_JOB_RUNTIME_CAP_MESSAGE);
|
||||
}
|
||||
|
||||
module.exports = { AiAgentJobDeadlineExceeded, assertAiAgentJobDeadline };
|
||||
Reference in new issue
Block a user