// src/delegation/index.ts
var DELEGATION_MCP_SERVER_KEY = "agent-runtime-delegation";
var DELEGATION_TOOLS = [
  "delegate_code",
  "delegate_research",
  "delegate_feedback",
  "delegation_status",
  "delegation_history"
];
function buildDelegationMcpServer(opts) {
  if (!opts.apiKey) return void 0;
  const env = { TANGLE_API_KEY: opts.apiKey };
  const forward = opts.forwardEnv ?? {};
  for (const key of ["SANDBOX_BASE_URL", "OTEL_EXPORTER_OTLP_ENDPOINT", "OTEL_EXPORTER_OTLP_HEADERS", "TRACE_ID", "PARENT_SPAN_ID"]) {
    const value = forward[key];
    if (value) env[key] = value;
  }
  return {
    transport: "stdio",
    command: "npx",
    args: ["-y", opts.packageSpec ?? "@tangle-network/agent-runtime", "mcp"],
    env,
    enabled: true,
    metadata: { surface: "delegation:dispatch", tools: DELEGATION_TOOLS }
  };
}
function delegationMcpForConfig(config, opts) {
  if (!config.delegation?.enabled) return {};
  const server = buildDelegationMcpServer(opts);
  return server ? { [DELEGATION_MCP_SERVER_KEY]: server } : {};
}

export {
  DELEGATION_MCP_SERVER_KEY,
  DELEGATION_TOOLS,
  buildDelegationMcpServer,
  delegationMcpForConfig
};
//# sourceMappingURL=chunk-AQ2BOPOQ.js.map