This commit is contained in:
ZacharyZhang-NY committed 2026-03-18 17:49:10 -04:00
1 parent 48daca9ba0
commit 53e0f03c0c
13 files changed
+509 -125

No files matched your search

+11 -3
View File
@@ -1,6 +1,8 @@
import { buildTaskPrompt } from "./prompt-builder";
import type { AppDatabase } from "./database";
import { getConnectorExecutionReadinessIssue } from "@shared/connector-policy";
import type { DesktopResult } from "@shared/contracts";
import type { ConnectorRecord } from "@shared/types";
type WorkspaceLockMode = "exclusive" | "shared" | "none";
@@ -140,7 +142,7 @@ export function createOrchestrationService({
function getRunEligibilityFailure(
agent: { status: string; budgetMonthlyUsd: number; spentMonthlyUsd: number; name: string; connectorId: string; id: string; companyId: string },
connector: { id: string; status: string },
connector: Pick<ConnectorRecord, "id" | "label" | "status" | "capabilityMatrix">,
) {
if (["terminated", "paused", "pending_approval"].includes(agent.status)) {
return "AGENT_NOT_RUNNABLE";
@@ -150,8 +152,10 @@ export function createOrchestrationService({
logger.info(`[run] Agent ${agent.name} budget exhausted, skipping`);
return "AGENT_BUDGET_EXHAUSTED";
}
if (connector.status !== "ready" && connector.status !== "degraded") {
logger.info(`[run] Agent ${agent.name} connector ${connector.id} not ready (${connector.status})`);
const connectorIssue = getConnectorExecutionReadinessIssue(connector);
if (connectorIssue) {
const issue = connectorIssue ?? `Connector ${connector.id} is not execution-ready.`;
logger.info(`[run] Agent ${agent.name} connector ${connector.id} blocked: ${issue}`);
return "CONNECTOR_NOT_READY";
}
return null;
@@ -174,6 +178,10 @@ export function createOrchestrationService({
if (!hasWorkerReady()) {
throw new Error("Orchestration worker is not ready.");
}
const connectorIssue = getConnectorExecutionReadinessIssue(connector);
if (connectorIssue) {
throw new Error(connectorIssue);
}
const env = db.resolveSecretEnv(connector.envBindingText, companyId);
const apiPort = getApiPort();