Skip to content

Open-source, local-first AI agent for real work.

1.7 KB
Raw Blame
import type { SubagentCoordinatorPort } from "@vetta/runtime-subagents";
import type { CodingAgentWorkflowDispatcherPort } from "../../runtime-contracts/index.js";
import {
	CODING_AGENT_MODEL_TOOL_ORDER,
	CODING_AGENT_SUBAGENT_MODEL_TOOL_ORDER_STEP,
} from "../../tool-policy/model-tool-order.js";
import {
	createDispatchWorkflowsToolRegistration,
	createFollowupTaskToolRegistration,
	createInterruptAgentToolRegistration,
	createListAgentsToolRegistration,
	createSendMessageToolRegistration,
	createSpawnAgentToolRegistration,
	createWaitAgentToolRegistration,
} from "./tools/index.js";

/** 组装 Coding Agent 工具顺序;协议归 @vetta/runtime-tools,Node 实现归 @vetta/runtime-node。 */
export function createCodingAgentSubagentRuntimeToolRegistrations(
	getCoordinator: () => SubagentCoordinatorPort | undefined,
	getWorkflowDispatcher: () => CodingAgentWorkflowDispatcherPort | undefined,
	workflowTypeId = "workflow",
) {
	const order = (index: number) =>
		CODING_AGENT_MODEL_TOOL_ORDER.subagentStart + index * CODING_AGENT_SUBAGENT_MODEL_TOOL_ORDER_STEP;
	return [
		createSpawnAgentToolRegistration({ getCoordinator, modelOrder: order(0) }),
		createDispatchWorkflowsToolRegistration({ getWorkflowDispatcher, workflowTypeId, modelOrder: order(1) }),
		createWaitAgentToolRegistration({ getCoordinator, workflowTypeId, modelOrder: order(2) }),
		createListAgentsToolRegistration({ getCoordinator, modelOrder: order(3) }),
		createInterruptAgentToolRegistration({ getCoordinator, modelOrder: order(4) }),
		createSendMessageToolRegistration({ getCoordinator, modelOrder: order(5) }),
		createFollowupTaskToolRegistration({ getCoordinator, modelOrder: order(6) }),
	] as const;
}